Skip to main content

A package for batch processing with OpenAI API.

Project description

Certainly! Here's a clean and comprehensive README for your GPTBatcher tool, formatted in Markdown:

# GPT Batcher

A simple tool to batch process messages using OpenAI's GPT models. `GPTBatcher` allows for efficient handling of multiple requests simultaneously, ensuring quick responses and robust error management.

## Installation

To get started with `GPTBatcher`, clone this repository to your local machine. Navigate to the repository directory and install the required dependencies (if any) by running:

```bash
pip install gpt_batch

Quick Start

To use GPTBatcher, you need to instantiate it with your OpenAI API key and the model name you wish to use. Here's a quick guide:

Handling Message Lists

This example demonstrates how to send a list of questions and receive answers:

from gpt_batch.batcher import GPTBatcher

# Initialize the batcher
batcher = GPTBatcher(api_key='your_key_here', model_name='gpt-3.5-turbo-1106')

# Send a list of messages and receive answers
result = batcher.handle_message_list(['question_1', 'question_2', 'question_3', 'question_4'])
print(result)
# Expected output: ["answer_1", "answer_2", "answer_3", "answer_4"]

Handling Embedding Lists

This example shows how to get embeddings for a list of strings:

from gpt_batch.batcher import GPTBatcher

# Reinitialize the batcher for embeddings
batcher = GPTBatcher(api_key='your_key_here', model_name='text-embedding-3-small')

# Send a list of strings and get their embeddings
result = batcher.handle_embedding_list(['question_1', 'question_2', 'question_3', 'question_4'])
print(result)
# Expected output: ["embedding_1", "embedding_2", "embedding_3", "embedding_4"]

Configuration

The GPTBatcher class can be customized with several parameters to adjust its performance and behavior:

  • api_key (str): Your OpenAI API key.
  • model_name (str): Identifier for the GPT model version you want to use, default is 'gpt-3.5-turbo-1106'.
  • system_prompt (str): Initial text or question to seed the model, default is empty.
  • temperature (float): Adjusts the creativity of the responses, default is 1.
  • num_workers (int): Number of parallel workers for request handling, default is 64.
  • timeout_duration (int): Timeout for API responses in seconds, default is 60.
  • retry_attempts (int): How many times to retry a failed request, default is 2.
  • miss_index (list): Tracks indices of requests that failed to process correctly.

For more detailed documentation on the parameters and methods, refer to the class docstring.

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

gpt_batch-0.1.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

gpt_batch-0.1.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file gpt_batch-0.1.3.tar.gz.

File metadata

  • Download URL: gpt_batch-0.1.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for gpt_batch-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d0c89afe88eb01db78d6b8ef1de13aac14b17fde002a97f907d7932e09132caa
MD5 e3da77be739cb61f508b10816be744c9
BLAKE2b-256 c58e46e0b67f487ff5df2ba61f5d839fa349586e8d8af43e311ed67043d54877

See more details on using hashes here.

File details

Details for the file gpt_batch-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: gpt_batch-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for gpt_batch-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3463b1e7abadbcdd04b12fc158e7aae3b663bfe739a25361f85d466fa92650e8
MD5 d00ab589f17570f813a124cee9a588b7
BLAKE2b-256 22a05575c055468b74aa0a64a5f6f1791104caa12caae509eaa31d85fe67f1aa

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