Skip to main content

Python SDK for the ZeebeeAI Chat Platform

Project description

ZeebeeAI Python SDK

A powerful Python client for interacting with the ZeebeeAI Chat SDK Platform. This SDK provides access to all platform features including text chat, voice streaming, agent orchestration, and autonomous routing.

Features

  • Multi-Model Chat: Access GPT-4o, Claude-3.5 Sonnet, Grok-2, Qwen, and other models through a unified API
  • Voice Streaming: Real-time bidirectional voice chat with WebSocket support
  • Agent Orchestration: Create and manage AI agent pipelines for complex tasks
  • Autonomous Routing: Intelligent routing of user queries to specialized agents
  • Semantic Search: Integration with vector database for knowledge retrieval
  • Conversation Management: Tools for handling conversation history and context
  • Type Hints: Full type annotations for Python 3.10+ and mypy compatibility

Installation

pip install zeebee-ai-client

Basic Usage

from zeebee_ai_client import ZeebeeClient

# Initialize with your API key
client = ZeebeeClient(api_key="YOUR_API_KEY")

# Send a chat message
def send_message():
    try:
        response = client.chat(
            message="Tell me about artificial intelligence",
            model="gpt-4o"  # Optional, default is 'gpt-4o'
        )
        
        print(f"AI response: {response['response']}")
        print(f"Conversation ID: {response['conversation_id']}")
        return response
    except Exception as e:
        print(f"Error: {e}")

# Stream chat responses
def stream_chat():
    try:
        # Enable streaming
        for chunk in client.chat(
            message="Write a short story about a robot",
            model="claude-3-5-sonnet",
            stream=True,
        ):
            # Print each chunk as it arrives
            if "text" in chunk:
                print(chunk["text"], end="", flush=True)
            
    except Exception as e:
        print(f"Error: {e}")

Voice Chat

import asyncio

async def voice_chat_example():
    try:
        # Voice chat with file input
        result = await client.voice_chat(
            audio_source="path/to/your/audio.webm",
            model="gpt-4o",
            # Optional handler for streaming response
            stream_handler=lambda chunk: print(f"Received chunk: {len(chunk)} bytes") 
        )
        
        print(f"Transcribed text: {result['text']}")
        print(f"Conversation ID: {result['conversation_id']}")
        
        # Save the audio response to a file
        with open("response.webm", "wb") as f:
            f.write(result["audio"])
            
    except Exception as e:
        print(f"Error in voice chat: {e}")

# Run the async function
asyncio.run(voice_chat_example())

Agent Orchestration

from zeebee_ai_client import ZeebeeClient, AgentController, PipelineController

# Initialize client and controllers
client = ZeebeeClient(api_key="YOUR_API_KEY")
agent_controller = AgentController(client)
pipeline_controller = PipelineController(client)

async def create_and_run_pipeline():
    try:
        # Create specialized agents
        data_cleaner = agent_controller.create_agent(
            name="Data Cleaner",
            type="data_processor",
            config={
                "cleansingOptions": {
                    "removeDuplicates": True,
                    "handleMissingValues": "imputation"
                }
            }
        )
        
        data_analyzer = agent_controller.create_agent(
            name="Data Analyzer",
            type="text_analyzer",
            config={
                "analysisType": "financial",
                "metrics": ["growth", "trends", "anomalies"]
            }
        )
        
        # Create a pipeline
        pipeline = pipeline_controller.create_pipeline(
            name="Data Analysis Pipeline",
            description="Analyzes financial data",
            stages=[
                {
                    "name": "Data Cleaning",
                    "agent_id": data_cleaner["id"]
                },
                {
                    "name": "Data Analysis",
                    "agent_id": data_analyzer["id"]
                }
            ]
        )
        
        # Execute the pipeline
        execution = pipeline_controller.execute_pipeline(
            pipeline_id=pipeline["id"],
            input_data={
                "data": "Your raw data here",
                "options": {"thoroughness": "high"}
            }
        )
        
        # Monitor execution progress
        async for update in pipeline_controller.listen_to_execution(execution["id"]):
            print(f"Status: {update['status']}")
            
            if update.get("is_complete", False):
                print(f"Final result: {update['result']}")
                break
                
    except Exception as e:
        print(f"Error: {e}")

# Run the async function
asyncio.run(create_and_run_pipeline())

Error Handling

The SDK includes custom exceptions for different error types:

from zeebee_ai_client import (
    AuthenticationError, 
    RateLimitError, 
    AgentException, 
    PipelineException
)

try:
    response = client.chat(message="Hello")
except AuthenticationError as e:
    print(f"Authentication error: {e}")
except RateLimitError as e:
    print(f"Rate limit exceeded: {e}")
except AgentException as e:
    print(f"Agent error: {e}")
except PipelineException as e:
    print(f"Pipeline error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Example Applications

The SDK includes example applications that demonstrate its capabilities:

  • Multi-Agent Assistant: A complex assistant that uses multiple specialized agents
  • Voice Transcription Service: A service that transcribes speech to text
  • Interactive Voice Chat: A voice-based chat interface

Python Compatibility

The SDK requires Python 3.10 or newer and is fully compatible with:

  • asyncio for asynchronous programming
  • Type hints for static type checking
  • Context managers for resource management

Documentation

For more detailed information, see the following documentation:

Development

To contribute to the SDK development:

  1. Clone the repository
  2. Install dependencies: pip install -e ".[dev]"
  3. Run tests: pytest
  4. Check types: mypy zeebee_ai_client

License

This SDK is licensed under the 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

zeebee_ai_client-0.1.3.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

zeebee_ai_client-0.1.3-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file zeebee_ai_client-0.1.3.tar.gz.

File metadata

  • Download URL: zeebee_ai_client-0.1.3.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for zeebee_ai_client-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9b9a6905743d8d6912df197d294c4aae799f80f26ec0bc8b0c4d88eeddda3664
MD5 73504efc8a873f343f2ae209eccab2c8
BLAKE2b-256 c792f3bdc9b62709eae6b004316418c1416b3f323c824e34499e36cad18b3c72

See more details on using hashes here.

File details

Details for the file zeebee_ai_client-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for zeebee_ai_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30b72a59429ff865a848c9ce629763775b0565a4df32f7915aeca563c88d222e
MD5 f0aa3a48209becbd71bed679ca17879f
BLAKE2b-256 decd9cd663e6b5d6a5380f279ed187e6eeaf618f00d4b2b28f6ed08b8a3b9175

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