LangBatch is a python package with unified API for AI batch processing workloads. Supports OpenAI, Anthropic, Azure OpenAI, Vertex AI
Project description
Call all Batch APIs using the OpenAI format [OpenAI, Anthropic, Azure OpenAI, Vertex AI, Bedrock]
LangBatch is a unified API for accessing Batch APIs from providers like OpenAI, Anthropic, Azure OpenAI, Vertex AI, Bedrock, etc.
Utlize Batch APIs for
- Request that don't require immediate responses.
- Low cost (usually 50% discount)
- Higher rate limits
- Example use cases: Data processing pipelines, Evaluations, Classifying huge data, Creating embeddings for large text contents
Key Features
- OpenAI format for requests and responses
- Utilities for handling the complete lifecycle of a batch job: Creating, Starting, Monitoring, Retrying and Processing
- Pipeline to convert stream of incoming requests into batch jobs
Installation
PyPI:
pip install langbatch
Alternatively, from source:
pip install git+https://github.com/EasyLLM/langbatch
Find the complete Installation guide here.
Quickstart
Here is the 3 main lines to start a batch job:
from langbatch import chat_completion_batch
batch = chat_completion_batch("openai_chat_completion_requests.jsonl", provider="openai")
batch.start()
Check the status of the batch and get the results:
if batch.get_status() == "completed":
results, _ = batch.get_results()
for result in results:
print(f"Custom ID: {result['custom_id']}")
print(f"Content: {result['choices'][0]['message']['content']}")
Find the complete Get Started guide here.
🫂 Community
If you want to get more involved with LangBatch, check out our discord server
Contributors
+----------------------------------------------------------------------------+
| +----------------------------------------------------------------+ |
| | Developers: Those who built with `langbatch`. | |
| | (You have `import langbatch` somewhere in your project) | |
| | +----------------------------------------------------+ | |
| | | Contributors: Those who make `langbatch` better. | | |
| | | (You make PR to this repo) | | |
| | +----------------------------------------------------+ | |
| +----------------------------------------------------------------+ |
+----------------------------------------------------------------------------+
We welcome contributions from the community! Whether it's bug fixes, feature additions, or documentation improvements, your input is valuable.
- Fork the repository
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langbatch-0.1.2.tar.gz.
File metadata
- Download URL: langbatch-0.1.2.tar.gz
- Upload date:
- Size: 31.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bde01e3d23294033974832e693a4ad99b2f4435d74b6664f17b0eebb384b408
|
|
| MD5 |
eae5a57d3ad7972ae0d84e43084e1546
|
|
| BLAKE2b-256 |
a97b20c7459b4362a0e117d82584efb96c648be81b5cce897fa1c6514a3dd37f
|
File details
Details for the file langbatch-0.1.2-py3-none-any.whl.
File metadata
- Download URL: langbatch-0.1.2-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ea148900d20634d9fc02470f5404c8668e5f74af1e02a9a078ca4bb78778683
|
|
| MD5 |
5b2d29bfd3cd26988998666ef3ee6396
|
|
| BLAKE2b-256 |
44bf5f28672f936387851999edbdfcd20b3cb075fa9bb53ecfaf6e70c55586d6
|