Default template for PDM package
Project description
OpenAI Batcher
OpenAI Batcher is a Python package designed to process batches of user prompts using OpenAI's API. It allows for efficient batch processing and monitoring of jobs.
Installation
you can install the package directly using pip:
pip install openai-batcher
Alternatively, You can clone the repository and install the dependencies:
git clone https://github.com/srinathmkce/openai-batcher
cd openai_batcher
pdm install
Usage
Set your openai key
export OPENAI_API_KEY=<SET-YOUR-OPENAI-KEY-HERE>
Here's an example of how to use the process_batch function from the package:
from openai_batcher.batch import process_batch
from datasets import load_dataset
# Load dataset
dataset = load_dataset("stanfordnlp/imdb")
train_df = dataset["train"].to_pandas()
# Define system prompt
system_prompt = """
your task is to analyze the sentiment of the review and classify it as Positive or Negative. DO not add any explanation.
JSON:{"sentiment": String // Positive or Negative}
"""
# Process batch
process_batch(
system_prompt=system_prompt,
batch_user_prompts=train_df["text"],
start_index=0,
end_index=25,
batch_size=5
)
Development
To develop this package inside a development container, use the provided devcontainer.json and Dockerfile.
Using Dev Container Open the project in Visual Studio Code.Install the Remote - Containers extension.Reopen the project in the container. Building the Docker Image To build the Docker image manually, run:
docker build -t openai-batcher .
Next Steps
Your contribuitions are welcome. Following features are yet to be added
- Checkpointing
- Auto-Batching
- Improved Polling meachnism
- Test Cases
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openai_batcher-0.1.0.tar.gz
.
File metadata
- Download URL: openai_batcher-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.18.1 CPython/3.11.9 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 858ee7442cc29c043be71b8e8c924c66dab42aff1d90c05241aac8f0456a58de |
|
MD5 | f50681df30a922d836517e0e42fc7c09 |
|
BLAKE2b-256 | 604696dd86acfc3d312e26cf5e2e1781dca307566b5281081ec9a0622dc886b5 |
File details
Details for the file openai_batcher-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: openai_batcher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.18.1 CPython/3.11.9 Linux/5.10.102.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd45ec4767a6aef00017b3818e7096d5806776e43397defe1695d5d3a7902cb |
|
MD5 | 3ddd89c4a21fe384a7c5e20362fa79c8 |
|
BLAKE2b-256 | 2c320dbe73143164dded387ee9ec096d956244521445b930eacf5b99e9d9788b |