SDK for connecting AI agents to Arinova Chat
Project description
arinova-agent-sdk
Python SDK for connecting AI agents to Arinova Chat via WebSocket. Supports streaming responses with automatic reconnection.
Install
pip install arinova-agent-sdk
Requires Python 3.10+.
Quick Start
from arinova_agent import ArinovaAgent
agent = ArinovaAgent(
server_url="https://chat.arinova.ai",
bot_token="your-bot-token",
)
@agent.on_task
async def handle(task):
# Stream chunks to the user
for word in task.content.split():
task.send_chunk(word + " ")
# Signal completion with the full response
task.send_complete("Echo: " + task.content)
agent.run()
agent.run() blocks the process and handles SIGINT/SIGTERM for graceful shutdown. If you are already inside an async context, use await agent.connect() instead:
import asyncio
from arinova_agent import ArinovaAgent
agent = ArinovaAgent(
server_url="https://chat.arinova.ai",
bot_token="your-bot-token",
)
@agent.on_task
async def handle(task):
task.send_chunk("Thinking...")
task.send_complete("Done.")
asyncio.run(agent.connect())
API Reference
Constructor
ArinovaAgent(
server_url: str, # Arinova Chat server URL
bot_token: str, # Bot authentication token
reconnect_interval: float = 5.0, # Seconds between reconnect attempts
ping_interval: float = 30.0, # Seconds between keepalive pings
)
All parameters are keyword-only.
@agent.on_task
Register a task handler. Called each time the agent receives a message from a user. The handler receives a Task object and can be sync or async.
@agent.on_task
async def handle(task):
...
Task Object
| Field | Type | Description |
|---|---|---|
task_id |
str |
Unique identifier for this task |
conversation_id |
str |
Conversation the message belongs to |
content |
str |
The user's message text |
send_chunk |
Callable[[str], None] |
Stream a partial response to the user |
send_complete |
Callable[[str], None] |
Finalize the response with full content |
send_error |
Callable[[str], None] |
Send an error message back to the user |
A typical handler streams chunks as they are generated, then calls send_complete with the assembled full text. If something goes wrong, call send_error instead.
Lifecycle Callbacks
@agent.on_connected
def connected():
print("Connected")
@agent.on_disconnected
def disconnected():
print("Disconnected")
@agent.on_error
def error(exc: Exception):
print("Error:", exc)
on_connected-- called after successful authentication.on_disconnected-- called when the WebSocket connection drops.on_error-- called on connection errors or unhandled exceptions in the task handler.
agent.run()
agent.run() -> None
Start the agent in blocking mode. Creates its own event loop, connects to the server, and reconnects automatically on disconnection. Stops on SIGINT or SIGTERM.
await agent.connect()
await agent.connect() -> None
Start the agent within an existing async event loop. Reconnects automatically until disconnect() is called.
await agent.disconnect()
await agent.disconnect() -> None
Close the WebSocket connection and stop automatic reconnection.
Getting a Bot Token
- Open the Arinova Chat dashboard.
- Navigate to the bot management page and create a new bot.
- Copy the bot token from the bot's settings page.
- Pass it as the
bot_tokenparameter when creating anArinovaAgentinstance.
License
MIT
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 arinova_agent_sdk-0.0.1.tar.gz.
File metadata
- Download URL: arinova_agent_sdk-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
150d05e9f004b9270279cc587904448b1e82ad3325820fc36fed2a1d35965289
|
|
| MD5 |
0520044fb464ae447cd6fa72dbfe2bc4
|
|
| BLAKE2b-256 |
5fe9f58273af693e4d8e97e234490c5bd58b7edcbfa5f6f16f7f8a4ab8bb9a34
|
File details
Details for the file arinova_agent_sdk-0.0.1-py3-none-any.whl.
File metadata
- Download URL: arinova_agent_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9db3029f02b0cf06b496bb35e8dac406c10f7b25580e2f29ab81fbfb31fdea2f
|
|
| MD5 |
66690a2568965ae204543df4c7c8e3b5
|
|
| BLAKE2b-256 |
f0049c5f923a87075e3abda5e07f6374a424cf0a94e45fee700b610f064be583
|