Skip to content

Polymind is a powerful multi-modal Telegram bot built with Gemini, DeepSeek, OpenRouter, and over 50 cutting-edge AI models. It offers seamless conversational intelligence, Mermaid diagram rendering, PDF/DOCX analysis, image generation, and collaborative toolsโ€”all in a single bot interface.

License

Notifications You must be signed in to change notification settings

Remy2404/Polymind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Polymind Bot

A powerful, multi-modal Telegram bot leveraging cutting-edge AI technologies including Google's Gemini 2.0 Flash, DeepSeek, OpenRouter, and 50+ AI models for comprehensive conversational assistance, media processing, and collaborative features.

Telegram Gemini Bot Project Report Mermaid Diagram Example

๐Ÿ“‘ Table of Contents

โœจ Key Features

๐Ÿง  AI & Language Models

  • 54+ AI Models: Hierarchical model selection across Gemini, DeepSeek, OpenRouter (Llama, Claude, GPT, Qwen, Mistral, etc.)
  • Intelligent Model Switching: Context-aware automatic model selection based on task type
  • Multi-Modal AI: Combined text, image, document, and voice processing in single requests
  • Conversation Memory: Persistent context across sessions with model-specific history
  • Smart Fallback System: Automatic failover between AI providers for reliability

๐ŸŽจ Visual & Media Processing

  • Mermaid Diagram Rendering: Automatic detection and conversion of text-based diagrams to images
  • Image Generation: Advanced image creation via Together AI and Imagen3 with custom prompts
  • Video Generation: Text-to-video capabilities for creative content
  • Image Analysis: Intelligent visual content analysis and description
  • Document Processing: PDF, DOCX analysis with semantic search and content extraction

๐ŸŽ™๏ธ Voice & Speech

  • Advanced Voice Recognition: engines ( Faster-Whisper)
  • Voice Activity Detection: Automatic silence filtering and speech enhancement
  • Confidence Scoring: Reliability metrics for transcription accuracy

๐Ÿ‘ฅ Group Chat & Collaboration

  • Group Intelligence: Shared memory and context across group conversations
  • Collaborative Workspaces: Team knowledge management and note sharing
  • Discussion Threading: Structured conversations with topic tracking
  • Group Analytics: Usage statistics and conversation insights
  • Role-Based Access: Customizable permissions for different group members
  • Real-Time Collaboration: Live typing indicators and activity streams

๐Ÿ”ง Technical Excellence

  • Production-Ready: Optimized for high-traffic deployments with webhook support
  • Rate Limiting: Intelligent request management and flood protection
  • Advanced Formatting: Rich markdown with tables, spoilers, LaTeX, and code highlighting
  • Smart Message Chunking: Automatic splitting of long responses within Telegram limits
  • Error Recovery: Comprehensive error handling with graceful degradation
  • Performance Monitoring: Built-in logging, analytics, and debugging tools

๐Ÿ”ง Prerequisites

  • Python 3.11+ with asyncio support
  • Node.js 20.x+ for Mermaid diagram rendering
  • MongoDB instance (local or MongoDB Atlas)
  • Required APIs:
    • Telegram Bot Token (via @BotFather)
    • Google Gemini API key
    • OpenRouter API key (optional, for 50+ additional models)
    • Together AI API key (for image/video generation)
    • HuggingFace API keys (for specialized models)
  • System Dependencies:
    • FFmpeg (for audio/video processing)
    • @mermaid-js/mermaid-cli (auto-installed in Docker)

๐Ÿš€ Installation

๐Ÿ› ๏ธ Development Setup

# Clone the repository
git clone https://github.com/Remy2404/Telegram-Gemini-Bot.git
cd Telegram-Gemini-Bot

# Create and activate Python virtual environment
python -m venv venv
source venv/bin/activate     # macOS/Linux  
venv\Scripts\activate        # Windows

# Install Python dependencies
uv sync
# or: pip install -r requirements.txt

# Install Node.js dependencies for Mermaid rendering
npm install -g @mermaid-js/mermaid-cli

# Verify installation
mmdc --version  # Should show Mermaid CLI version

โšก Quick Start

# Start development server with hot reload
uv run uvicorn app:app --host 0.0.0.0 --port 8000 --reload

# Or start with production optimizations
uv run python app.py

โš™๏ธ Configuration

Create a comprehensive .env file in the project root:

# ๐Ÿค– Core Bot Configuration
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
MONGODB_URI=mongodb://localhost:27017  # or MongoDB Atlas URI
# ๐Ÿง  AI Model APIs
GEMINI_API_KEY=your_gemini_api_key
OPENROUTER_API_KEY=your_openrouter_api_key  # Access to 50+ models
DEEPSEEK_API_KEY=your_deepseek_api_key      # Optional, for DeepSeek models
TOGETHER_API_KEY=your_together_api_key
WEBHOOK_URL=https://your-domain.com
PORT=8000

๐Ÿ’ก Usage

๐Ÿš€ Starting the Bot

Local Development

# Start with hot reload for development
uv run uvicorn app:app --host 0.0.0.0 --port 8000 --reload

# Start with production optimizations
uv run python app.py

Production Deployment

# Using Gunicorn with multiple workers
gunicorn app:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

# Using Docker (recommended)
docker-compose up -d

