Skip to main content

Takeoff Client is a Python client for the Takeoff Server

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

takeoff_client-0.6.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

takeoff_client-0.6.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file takeoff_client-0.6.0.tar.gz.

File metadata

  • Download URL: takeoff_client-0.6.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for takeoff_client-0.6.0.tar.gz
Algorithm Hash digest
SHA256 5be7f4096a3f666850c4e2c3bd3bb7ed53c649006ecf6b6e9d3a65cc8b27337e
MD5 799e2bf0d7367dcd0f5637e5ec632d6b
BLAKE2b-256 6c8c8a97ad014005f512b56f47d830e2d0ee9cca2189c950e94411b9adee68a1

See more details on using hashes here.

File details

Details for the file takeoff_client-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for takeoff_client-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e05e11d7839f5d5c052583152b558b791674bce8ffb73c045a2e2d4f60de48f1
MD5 45acc273d110e5b1531d2e409e1fe800
BLAKE2b-256 7175a6ef1200e941b59095c4311cb14b295e6d46a542df9f798488744a14636c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page