A sophisticated Discord bot that leverages large language models (LLMs) for creating immersive, context-aware conversations with long-term memory capabilities.
- Long-term memory - Remembers past conversations using semantic search
- Context awareness - Maintains conversational context across messages
- Freewill mode - Bot can initiate conversations after periods of inactivity
- Multiple LLM support - Compatible with Gemini, OpenAI, Claude, and other providers
- Docker ready - Easy deployment with Docker and docker-compose
- Custom roleplay guidelines - Configurable personality and interaction styles
- Temporal awareness - Acknowledges time gaps between messages
- Rust (latest stable recommended)
- Discord bot token
- API keys for your preferred LLM provider (Gemini, OpenAI, etc.)
- Docker and docker-compose (optional, for containerized deployment)
-
Clone the repository:
git clone https://github.com/yourusername/chatbot.git cd chatbot -
Copy the example config and customize it:
cp config.example.toml config.toml # Edit config.toml with your API keys and preferences -
Build the project:
cargo build --release
This project depends on my dependency rig-dyn for dynamic LLM provider integration with the rig crate. Currently, the following LLM providers are supported:
anthropicazurecoheredeepseekgaladrielgeminigroqhuggingfacehyperbolicmiramoonshotopenaiopenrouterollamaperplexitytogetherxai
cargo run --releasedocker-compose up -dThe bot is configured via the config.toml file. Key configuration sections include:
[config.discord]
token = "YOUR_DISCORD_BOT_TOKEN"[config.llm]
use_tools = true
force_lowercase = true
similarity_threshold = 0.5
[config.llm.completion]
model = "gemini-2.0-flash-thinking-exp-01-21"
provider = "gemini"
api_key = "YOUR_API_KEY"Configure memory storage parameters:
[config.llm.embedding]
model = "text-embedding-004"
provider = "gemini"
api_key = "YOUR_API_KEY"
qdrant_host = "127.0.0.1"
qdrant_port = 6334
qdrant_https = false[config.context.system]
chatbot_name = "your_bot_name"
user_name = "default_user_name"
about = "Description of your bot's personality and background"
max_ltm = 100
age = "19 years old"The bot consists of several key components:
- Discord Integration: Manages Discord events and message handling
- Chat Engine: Core conversational logic
- Memory System: Long-term and short-term memory management
- Uses Qdrant vector database for semantic search
- Stores conversation summaries for future recall
- LLM Client: Interfaces with various LLM providers
/clear- Clear conversation history/config- Update configuration settings/reload- Reload the bot configuration
The bot uses a two-tiered memory system:
- Short-term memory (STM): Recent conversation history kept in active memory
- Long-term memory (LTM): Important information extracted and stored in a vector database for semantic search and recall
When the bot needs to recall information, it:
- Embeds the current query using the embedding model
- Searches the vector database for semantically similar memories
- Incorporates relevant memories into its response context
The bot can initiate conversations after periods of inactivity:
- Configurable minimum and maximum wait times
- Probability increases exponentially with time since last interaction
- Summarizes conversation context before initiating new interactions
This project is licensed under the MIT License - see the LICENSE.txt file for details.
- Built with Rust, Serenity, and Qdrant
- Uses rig for LLM integration