Replace custom provider abstraction with litellm

Drops the src/providers/ package (base class, AnthropicProvider,
OpenAIProvider, factory) in favour of a single src/llm.py that calls
litellm.completion() directly. litellm handles provider routing,
authentication, and SDK differences for 100+ providers without any
code we need to maintain.

Changes:
- Delete src/providers/ entirely
- Add src/llm.py — one complete() function wrapping litellm
- src/agent/core.py: EmailAgent takes model: str instead of LLMProvider
- src/config.py: ai_provider + api key fields → single ai_model string
  in litellm format (e.g. "anthropic/claude-opus-4-6")
- main.py: remove provider factory wiring; pass config.ai_model to agent
- .env.example: simplify AI section, show litellm model string examples
- pyproject.toml: replace anthropic + openai deps with litellm>=1.0.0
- uv.lock: regenerated

https://claude.ai/code/session_01HaUFs7SaLD5SoiuGCY27Tw
This commit is contained in:
Claude
2026-02-21 07:35:37 +00:00
parent 1ba42f9497
commit 431847a8b7
11 changed files with 972 additions and 226 deletions
+9 -9
View File
@@ -6,21 +6,21 @@
# ---------------------------------------------------------------
# ---------------------------------------------------------------
# AI Provider
# AI Model (via litellm — supports any provider)
# ---------------------------------------------------------------
# Choose "anthropic" (Claude) or "openai" (GPT).
AI_PROVIDER=anthropic
# Optional: override the default model for the chosen provider.
# Anthropic default: claude-opus-4-6
# OpenAI default: gpt-4o
# AI_MODEL=
# Use litellm model strings: "<provider>/<model-name>"
# Examples:
# anthropic/claude-opus-4-6 (default)
# openai/gpt-4o
# gemini/gemini-2.0-flash
AI_MODEL=anthropic/claude-opus-4-6
# ---------------------------------------------------------------
# API Keys — set the one matching your AI_PROVIDER
# API Keys — set the one matching your chosen model's provider
# ---------------------------------------------------------------
ANTHROPIC_API_KEY=sk-ant-...
# OPENAI_API_KEY=sk-...
# GEMINI_API_KEY=...
# ---------------------------------------------------------------
# Email — IMAP (receiving parent messages)