Skip to main content

Takeoff Python Client Library

Table of Contents

About

The Takeoff Python Client Library serves as an essential tool for interacting with the Takeoff Server. It simplifies the process of sending requests to the server, offering a streamlined, Pythonic interface. This library is designed for developers who need to integrate their Python applications with the Takeoff Server, providing them with a robust and efficient way to communicate with the server's API.

Getting Started

Installing

To get started with the Takeoff Python Client Library, you can install it directly using pip:

pip install takeoff_client

Alternatively, if you are working on developing the library, you can install it in editable mode. This allows you to make changes to the library and test them in real-time. Navigate to the python-client folder and run the following command:

pip install -e . 

Usage

Establishing a Connection

To start using the client, you need to establish a connection with the Takeoff Server. You can do this by creating an instance of the TakeoffClient. Replace "http://localhost" and 3000 with the appropriate URL and port of your Takeoff Server.

client = TakeoffClient(base_url="http://localhost", port=3000)

Interaction with Server

For more details, please check the API documentation below.

Retrieving Reader Information

To get information about the reader from the server, use the get_reader() method. This method sends a request to the server and returns reader-related information.

client.get_reader() 

Embedding

For querying the embedding model, use the embed() method.

client.embed("Text to embed")

Generation

To generate text based on a given input, use the generate() method.

client.generate("Text to generate")

Takeoff Python Client API Documentation

To convert the provided method descriptions into API documentation, I'll structure each description to include key components like a brief overview, parameters, return type, and any additional notes or exceptions. Here's how the API documentation can be structured:


Takeoff Python Client API Documentation

1. get_readers()

Overview: Retrieves a list of information about all readers from the Takeoff Server.

Returns:

  • dict: A dictionary containing information about all readers.

Example Usage:

reader_info = client.get_readers()

2. embed(text, consumer_group="embed")

Overview: Embeds a batch of text using the specified consumer group.

Parameters:

  • text (str | List[str]): The text or list of texts to be embedded.
  • consumer_group (str, optional): The consumer group to use for embedding. Defaults to "embed".

Returns:

  • dict: A dictionary containing the embedding response.

Exceptions:

  • Raises an exception if the embedding request fails.

Example Usage:

embedding_response = client.embed("Sample text")

3. generate(text, sampling_temperature=None, sampling_topp=None, sampling_topk=None, max_new_tokens=None, min_new_tokens=None, regex_string=None, json_schema=None, prompt_max_tokens=None, consumer_group="primary")

Overview: Generates text based on the given input and parameters.

Parameters:

  • text (str | List[str]): The input text or list of texts for generation.
  • Additional optional parameters for controlling text generation:
    • sampling_temperature (float)
    • sampling_topp (float)
    • sampling_topk (int)
    • max_new_tokens (int)
    • min_new_tokens (int)
    • regex_string (str)
    • json_schema (Any)
    • prompt_max_tokens (int)
    • consumer_group (str): Defaults to "primary".

Returns:

  • dict: A dictionary containing the generated text response.

Exceptions:

  • Raises an exception if the text generation request fails.

Example Usage:

generated_text = client.generate("Sample input text")

4. generate_stream(text, sampling_temperature=None, sampling_topp=None, sampling_topk=None, max_new_tokens=None, min_new_tokens=None, regex_string=None, json_schema=None, prompt_max_tokens=None, consumer_group="primary")

Overview: Similar to generate, but returns an iterator for streaming the generated text.

Parameters:

  • Same as generate method.

Returns:

  • Iterator[Event]: An iterator that yields a server sent event

Exceptions:

  • Raises an exception if the text generation request fails.

Example Usage:

generator = client.generate_stream(["Sample input"])
for event in generator:
    print(event.data)

Metadata

Release files for takeoff-client 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for takeoff-client 0.7.0
File Size Uploaded Provenance Actions
takeoff_client-0.7.0.tar.gz 16.0 kB Without provenance Details for takeoff_client-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for takeoff-client 0.7.0
File Interpreter ABI Platform Actions
takeoff_client-0.7.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for takeoff_client-0.7.0-py2.py3-none-any.whl

Total release size: 27.3 kB

Release files / takeoff_client-0.7.0.tar.gz

Download URL takeoff_client-0.7.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6a92f11035357833ab302866ad067c865bc1a12d85d72c768411675e1f37d839
BLAKE2b-256 checksum
How to use checksums
c16b92cb0b646462de94491c9d18d23bd214bc59f29d8fb9daa72fd057a72e42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / takeoff_client-0.7.0-py2.py3-none-any.whl

Download URL takeoff_client-0.7.0-py2.py3-none-any.whl
Size 11.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ff30e70de65c57d8413d743a810c23aa285631f503d3d1c25053820ac17e4abe
BLAKE2b-256 checksum
How to use checksums
acd58d350df5d0b3f08f389f3f3c2ae5e7c5f140e42c2b3bf0376f4780f399be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for takeoff-client 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page