Skip to main content

Async Python client for Autobyteus LLM API

Project description

Autobyteus LLM Client

Python async client library for interacting with the Autobyteus LLM API.

Installation

pip install autobyteus-llm-client

For development/testing:

pip install -e .[test]

Configuration

Set required environment variables:

export AUTOBYTEUS_API_KEY="your_api_key_here"
export AUTOBYTEUS_SERVER_URL="http://localhost:8000"  # Optional, defaults to localhost

Usage

from autobyteus_llm_client import AutobyteusClient

async def main():
    # Initialize client
    client = AutobyteusClient()
    
    # Get available models
    models = await client.get_available_models()
    print(f"Available models: {models}")
    
    # Send a message
    response = await client.send_message(
        conversation_id="test_conv",
        model_name="gpt-4",
        user_message="Hello, world!"
    )
    print(f"Response: {response}")
    
    # Clean up conversation
    await client.cleanup("test_conv")
    await client.close()

# Run the async main function
import asyncio
asyncio.run(main())

Streaming Responses

async def stream_example():
    client = AutobyteusClient()
    try:
        async for chunk in client.stream_message(
            conversation_id="stream_conv",
            model_name="gpt-4",
            user_message="Stream this response"
        ):
            print(f"Received chunk: {chunk}")
    finally:
        await client.cleanup("stream_conv")
        await client.close()

Testing

  1. Create a .env.test file with test credentials:
AUTOBYTEUS_API_KEY="test_key"
AUTOBYTEUS_SERVER_URL="http://test-server:8000"
  1. Run tests:
pytest -v autobyteus_llm_client/tests/

Error Handling

The client will raise RuntimeError for API errors. Always wrap calls in try/except blocks:

try:
    response = await client.send_message(...)
except RuntimeError as e:
    print(f"API error occurred: {str(e)}")

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

autobyteus_llm_client-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

autobyteus_llm_client-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file autobyteus_llm_client-1.0.0.tar.gz.

File metadata

  • Download URL: autobyteus_llm_client-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for autobyteus_llm_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ab6419b218b783c01241173b81741b28c57dec0e5054dd396c3ff3ebf61de23a
MD5 6cd9f2d8ade9e9ac5f6227b21fd889b8
BLAKE2b-256 350cdd4afcc3651892560bb457dc76b595156401b87a31477ff7856ea394bf90

See more details on using hashes here.

File details

Details for the file autobyteus_llm_client-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autobyteus_llm_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b71c003d0cae3dd68ddae6b2d0c6c4193140141eb006c440dd3736e8e10d7735
MD5 bb5d5b790e60d43f0307573319b1a7a5
BLAKE2b-256 8dfe47b267874620f4b97fa8923b7d49c523d2ca766a7f8a1e827acdde762b41

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