Skip to main content

A modular AI API/chat manager supporting multiple backends

Project description

AI Chat Manager

A comprehensive Python package for managing AI-powered chat conversations with support for multiple backends, enhanced features, and extensible architecture.

Features

  • Multiple AI Backends: Support for OpenAI, Venice AI, HuggingFace, ElevenLabs, and more
  • Streaming Support: Real-time streaming responses
  • Function Calling: Advanced function calling capabilities
  • Vision Support: Image understanding with compatible models
  • Audio Generation: Text-to-speech with ElevenLabs
  • Conversation Management: Persistent conversation history with smart context handling
  • Rate Limiting: Built-in rate limiting and retry logic
  • Error Handling: Comprehensive error handling and conversion
  • CLI Interface: Easy-to-use command line interface
  • Extensible: Plugin architecture for adding new backends

Installation

pip install cybercore-ai-chat-manager

Quick Start

from ai_chat_manager import ChatManager, Config
from ai_chat_manager.backends import OpenAIBackend

# Create configuration
config = Config()
config.add_backend("openai", {
    "api_key": "your-openai-api-key",
    "model": "gpt-3.5-turbo"
})

# Create chat manager
manager = ChatManager(config)

# Start a conversation
response = await manager.chat("Hello, how are you?", backend="openai")
print(response.content)

Project Structure

ai_chat_manager/
├── __init__.py                  # Main package init
├── core/
│   ├── __init__.py
│   ├── types.py                 # Core type definitions
│   ├── exceptions.py            # Exception definitions
│   ├── config.py                # Configuration management
│   ├── bot.py                   # Bot implementation
│   └── manager.py               # Chat manager
├── backends/
│   ├── __init__.py              # Backend registry
│   ├── base.py                  # Base backend class
│   ├── openai_backend.py
│   ├── venice_backend.py
│   ├── huggingface_backend.py
│   └── elevenlabs_backend.py
├── cli/
│   ├── __init__.py
│   ├── main.py                  # Main CLI
│   └── wrapper.py               # CLI wrapper
├── utils/
│   ├── __init__.py
│   └── helpers.py               # Utility functions
└── examples/
    ├── basic.py
    └── advanced.py

Backend Support

OpenAI

  • GPT-3.5, GPT-4, and all variants
  • Function calling
  • Vision support (GPT-4V)
  • Streaming responses

Venice AI

  • Privacy-focused AI platform
  • Anonymous and censorship-resistant
  • OpenAI-compatible API
  • Enhanced privacy controls

HuggingFace

  • Inference API support
  • Local model support
  • Wide variety of open-source models
  • Custom model hosting

ElevenLabs

  • High-quality text-to-speech
  • Voice cloning
  • Multiple voice models
  • Streaming audio generation

Configuration

The package uses a comprehensive configuration system:

from ai_chat_manager.core.config import Config, BackendConfig

config = Config()

# Add OpenAI backend
openai_config = BackendConfig(
    name="openai",
    backend_type="openai",
    api_key="your-api-key",
    model="gpt-4",
    max_tokens=2000,
    temperature=0.7
)
config.add_backend_config(openai_config)

Error Handling

The package provides comprehensive error handling:

from ai_chat_manager.core.exceptions import (
    BackendError, AuthenticationError, RateLimitError,
    ModelNotFoundError, QuotaExceededError
)

try:
    response = await manager.chat("Hello")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit exceeded")
except BackendError as e:
    print(f"Backend error: {e}")

CLI Usage

# Initialize configuration
ai-chat-manager init

# Basic commands (all three work identically)
ai-chat-manager --help
acm --help
chat-manager --help

# Backend management
ai-chat-manager backend add openai
ai-chat-manager backend list

# Bot management
ai-chat-manager bot create assistant
ai-chat-manager bot list

# Start chatting
ai-chat-manager chat assistant

# System status
ai-chat-manager status
ai-chat-manager doctor

Examples

See the examples/ directory for more detailed usage examples:

  • basic.py: Simple chat interactions
  • advanced.py: Advanced features like function calling, streaming, and conversation management

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

Version 1.0.0

  • Initial release
  • Support for OpenAI, Venice AI, HuggingFace, and ElevenLabs
  • Comprehensive configuration system
  • CLI interface with three command aliases: ai-chat-manager, acm, chat-manager
  • Error handling and retry logic
  • Conversation management
  • Streaming support
  • Function calling

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

cybercore_ai_chat_manager-1.0.0.tar.gz (93.5 kB view details)

Uploaded Source

Built Distribution

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

cybercore_ai_chat_manager-1.0.0-py3-none-any.whl (105.5 kB view details)

Uploaded Python 3

File details

Details for the file cybercore_ai_chat_manager-1.0.0.tar.gz.

File metadata

File hashes

Hashes for cybercore_ai_chat_manager-1.0.0.tar.gz
Algorithm Hash digest
SHA256 887ef0787832b835a7247ce1a006889e7be45a6b4e15372c37683c92090d01b6
MD5 e8c6466d84aed0a8ab32d45ae7befc36
BLAKE2b-256 24bc436eb11732095cfcbf4dc76ed27b4dd2b742a6b7f5d41ba8a5ffc2876107

See more details on using hashes here.

File details

Details for the file cybercore_ai_chat_manager-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cybercore_ai_chat_manager-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9e0b1774a4ac2540f525fedbe6a048c669ca03177916e153e0c801915d338b4
MD5 fbf1db8f15284a61edcb955c2f44a9cd
BLAKE2b-256 45d1cdba316911821fcd631ec4d6c129b4f1c6c742375a4951f0c2917cc84225

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