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="test-model",
        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="test-model",
            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.1.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.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autobyteus_llm_client-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2085a5ebc2993a4276d18f012e3f9f0307b3be2242e485b78443ffdb4bd44af8
MD5 5407daa60a7c2a512c5ca5d9ed3bc947
BLAKE2b-256 afee4d52d24e747627de0df0487846dd33f58e40c10eb076968b1ed17fbae53f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autobyteus_llm_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7c5b909d8c3cc17732c7f84b07600cf25dca37dbf8667869889ec63589a9f5a
MD5 6bf1eefeb7ef52f823c56836acf5cd26
BLAKE2b-256 36231d968787843796a784aa0f5ce5e130b21096f883ee5b325154eec1075f51

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