Skip to content

Codegass/ChatAnvil

Repository files navigation

ChatAnvil

A flexible and extensible Python library for interacting with multiple AI chat providers. Currently supports OpenAI, Anthropic (Claude), Groq, and Ollama.

Features

  • Unified interface for multiple AI chat providers
  • Easy provider switching with consistent API
  • Built-in retry mechanisms and error handling
  • Configurable logging
  • Environment variable support
  • Type hints throughout

Installation

pip install chatanvil

Quick Start

# After installation via pip
from anvil import Chat  # Simple alias
# or
from chatanvil import Chat  # Full package name

# Initialize with OpenAI
chat = Chat(service_provider='openai')

# Get a response
response = chat.get_response(
    message="What is the capital of France?",
    temperature=0.7
)
print(response)

# Switch to Claude
claude_chat = Chat(
    service_provider='claude',
    system_prompt="You are a helpful assistant that specializes in geography."
)

response = claude_chat.get_response(
    message="What are the top 3 largest cities in Japan?"
)
print(response)

Configuration

Copy .env.example to .env and fill in your API keys:

cp .env.example .env

Or set them programmatically:

chat = Chat(
    service_provider='openai',
    api_key='your-api-key',
    model='gpt-4o'
)

Supported Providers

  • OpenAI (GPT-3.5, GPT-4)
  • Anthropic (Claude)
  • Groq
  • Ollama (local models)

Development

  1. Clone the repository:
git clone [email protected]:Codegass/ChatAnvil.git
cd ChatAnvil
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install in development mode:
pip install -e .
  1. Run examples:
# Examples in the repository use direct imports
python examples/basic_chat.py
python examples/chat_with_parser.py

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages