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-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: autobyteus_llm_client-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7ea0befc8bbfa522336aeb67fba3d79523db6dd57fe25af4c5e90eee4a37329
MD5 91a0b782f42fbc325cec4b9effe0e41c
BLAKE2b-256 7a1e4517a98d5f6f2a1822c860553de57b074fb1001527205536de9a4955cf74

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