mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 00:29:40 +02:00
feat(llm): add BYOK tier + 4 provider adapters (OpenAI, Anthropic, Gemini, Mistral)
Phase 1-3 of BYOK support. Introduces a 5th LLM tier 'byok' that routes to user-provided API keys via direct browser fetches. shared-llm additions: - LlmTier extended with 'byok' (rank 3, between mana-server and cloud) - ByokBackend: LlmBackend implementation that delegates key lookup to an app-provided resolver callback, then dispatches to the right provider adapter - 4 provider adapters: - OpenAI (gpt-5, gpt-4o, o1 family) - Anthropic (Claude Opus/Sonnet/Haiku 4.6) with CORS header - Gemini (2.5 Pro/Flash) — REST API with different message format - Mistral — OpenAI-compatible, reuses shared openai-compat adapter - Pricing table for 20+ models with USD per 1M tokens - estimateCost() + formatCost() helpers Keys stay device-local (IndexedDB in next phase). Browser-direct fetches mean keys never touch Mana's server. Updates two existing tier maps (memoro DetailView, SourceBadge) to include the new tier. Planning doc at docs/architecture/BYOK_PLAN.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3817111f80
commit
a33857fa39
15 changed files with 1026 additions and 11 deletions
|
|
@ -14,7 +14,7 @@
|
|||
* <SourceBadge tier={result.source} latencyMs={result.latencyMs} />
|
||||
*/
|
||||
import { llmSettingsState, tierLabel, type LlmTier } from '@mana/shared-llm';
|
||||
import { Lightning, Cpu, HardDrive, Cloud } from '@mana/shared-icons';
|
||||
import { Lightning, Cpu, HardDrive, Cloud, Key } from '@mana/shared-icons';
|
||||
|
||||
interface Props {
|
||||
tier: LlmTier;
|
||||
|
|
@ -39,6 +39,10 @@
|
|||
color: 'border-blue-500/40 bg-blue-500/10 text-blue-600 dark:text-blue-400',
|
||||
icon: HardDrive, // our infrastructure
|
||||
},
|
||||
byok: {
|
||||
color: 'border-violet-500/40 bg-violet-500/10 text-violet-600 dark:text-violet-400',
|
||||
icon: Key, // user-supplied key
|
||||
},
|
||||
cloud: {
|
||||
color: 'border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400',
|
||||
icon: Cloud, // remote
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
none: 'Lokal (regelbasiert)',
|
||||
browser: 'Auf deinem Gerät (Gemma 4 E2B)',
|
||||
'mana-server': 'Mana-Server (Gemma 4 E4B)',
|
||||
byok: 'Dein API-Key',
|
||||
cloud: 'Google Gemini',
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue