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
- Create a
.env.testfile with test credentials:
AUTOBYTEUS_API_KEY="test_key"
AUTOBYTEUS_SERVER_URL="http://test-server:8000"
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2085a5ebc2993a4276d18f012e3f9f0307b3be2242e485b78443ffdb4bd44af8
|
|
| MD5 |
5407daa60a7c2a512c5ca5d9ed3bc947
|
|
| BLAKE2b-256 |
afee4d52d24e747627de0df0487846dd33f58e40c10eb076968b1ed17fbae53f
|
File details
Details for the file autobyteus_llm_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: autobyteus_llm_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c5b909d8c3cc17732c7f84b07600cf25dca37dbf8667869889ec63589a9f5a
|
|
| MD5 |
6bf1eefeb7ef52f823c56836acf5cd26
|
|
| BLAKE2b-256 |
36231d968787843796a784aa0f5ce5e130b21096f883ee5b325154eec1075f51
|