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.4.tar.gz (23.7 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.4-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zeebee_ai_client-0.1.4.tar.gz
  • Upload date:
  • Size: 23.7 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.4.tar.gz
Algorithm Hash digest
SHA256 c53783fde9e7b2e99af5cc1fe0b13892de2aae58028bd6da8a44982d5b6a1a62
MD5 ef8a163132914c6695f7cd7c02044612
BLAKE2b-256 1a75fb02c1a475994a66dd78d39e019ce09aa3b6b419a2e774ae76bd1d7d7276

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zeebee_ai_client-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 900f566dd211191886a89874d1f45dd1fe738a430c851a606e0de1880dca6b6b
MD5 6e17842ee58d7b18c64d16e047629b98
BLAKE2b-256 f33eab3ce9e327adb7f502b7b2c45e1ffd53a6c6a483b388cb448e398d00765d

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