Skip to main content

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]

GitHub release Build License PyPI Downloads discord-invite

Documentation | Join Discord

LangBatch is a Python library for large scale AI generation using batch APIs from providers like OpenAI, Azure OpenAI, GCP Vertex AI, 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

  • Unified API to access Batch APIs from different providers.
  • Standarized OpenAI format for requests and responses
  • Utilities for handling the complete lifecycle of a batch job: Creating, Starting, Monitoring, Retrying and Processing Completed
  • Convert 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 OpenAIChatCompletionBatch
batch = OpenAIChatCompletionBatch("openai_chat_completion_requests.jsonl")
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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

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

langbatch-0.1.1.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

langbatch-0.1.1-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file langbatch-0.1.1.tar.gz.

File metadata

  • Download URL: langbatch-0.1.1.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Windows/10

File hashes

Hashes for langbatch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 64187de4ce43e1f8d7fb50ccd40334c839ff0b2fd6c24757ff3da9094bba8f59
MD5 8ec2252b2ae670d67db26a3846647435
BLAKE2b-256 0a7c2a65ffd2f550df4d8a42e07a9da0503b73aa81e78b8c0bf1bad2dd09a6f1

See more details on using hashes here.

File details

Details for the file langbatch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langbatch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.1 Windows/10

File hashes

Hashes for langbatch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 768d6366186af7370c8ba69147fca55b724ced622c9c46afc9558dca73474289
MD5 a1166916bee74d95e85c0cacd40fab5f
BLAKE2b-256 6cdc78ae288d946e43ca333f4745270efa642bc19beb322d0b7b87ba702e273f

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