mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-20 19:26:41 +02:00
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>
25 lines
953 B
TypeScript
25 lines
953 B
TypeScript
/**
|
|
* Mana LLM model aliases — single source of truth for which class of
|
|
* model each backend feature uses.
|
|
*
|
|
* Resolved server-side by mana-llm via `services/mana-llm/aliases.yaml`;
|
|
* consumers don't see the underlying provider/model unless they really
|
|
* need to (mainly for token-cost accounting via the
|
|
* `X-Mana-LLM-Resolved` response header).
|
|
*
|
|
* Plan: docs/plans/llm-fallback-aliases.md.
|
|
*/
|
|
export const MANA_LLM = {
|
|
/** Short answers, classification, single-shot Q&A. Cheap class. */
|
|
FAST_TEXT: 'mana/fast-text',
|
|
/** Writing, essays, stories, longer prose. */
|
|
LONG_FORM: 'mana/long-form',
|
|
/** JSON output (comic storyboards, research subqueries, voice-intent parsing). */
|
|
STRUCTURED: 'mana/structured',
|
|
/** Agent missions, tool calls, multi-step plans. */
|
|
REASONING: 'mana/reasoning',
|
|
/** Multimodal (image + text). */
|
|
VISION: 'mana/vision',
|
|
} as const;
|
|
|
|
export type ManaLlmAlias = (typeof MANA_LLM)[keyof typeof MANA_LLM];
|