- Add gemini.py provider using google-genai SDK - Update config.py with gemini provider and GEMINI_API_KEY - Update ai_service.py factory to support gemini - Add google-genai to requirements.txt - Update .env.example, README.md, and CLAUDE.md documentation
1.8 KiB
1.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build & Run Commands
# Install dependencies
pip install -r requirements.txt
# Run the bot (requires .env with DISCORD_TOKEN and AI provider key)
python -m daemon_boyfriend
# Run with Docker
docker-compose up -d
# Syntax check all Python files
python -m py_compile src/daemon_boyfriend/**/*.py
Architecture
This is a Discord bot that responds to @mentions with AI-generated responses (multi-provider support).
Provider Pattern
The AI system uses a provider abstraction pattern:
services/providers/base.pydefinesAIProviderabstract class withgenerate()methodservices/providers/openai.py,openrouter.py,anthropic.py,gemini.pyimplement the interfaceservices/ai_service.pyis the factory that creates the correct provider based onAI_PROVIDERenv var- OpenRouter uses OpenAI's client with a different base URL
- Gemini uses the
google-genaiSDK
Cog System
Discord functionality is in cogs/:
ai_chat.py-@mentionhandler (responds when bot is mentioned)
Cogs are auto-loaded by bot.py from the cogs/ directory.
Configuration
All config flows through config.py using pydantic-settings. The settings singleton is created at module load, so env vars must be set before importing.
Key Design Decisions
ConversationManagerstores per-user chat history in memory with configurable max length- Long AI responses are split via
split_message()inai_chat.pyto respect Discord's 2000 char limit - The bot responds only to @mentions via
on_messagelistener
Environment Variables
Required: DISCORD_TOKEN, plus one of OPENAI_API_KEY, OPENROUTER_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY depending on AI_PROVIDER setting.