Elie Habib
ac9e3c8af2
refactor(llm): consolidate provider chain to single source of truth (#1640)
* fix(relay): add LLM fallback chain to ais-relay classify
Replace single Groq-only LLM call with provider fallback chain
(Groq → OpenRouter → Ollama) matching seed-insights.mjs pattern.
If Groq fails or is unavailable, classify falls through to the
next configured provider automatically.
* refactor(llm): consolidate provider chain to single source of truth
- Fix OpenRouter model: openrouter/free → google/gemini-2.5-flash in canonical llm.ts
- Migrate 4 intelligence handlers (classify-event, batch-classify, deduct-situation,
get-country-intel-brief) from hardcoded Groq-only to callLlm() with full
ollama → groq → openrouter fallback chain
- Remove duplicate getProviderCredentials from news/v1/_shared.ts, re-export canonical
- Remove orphaned GROQ_API_URL/GROQ_MODEL from intelligence/v1/_shared.ts
- Reorder script provider chains (ais-relay.cjs, seed-insights.mjs) to canonical
ollama → groq → openrouter order
- Net -161 lines: eliminated duplicated provider logic across 9 files
* fix: eliminate double JSON parse in classify-event, throw on runSeed verification failure
* fix(tests): add llm module alias to country-intel-brief test fixture
* fix: preserve generic LLM_API_* fallback, add retry to seed verification
- Add 'generic' provider to callLlm() chain for LLM_API_URL/LLM_API_KEY/LLM_MODEL
(preserves existing OpenAI-compatible endpoint contract)
- Change seed verification to warn-only with 1 retry instead of fatal throw
(write already succeeded, transient read failure shouldn't fail the job)
- Update docs to reflect new provider fallback chain
2026-03-15 11:44:42 +04:00
..
2026-03-15 01:42:04 +04:00
2026-03-15 08:24:09 +04:00
2026-02-28 17:43:56 +04:00
2026-03-14 15:07:30 +04:00
2026-03-14 21:29:21 +04:00
2026-03-15 11:44:42 +04:00
2026-03-14 21:29:21 +04:00
2026-03-15 11:44:42 +04:00
2026-03-14 21:29:21 +04:00
2026-03-12 06:50:30 +04:00
2026-03-05 10:16:43 +04:00
2026-03-14 21:29:21 +04:00
2026-02-26 20:52:44 +04:00
2026-03-14 23:42:30 +04:00
2026-03-01 11:53:20 +04:00
2026-03-01 11:53:20 +04:00
2026-03-07 10:00:03 +04:00
2026-03-14 21:29:21 +04:00
2026-03-01 15:59:53 +04:00
2026-03-14 21:29:21 +04:00
2026-03-01 11:53:20 +04:00
2026-03-15 11:20:51 +04:00
2026-03-08 09:00:45 +04:00
2026-03-15 02:50:13 +04:00
2026-03-11 13:15:21 +04:00
2026-03-01 11:53:20 +04:00
2026-03-15 01:30:54 +04:00
2026-03-15 00:37:31 +04:00
2026-03-14 21:29:21 +04:00
2026-03-05 10:09:27 +04:00
2026-03-08 00:09:24 +04:00
2026-03-15 00:37:31 +04:00
2026-03-14 15:07:30 +04:00
2026-03-08 00:09:24 +04:00
2026-03-14 21:29:21 +04:00
2026-03-04 17:37:15 +04:00
2026-03-04 17:37:15 +04:00
2026-03-15 00:37:31 +04:00
2026-03-15 11:09:34 +04:00
2026-03-07 10:51:45 +04:00
2026-03-15 08:23:59 +04:00
2026-03-15 00:37:31 +04:00
2026-03-08 00:09:24 +04:00
2026-03-15 03:15:30 +04:00
2026-03-15 11:44:42 +04:00
2026-03-15 11:09:34 +04:00
2026-03-14 21:29:21 +04:00
2026-03-08 00:09:24 +04:00
2026-03-14 21:29:21 +04:00
2026-03-15 01:30:54 +04:00
2026-03-15 03:15:30 +04:00
2026-03-10 07:23:07 +04:00
2026-03-14 21:29:21 +04:00
2026-03-15 00:37:31 +04:00
2026-03-15 01:30:54 +04:00
2026-03-08 00:09:24 +04:00
2026-03-07 22:24:58 +04:00
2026-03-15 00:37:31 +04:00
2026-03-07 06:44:01 +04:00
2026-03-15 11:09:34 +04:00
2026-03-14 21:29:21 +04:00
2026-03-15 10:26:08 +04:00
2026-03-14 21:29:21 +04:00
2026-03-07 22:37:36 +04:00
2026-03-14 10:23:20 +04:00
2026-02-19 07:53:15 +04:00
2026-03-14 21:29:21 +04:00
2026-03-04 17:37:15 +04:00
2026-03-15 09:29:50 +04:00