fix(llm): user-friendly error messages when no LLM tier available

Track skip reasons per tier in the orchestrator (no-consent,
no-backend, not-available, not-ready, runtime-error) and expose
them via NoTierAvailableError.getUserMessage() with actionable
German text pointing the user to the right settings page.

Before: "No tier could run task 'companion.chat' (attempted: cloud)"
After:  "Cloud (Gemini): Cloud-Einwilligung fehlt. Aktiviere sie
         unter Einstellungen → KI."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-17 14:46:39 +02:00
parent c642e1be78
commit 2b96953ad1
3 changed files with 72 additions and 4 deletions

View file

@ -11,7 +11,7 @@
* routes through text-completion).
*/
import { llmOrchestrator } from '@mana/shared-llm';
import { llmOrchestrator, NoTierAvailableError } from '@mana/shared-llm';
import { isLocalLlmSupported, getLocalLlmStatus, loadLocalLlm } from '@mana/local-llm';
import { companionChatTask } from '$lib/llm-tasks/companion-chat';
import { generateContextDocument } from '$lib/data/projections/context-document';
@ -54,8 +54,11 @@ async function callLlm(messages: LlmMessage[], onToken?: (token: string) => void
});
return result.value.content;
} catch (err) {
if (err instanceof NoTierAvailableError) {
return err.getUserMessage();
}
const msg = err instanceof Error ? err.message : String(err);
return `LLM nicht verfuegbar: ${msg}`;
return `LLM nicht verfügbar: ${msg}`;
}
}