A Telegram bot that integrates with various LLM models to provide AI-powered chat capabilities.
- Supports multiple LLM models (Claude, Gemini, etc.)
- Custom system prompts
- Message history tracking
- Support for text, photo, and audio attachments
- User authentication via admin list
- Clone the repository:
git clone https://github.com/yourusername/telegram-llm.git
cd telegram-llm- Install dependencies using Poetry:
poetry install- Set up environment variables in a
.envfile:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
ADMINS=["your_telegram_user_id"]
LOGFIRE_API_KEY=your_logfire_api_key
FIRECRAWL_API_KEY=your_firecrawl_api_key
BRAVE_SEARCH_API_KEY=your_brave_search_api_key
Run the bot:
poetry run service-runOr using Docker:
docker-compose up -d/help- Show available commands/model- Show current model/set_model <model_id>- Set the model to use/models- List available models/system_prompt- Show current system prompt/set_system_prompt <prompt>- Set system prompt/attachment_types- Show supported attachment types/_user_id- Get your user ID/_chat_id- Get the current chat ID (admin only)/private- Process a message privately (admin only)
@think- Make the model show its thinking and reasoning process before answering@web your search query- Search the web for information related to your query@https://example.comor@example.com/page- Scrape a webpage and include its content in the LLM context
The project includes a comprehensive test suite. To run the tests:
# Run tests using make
make test
# Run tests with coverage
make test-covAlternatively, you can run tests directly with pytest:
poetry run pytest
poetry run pytest --cov=.See the tests/README.md file for more details on testing.
This project uses Poetry for dependency management and pytest for testing.
To add a new dependency:
poetry add package-nameTo add a development dependency:
poetry add --group dev package-name