gittech. site

for different kinds of informations and explorations.

Ichigo Bot โ€“ Telegram Chat Bot for Aggregating LLMs and API Providers

Published at
Feb 3, 2025

๐Ÿ“ Ichigo Bot

Build and Release GitHub Release (Latest) Docker Pulls

English | ็ฎ€ไฝ“ไธญๆ–‡

A delightful Telegram AI chat bot powered for aggregating models and API providers. ๐ŸŒŸ

If you're not sure where to start, check out cheahjs/free-llm-api-resources for a wealth of LLM API resources, and visit Telegram Bots for guidance on creating your own bot.

โœจ Features

  • ๐Ÿ›ก๏ธ Production-ready with super-robust error handling
  • ๐Ÿ’ซ Magical streaming chat responses
  • ๐Ÿ–ผ๏ธ Supports image in chat for multimodal LLM
  • ๐Ÿค– Compatible with almost any API providers
  • ๐ŸŽฎ Mix and match your favorite models and providers
  • ๐Ÿ” Keeps your chats and models safe with user access control
  • ๐Ÿ“ Beautiful Telegram Markdown V2 formatting
  • ๐ŸŽฏ Smart system prompts for better conversations
  • ๐Ÿชถ Light as a feather on your server

๐Ÿณ Quick Docker Deployment (beta)

  1. Create a local data directory. Assume the data directory path is /path/to/data:
mkdir -p /path/to/data
  1. Create a configuration file config.toml in /path/to/data. The configuration file's name must be config.toml, not any other name. Please refer to asset/example_config.toml for an example configuration.

  2. Run the Docker container (replace /path/to/data with the real data directory path):

sudo docker run -d \
  --name ichigod \
  -v /path/to/data:/etc/ichigod \
  -e ICHIGOD_DATA_DIR=/etc/ichigod \
  --restart unless-stopped \
  dockerrewired/ichigo-bot:latest

๐ŸŽฎ Commands

  • /chat - Chat with Ichigo (Can be omitted in private messages)
  • /new - Start a new conversation
  • /set - Switch to a different model
  • /list - Show available models
  • /undo - Remove last conversation round
  • /stop - Stop the current response
  • /set_temp - Set text completion temperature
  • /help - Get the list of commands

Admin Commands:

  • /get_config - View current configuration
  • /set_config - Update configuration and shutdown
  • /clear - Clear data
  • /tidy - Auto delete sessions and chat records whose IDs no longer exist

๐Ÿš€ Quick Start

Prerequisites

  • Go 1.21 or later
  • Make
  • Python 3 with telegramify-markdown package installed
  • A Telegram bot token (obtained via @BotFather)
  • OpenAI API key or other compatible API provider credentials
  • Tip: User IDs and group chat IDs can be retrieved via @RawDataBot

Build

make build

That's it! Assume the built binary is /project_root/target/ichigod.

Deploy (Linux with systemd)

  1. Move the built binary to /usr/bin and grant necessary permissions:
# Example commands
sudo chmod a+rx /project_root/target/ichigod
sudo cp -f /project_root/target/ichigod /usr/bin/ichigod
  1. Create a data directory at /etc/ichigod:
# Example commands
sudo mkdir -p /etc/ichigod
  1. Create a configuration file config.toml in /etc/ichigod. The configuration file's name must be config.toml, not any other name. Please refer to asset/example_config.toml for an example configuration.

  2. Create a Python virtual environment with telegramify-markdown installed in /etc/ichigod/venv:

# Example commands
cd /etc/ichigod
python3 -m venv venv
source venv/bin/activate
pip install telegramify-markdown
  1. Create a systemd service unit at /etc/systemd/system/ichigod.service:
# Example service unit
[Unit]
Description=Ichigo Telegram Bot Service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/bin/ichigod
Restart=always
RestartSec=5
Environment="ICHIGOD_DATA_DIR=/etc/ichigod"
Environment="PATH=/etc/ichigod/venv/bin"

[Install]
WantedBy=multi-user.target
  1. Enable and start the service:
# Example commands
sudo systemctl daemon-reload
sudo systemctl enable ichigod
sudo systemctl start ichigod
  1. Check the service log:
# Example commands
sudo journalctl -u ichigod.service | tail -8

# Example outputs
# <redacted> systemd[1]: Started ichigod.service - Ichigo Telegram Bot Service.
# <redacted> ichigod[202711]: <redacted> INFO starting ichigod
# <redacted> ichigod[202711]: <redacted> INFO initializing bot service
# <redacted> ichigod[202711]: <redacted> INFO bot API client initialized username=<redacted> debug_mode=false

๐Ÿ› ๏ธ Development

Development commands:

make dev        # Run in development mode
make debug      # Run with debugger
make build      # Build for current platform
make build_x64  # Build for Linux x64

โš™๏ธ Configuration

The bot looks for config.toml in these locations:

  1. $ICHIGOD_DATA_DIR
  2. /etc/ichigod/
  3. $HOME/.config/ichigod/
  4. Current directory