Commit 5d9280a
committed
fix(worker): unbreak wiki AI with free provider chain
- Fix ReferenceError in /api/chat: openRouterRes was block-scoped and
referenced outside its block, crashing every request with a 500
- Replace single OpenRouter dependency with a free provider chain:
Workers AI (env.AI binding) → Groq → GitHub Models → OpenRouter free
- Add R2 cache for generated guides (30-day TTL) so repeated requests
cost zero neurons / tokens
- Add 30s timeouts to all provider fetches
- Rewrite AI health check to exercise the real generateGuide path
(previously it pinged OpenRouter directly and missed worker bugs)
- Route /api/news/ai through the same chain with proper validation1 parent 3c55f1c commit 5d9280a
2 files changed
Lines changed: 219 additions & 201 deletions
0 commit comments