# Telegram Inference Bot Refactoring This repository contains a refactored version of the Telegram Inference Bot, which now uses a more flexible and maintainable approach for handling different AI providers. ## Changes 1. Introduced an abstract `AIProvider` class and concrete implementations for Anthropic and OpenAI. 2. Refactored the main bot code to use the new AI provider classes. 3. Implemented a factory function `create_ai_provider` for easy provider instantiation. 4. Updated command handlers to work with the new AI provider system. ## How to Use 1. Set up your environment variables in a `.env` file: ``` TELEGRAM_BOT_TOKEN=your_telegram_bot_token ANTHROPIC_API_KEY=your_anthropic_api_key OPENAI_API_KEY=your_openai_api_key ``` 2. Install the required dependencies: ``` pip install -r requirements.txt ``` 3. Run the bot: ``` python telegram_inference_bot.py ``` ## Commands - `/start`: Start the bot and receive a welcome message. - `/clear`: Clear the conversation history and any stored images. - `/switch`: Switch between smart and regular models (OpenAI only). - `/toggle`: Toggle between Anthropic and OpenAI providers. - `/status`: Display the current AI provider and model being used. ## Extending the Bot To add a new AI provider: 1. Create a new class in `ai_providers.py` that inherits from `AIProvider`. 2. Implement the required methods: `get_chat_response`, `format_messages`, `format_tool_calls`, etc. 3. Update the `create_ai_provider` function to include the new provider. ## Future Improvements - Implement more robust error handling and logging. - Add unit tests for the AI provider classes and main bot functionality. - Extend the README with more detailed usage instructions and examples.