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.1.tar.gz (12.8 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.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zeebee_ai_client-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 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.1.tar.gz
Algorithm Hash digest
SHA256 77695b3d65486fbbe4b32e8882736219362d1b34266acd7b5bf05997e5d544a8
MD5 9cbe0162f8ba516356c754676ace340c
BLAKE2b-256 089e72e1b93f763f01334c1c77ab1628bb0af5d9dbd8734577401ef3cef014ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zeebee_ai_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5eebef50e4430cbb21026cb84cf229fe734bd366a68df5b6a1e82d42022950e4
MD5 b9fd24bcf778e3d7f9426dffc14c2e3e
BLAKE2b-256 615139d002a731fe1cdb6da93296294ab67562d537d075d79351df9681bde208

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