Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async_llms-0.2.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_llms-0.2.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file async_llms-0.2.3.tar.gz.

File metadata

  • Download URL: async_llms-0.2.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for async_llms-0.2.3.tar.gz
Algorithm Hash digest
SHA256 31d0eabe25f0f5329fe4dac5e3cc7503bdf3c5a7c403f94b71a29c5b85066a77
MD5 e885746bbd6125c1efbb611bf1cb3177
BLAKE2b-256 05e1f67f9f03ff7cdce79fb38d2985fa6fccf4e2e347e10b14b10388305dc236

See more details on using hashes here.

File details

Details for the file async_llms-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: async_llms-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for async_llms-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d97787f5854a0f5fb9ccaf58127b1fb95849e894b6bb3a5e2a56c9440ad951d5
MD5 6de5c8c37ebc59999abdec86e3c2f2fa
BLAKE2b-256 da07bf30cd7c696b4e2dd7860cdf0345fc4bca4f54bdb7b1b79275dd282066cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page