๐ŸŒŸ Key Features in Action

๐ŸŽจ Mermaid Diagram Generation

Simply ask the bot to create diagrams:

๐Ÿ‘ค "Create a flowchart showing the user registration process"
๐Ÿค– [Automatically renders a beautiful diagram as an image]
  • Supports all Mermaid diagram types: flowcharts, sequence, class, ER, Gantt, etc.
  • Intelligent syntax cleaning and error handling
  • Fallback to code display if rendering fails

๐Ÿง  Multi-Model AI Conversations

๐Ÿ‘ค /switchmodel
๐Ÿค– Shows hierarchical model selection:
    ๐Ÿ“‚ ๐Ÿง  Gemini Models (3)
    ๐Ÿ“‚ ๐Ÿ”ฎ DeepSeek Models (5)  
    ๐Ÿ“‚ ๐Ÿฆ™ Meta Llama Models (8)
    ๐Ÿ“‚ ๐ŸŒŸ Qwen Models (6)
    ๐Ÿ“‚ ...and 40+ more models

๐Ÿข Group Collaboration

Add the bot to any group chat:

/groupsettings - Configure collaboration features
/groupcontext - View shared group memory
/groupthreads - Manage discussion topics
/groupstats - Group usage analytics

๐Ÿ“„ Document Processing

Upload any PDF or DOCX file:

  • Intelligent content extraction and analysis
  • Semantic search within documents
  • AI-powered summarization and Q&A
  • Export conversations to formatted documents

๐ŸŽฏ Specialized Use Cases

For Developers

๐Ÿ‘ค "Explain this Python code and suggest improvements"
๐Ÿค– [Provides detailed code analysis with suggestions]

๐Ÿ‘ค "Create a class diagram for a user authentication system"  
๐Ÿค– [Generates professional UML diagram]

For Content Creators

๐Ÿ‘ค /genimg "A futuristic city at sunset with flying cars"
๐Ÿค– [Creates high-quality AI-generated image]

#### For Teams and Groups
```bash
๐Ÿ‘ค "Summarize our last discussion about the project timeline"
๐Ÿค– [Provides intelligent summary of group conversations]

๐Ÿ‘ค /groupthreads
๐Ÿค– [Shows organized discussion topics and threads]

For Document Export & Creation

๐Ÿ‘ค /exportdoc
๐Ÿค– Choose what to export:
    ๐Ÿ“œ Export Conversation
    โœ๏ธ Provide Custom Text
    
๐Ÿ‘ค [Send custom text like "# My Report\n\nThis is my **important** document"]
๐Ÿค– [Converts to professional PDF/DOCX with proper formatting]

๐Ÿ‘ค /gendoc
๐Ÿค– [AI generates complete documents based on your requirements]

๐Ÿ“‹ Commands

Command Description Usage Example
/start Initialize the bot and get welcome /start
/help List all available commands /help
/genimg Generate an image from text prompt /genimg sunset over mountains
/reset Clear conversation history /reset
/switchmodel Hierarchical AI model selection /switchmodel
/listmodels List all available AI models /listmodels
/currentmodel Show current AI model /currentmodel
/exportdoc Export chat to PDF/DOCX /exportdoc
/gendoc Generate AI-powered documents /gendoc

๐Ÿ‘ฅ Group Chat Commands

Command Description Usage Example
/groupstats Show group usage statistics /groupstats
/groupsettings Configure group settings /groupsettings
/groupcontext View shared group memory /groupcontext
/groupthreads Manage discussion topics /groupthreads
/cleanthreads Clean up inactive conversation threads /cleanthreads

๐ŸŒŸ Special Features

  • ๐ŸŽจ Automatic Mermaid Rendering: Just ask for diagrams and they'll be rendered as images
  • ๐ŸŽ™๏ธ Voice Messages: Send voice notes for transcription and response
  • ๐Ÿ“ File Upload: Drag and drop PDFs, images, videos for AI analysis
  • ๐Ÿ’ฌ Group Chat: Add bot to groups with @mention support
  • ๐Ÿ”„ Model Memory: Each AI model maintains separate conversation history
  • ๐Ÿ“„ Rich Export: Export conversations with formatting, images, and metadata

Project Structure

src/
โ”œโ”€โ”€ database/        # Database schemas and connections
โ”œโ”€โ”€ handlers/        # Message & callback handlers
โ”œโ”€โ”€ services/        # AI model wrappers & business logic
โ”œโ”€โ”€ utils/           # Logging, config, utilities
โ””โ”€โ”€ main.py          # Entry point
app.py               # FastAPI server setup

Docker Deployment

Build and run:

docker build -t telegram-gemini-bot .
docker run -d -p 8000:8000 --env-file .env telegram-gemini-bot

With Docker Compose:

docker-compose up -d

Contributing

Contributions are welcome. Fork the repo, create a feature branch, commit your changes, and open a pull request.

License

This project is licensed under the MIT License. See LICENSE for details.

About

Polymind is a powerful multi-modal Telegram bot built with Gemini, DeepSeek, OpenRouter, and over 50 cutting-edge AI models. It offers seamless conversational intelligence, Mermaid diagram rendering, PDF/DOCX analysis, image generation, and collaborative toolsโ€”all in a single bot interface.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages