A powerful and flexible Telegram bot that combines the capabilities of advanced language models: OpenAI (GPT-4o), Google (Gemini 2.5, Thinking), Mistral AI, and Cerebras.
The project is built on a modern stack (Python 3.10+, Aiogram-style architecture, MongoDB) and lets you deploy your own AI assistant without strict limitations, with support for vision, document analysis, and long-term memory.
- Multi-model: The model is selected automatically based on the chosen chat mode. Configuration is fully customizable via YAML.
- Ultra-fast responses: Support for the Cerebras provider and Grok for instant answer generation (400+ tokens per second).
- Vision support: Send the bot photos and it will recognize their content (via GPT-4o, Gemini, or Llama 3.2 Vision).
- File handling: Upload documents in PDF, DOCX, TXT, PY, MD, CSV, XLSX, XLS formats (up to 5 MB). The bot reads their content and uses it in the conversation context.
- Thinking Models: Full support for models with a "chain of thought" (Reasoning) — the bot can show its reasoning before the final answer.
- Streaming: Answers are printed in real time, creating a live-conversation effect.
- Long-term memory: The
/remembercommand lets you save facts about yourself (name, tech stack, preferences) that are automatically injected into the context of every request. - Chat modes (Personas): Over 18 built-in roles with unique prompts: 👩🏼💻 IT expert, 🧠 Psychologist, 🇬🇧 Tutor, 🚀 Elon Musk, and more.
- Roleplay: A roleplay mode with customizable scenarios and stories.
- Educational mode: Interactive learning with question generation and answer checking.
- Data analysis: A mode for analyzing data from CSV and Excel files, generating reports and insights.
- Group support: The bot can be added to a group chat — it responds when mentioned or replied to.
- Admin panel: A "whitelist" system (approve/ban) for new users, token statistics, and message broadcasting (
/broadcast). - Improved UX: Visual loading indicators, emojis, and formatting for a better user experience.
/new— Start a new conversation (reset context)./mode— Choose a chat mode (switch persona)./retry— Regenerate the bot's last answer./profile— User profile and personal token usage statistics./remember [text]— Remember a fact. Example:/remember I code in Python, use Python code examples./help— Help.
/start_role [scenario]— Start a roleplay session with a given scenario./end_role— End the current roleplay session./role_history— Show the roleplay history.
/learn [topic]— Start learning a new topic./question— Get a learning question on the current topic./answer [answer]— Submit an answer to the current question./progress— Show learning progress./topics— Show the list of topics to learn.
/users— Show the list of users (pending approval and active)./approve [id|username]— Grant access to a user./ban [id|username]— Block access./broadcast [message]— Send a message to all active users./stats— Overall token usage statistics across all models.
The bot uses a flexible "backends" system configurable in config/models.yml. Supported:
- Unified / Proxy (Main): A universal client for any OpenAI-compatible API. Ideal for connecting via:
- Local proxies (Copilot Proxy, DeepSeek).
- Local LLMs (LM Studio, Ollama, vLLM).
- Third-party aggregators.
- Google Native: Direct support for Gemini 1.5 / 2.5 via the new
google-genaiSDK. Supports Search and native vision. - OpenAI Native: Official API (GPT-3.5, GPT-4o).
- Mistral AI: Native support for Mistral Large and Codestral.
- Cerebras: Inference support on Wafer-Scale Engine chips (Llama 3.3, Qwen).
- Python 3.10+ (or Docker)
- MongoDB (required, for storing history and users)
-
Copy the example files:
cp config/config.example.yml config/config.yml cp config/config.example.env config/config.env
-
Edit
config/config.yml. Fill in only the keys you plan to use:telegram_token: "123456:ABC-..." # API Keys (leave null if unused) openai_api_key: "sk-..." google_api_key: "AIza..." # For Gemini unified_api_key: "sk-..." # For OpenAI-compatible proxies # List of IDs or usernames of admins (for access to admin commands) allowed_telegram_usernames: [123456789, "my_username"]
-
Configure the models in
config/models.yml. You can add your own models by simply specifyingapi_baseandmodel_name.
The project includes a docker-compose.yml that brings up the bot and a MongoDB database.
-
Specify the DB parameters in
config/config.env. -
Start the containers:
docker-compose up --build -d
-
Make sure MongoDB is running and accessible.
-
Install dependencies:
pip install -r requirements.txt
-
Start the bot:
python bot/main.py
If you want to quickly test the bot without external APIs:
- Install Ollama: https://ollama.ai/
- Pull a model:
ollama pull llama3 - Start the server:
ollama serve - Make sure
config/chat_modes.ymluses theollama-llama3model (set by default) - Provide the Telegram bot token in
config/config.ymlorconfig/config.env - Start the bot as described above
bot/handlers/— Command logic (admin,message,user,menu,role_playing,learning).llm/— API clients (openai,gemini,unified).database.py— A wrapper over MongoDB.
config/chat_modes.yml— Prompts for role modes.models.yml— Registry of models and their settings.
locales/— Translation files (RU/EN).docs/guides/EXAMPLES.md— Usage examples and scenarios
The bot now supports a roleplay mode where you can create a scenario and interact with characters in a virtual world. Use the /start_role, /end_role, and /role_history commands to manage sessions.
In learning mode, the bot can generate questions on the topics you study, check your answers, and track progress. Use the /learn, /question, /answer, /progress, and /topics commands.
The bot can analyze data from CSV and Excel files, providing statistics, insights, and recommendations. Just upload a file in "📊 Data Analyst" mode.
- Visual loading indicators with updating text
- Emojis and formatting for better readability
- Improved messages and hints