mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 13:06:43 +02:00
feat(llm-aliases): M5 — migrate consumers to MANA_LLM aliases
Final milestone of docs/plans/llm-fallback-aliases.md. Every backend
caller now requests models via the `mana/<class>` alias system instead
of hardcoded `ollama/...` strings. mana-llm resolves aliases through
`services/mana-llm/aliases.yaml` with health-aware fallback (M3) and
emits resolved-model + fallback metrics (M4).
SSOT moved to `packages/shared-ai/src/llm-aliases.ts` so apps/api,
apps/mana/apps/web, and services/mana-ai all import the same
`MANA_LLM` constant via the existing `@mana/shared-ai` workspace
dependency. Three additional sites (memoro-server, mana-events,
mana-research) inline the alias string with a SSOT comment because
they don't pull @mana/shared-ai today.
Migrated 14 sites across 10 files:
- apps/api: writing(LONG_FORM), comic(STRUCTURED), context(FAST_TEXT),
food(VISION), plants(VISION), research orchestrator (3 tiers
collapsed to STRUCTURED+FAST_TEXT/LONG_FORM)
- apps/mana/apps/web: voice/parse-task + parse-habit (STRUCTURED)
- services/mana-ai: planner llm-client + tick.ts (REASONING)
- services/mana-events: website-extractor (STRUCTURED, inlined)
- services/mana-research: mana-llm client (FAST_TEXT, inlined)
- apps/memoro/apps/server: ai.ts (FAST_TEXT, inlined)
Legacy env-vars removed: WRITING_MODEL, COMIC_STORYBOARD_MODEL,
VISION_MODEL, MANA_LLM_DEFAULT_MODEL. The chain in aliases.yaml is
now the single tuning surface; SIGHUP reloads it without redeploys.
New `scripts/validate-llm-strings.mjs` regex-scans 2538 files for
hardcoded `<provider>/<model>` strings and fails the build if any
land outside the SSOT or the explicitly-allowed paths (image-gen
modules, model-inspector code, this validator itself, the registry).
Wired into `validate:all` next to the i18n + theme validators.
Verified: `pnpm validate:llm-strings` clean, `pnpm --filter @mana/api
type-check` clean, `pnpm --filter @mana/ai-service type-check`
clean. Web type-check has 2 pre-existing errors in
SettingsSidebar.svelte (i18n MessageFormatter type drift, last
touched in 988c17a67 — unrelated to this work).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8a49e3ffd5
commit
fea3adf5fe
19 changed files with 299 additions and 50 deletions
|
|
@ -18,9 +18,15 @@
|
|||
import { eq } from 'drizzle-orm';
|
||||
import { db, researchResults, sources, type ResearchDepth } from './schema';
|
||||
import { llmJson, llmStream, LlmError } from '../../lib/llm';
|
||||
import { MANA_LLM } from '@mana/shared-ai';
|
||||
import { webSearch, bulkExtract, type SearchHit, SearchError } from '../../lib/search';
|
||||
|
||||
// ─── Depth configuration ────────────────────────────────────
|
||||
//
|
||||
// `planModel` is always `STRUCTURED` (the planner emits JSON).
|
||||
// `synthModel` varies by depth: `quick` runs through `FAST_TEXT` for a
|
||||
// terse summary, `standard`/`deep` use `LONG_FORM` for richer prose.
|
||||
// Concrete provider/model selection lives in services/mana-llm/aliases.yaml.
|
||||
|
||||
interface DepthConfig {
|
||||
subQueryCount: number;
|
||||
|
|
@ -39,8 +45,8 @@ const DEPTH_CONFIG: Record<ResearchDepth, DepthConfig> = {
|
|||
maxSources: 5,
|
||||
extract: false,
|
||||
categories: ['general'],
|
||||
planModel: 'ollama/gemma3:4b',
|
||||
synthModel: 'ollama/gemma3:4b',
|
||||
planModel: MANA_LLM.STRUCTURED,
|
||||
synthModel: MANA_LLM.FAST_TEXT,
|
||||
},
|
||||
standard: {
|
||||
subQueryCount: 3,
|
||||
|
|
@ -48,8 +54,8 @@ const DEPTH_CONFIG: Record<ResearchDepth, DepthConfig> = {
|
|||
maxSources: 15,
|
||||
extract: true,
|
||||
categories: ['general', 'news'],
|
||||
planModel: 'ollama/gemma3:4b',
|
||||
synthModel: 'ollama/gemma3:12b',
|
||||
planModel: MANA_LLM.STRUCTURED,
|
||||
synthModel: MANA_LLM.LONG_FORM,
|
||||
},
|
||||
deep: {
|
||||
subQueryCount: 6,
|
||||
|
|
@ -57,8 +63,8 @@ const DEPTH_CONFIG: Record<ResearchDepth, DepthConfig> = {
|
|||
maxSources: 30,
|
||||
extract: true,
|
||||
categories: ['general', 'news', 'science', 'it'],
|
||||
planModel: 'ollama/gemma3:12b',
|
||||
synthModel: 'ollama/gemma3:12b',
|
||||
planModel: MANA_LLM.STRUCTURED,
|
||||
synthModel: MANA_LLM.LONG_FORM,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue