A Python library for making asynchronous LLM calls
Project description
async-llms: A Python Library for Asynchronous LLM Calls
async-llms is a Python library for making asynchronous LLM calls to accelerate LLM evaluation experiments.
Installation
You can install the package using pip:
pip install async-llms
Usage
Set API Key
Set the API key for the LLM provider you want to use.
export OPENAI_API_KEY="your_api_key"
export GOOGLE_API_KEY="your_api_key"
export XAI_API_KEY="your_api_key"
If you are using Google Vertex AI, you can set the project and location using the GOOGLE_PROJECT and GOOGLE_LOCATION environment variables.
export USE_VERTEX_AI="True" # default is False
export GOOGLE_PROJECT="your_project"
export GOOGLE_LOCATION="your_location" # "us-central1"
(Optional) Set Timeout
You can set the timeout for the LLM calls using the ASYNC_LLM_TIMEOUT environment variable.
export ASYNC_LLM_TIMEOUT=1800 # 1800 seconds per request
Command Line Interface
You can use the package directly from the command line:
async-llms \
--api_type "openai" \
--input_jsonl "path/to/input.jsonl" \
--output_jsonl "path/to/output.jsonl" \
--num_parallel_tasks "num_parallel_tasks"
Input Format
The input JSONL file format is identical to the one used in OpenAI's Batch API: https://platform.openai.com/docs/guides/batch
{
"custom_id": "unique_id_for_this_request",
"body": {
// Your LLM request parameters here
}
}
License
MIT License
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 async_llms-0.3.3.tar.gz.
File metadata
- Download URL: async_llms-0.3.3.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e94c04cfa90d82c04836e6ded4ebc60d7cc4e4661dde7dab6903030a03f792cc
|
|
| MD5 |
5b3a4565e2bb2263f0ddc6e053ca7e90
|
|
| BLAKE2b-256 |
8171e6fab352a2cf7a7a5e66ea1b47682157fa2a97519ea6b79cc8fb6abec0a0
|
File details
Details for the file async_llms-0.3.3-py3-none-any.whl.
File metadata
- Download URL: async_llms-0.3.3-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b1f5eb7a0692b93dd2641f9829f40b3b7688348a16861be67f3f67681518d37
|
|
| MD5 |
9c10f287f3a9311a4199cd4d3e45686e
|
|
| BLAKE2b-256 |
c736d9e9c01b3c181a73c808e63d13791106f8682b7633054ac456088990cb9a
|