How yincongcyincong/telegram-deepseek-bot works
Project type and purpose
• This is a backend-only, modular Telegram Bot written in Go. Its purpose is to mediate between Telegram users and various AI/LLM backends (DeepSeek, OpenAI, Gemini, etc.), offering features such as streaming chat, image/audio/video processing, RAG (Retrieval-Augmented Generation), function calls, token tracking, and admin commands.
File structure
• Top-level entry point:
• main.go – starts the bot, initializes modules, HTTP servers (metrics, pprof), and launches the Telegram long-polling or webhook loop in robot/
• Configuration:
• conf/ – Go structs for all env-var and JSON configs (audio, video, photo, RAG, general) + i18n resources
• param/ – command-line flags
• Core modules:
• robot/ – Telegram update handling, dispatching commands (/chat, /mode, /task, etc.)
• llm/ – Abstraction (llm.go, task.go) plus concrete adapters (deepseek, openai, gemini, huoshan, ollama)
• rag/ – document retrieval & context assembly using data/knowledge
• db/ – persistence layer for users, message history, token usage (supports sqlite3/mysql)
• utils/ – shared helpers (audio conversions, user ID utilities)
• Observability:
• logger/ – structured logging
• metrics/ – Prometheus exporter + pprof
• Static assets & docs:
• static/doc/ – user-facing markdown
• data/knowledge/ – text corpora for RAG
• Deployment & build:
• Dockerfile, Makefile, release.sh, ci.yml
• .github/ISSUE_TEMPLATE, workflows
README for additional insights
• Emphasizes easy deployment, environment-driven configuration, Docker support, and the variety of AI backends.
• Lists all bot commands and external dependencies (Telegram API, DeepSeek API, other LLM services, Volcengine for multimodal, DB drivers).
Elements
• User → Telegram API → Bot Core → LLM Adapter → External LLM → Bot Core → Telegram API → User
• Bot Core → DB (write/read)
• Bot Core → RAG (read knowledge)
• Bot Core → Metrics endpoint
• Blue for internal modules
• Green for external services
• Orange for data stores
• Gray for static assets