Add SearXNG web search for current information
- Add searxng.py service for web queries via SearXNG API - Integrate search into ai_chat.py with AI-driven search decisions - AI determines if query needs current info, then searches automatically - Add SEARXNG_URL, SEARXNG_ENABLED, SEARXNG_MAX_RESULTS config options - Update documentation in README.md, CLAUDE.md, and .env.example
This commit is contained in:
10
CLAUDE.md
10
CLAUDE.md
@@ -39,11 +39,21 @@ 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.
|
||||
|
||||
### Web Search
|
||||
The bot can search the web for current information via SearXNG:
|
||||
- `services/searxng.py` provides `SearXNGService` for web queries
|
||||
- `ai_chat.py` uses a two-step approach: first asks AI if search is needed, then provides results as context
|
||||
- Search is triggered automatically when the AI determines the query needs current information
|
||||
- Configured via `SEARXNG_URL`, `SEARXNG_ENABLED`, and `SEARXNG_MAX_RESULTS` env vars
|
||||
|
||||
### Key Design Decisions
|
||||
- `ConversationManager` stores per-user chat history in memory with configurable max length
|
||||
- Long AI responses are split via `split_message()` in `ai_chat.py` to respect Discord's 2000 char limit
|
||||
- The bot responds only to @mentions via `on_message` listener
|
||||
- Web search uses AI to decide when to search, avoiding unnecessary API calls for general knowledge questions
|
||||
|
||||
## 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.
|
||||
|
||||
Optional: `SEARXNG_URL` for web search capability.
|
||||
|
||||
Reference in New Issue
Block a user