Files
Lumotia/src/lib/stores/llmStatus.svelte.ts
Jake 0f105f0e15 chore(llm): update callers for renamed model variants
Picks up the registry rename in the front-end and Tauri command layer:

- src/lib/types/app.ts: LlmModelIdStr now lists the four new ids
  (qwen3_5_2b / qwen3_5_4b / qwen3_5_9b / qwen3_6_27b).
- src/lib/pages/SettingsPage.svelte: LLM_MODELS table rebuilt with
  four tiers (Minimal / Standard / High / Maximum), matching subtitles
  and download-size copy. selectedLlmModelId fallback, hardware-warning
  thresholds, tier-availability check, and ensureRecommendedLlmTier
  fallback all retargeted at the new ids. The Maximum tier surfaces a
  64 GB / 24 GB warning so users with mid-range hardware see honest
  expectations.
- src-tauri/src/commands/llm.rs and commands/tasks.rs: doc-comment
  examples refreshed (Qwen3 4B → Qwen3.5 4B, Qwen3's tokenizer →
  Qwen's tokenizer — the BPE family is shared).
- src/lib/stores/llmStatus.svelte.ts: chip-detail example updated.

cargo build --workspace clean. cargo test --workspace clean.
npx svelte-check reports one pre-existing error in vite.config.js
(unused @ts-expect-error directive, dates back to the original
scaffold commit 9926a42); not introduced here, out of scope to fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 09:59:03 +01:00

65 lines
2.4 KiB
TypeScript

import { invoke } from "@tauri-apps/api/core";
import { hasTauriRuntime } from "$lib/utils/runtime.js";
/// Visible LLM state for the status chip (brief item #31).
/// off — user has settings.aiTier === "off"; chip hidden.
/// warming — model download or load in progress.
/// ready — model loaded, idle.
/// generating — an active cleanup_transcript_text_cmd call is in flight.
/// error — last health check or generation failed.
export type LlmStatusKind = "off" | "warming" | "ready" | "generating" | "error";
export interface LlmStatusState {
kind: LlmStatusKind;
/// Optional short phrase for the chip to surface (e.g. "Loading Qwen3.5 4B").
detail: string | null;
}
export const llmStatus = $state<LlmStatusState>({ kind: "off", detail: null });
/// Poll `get_llm_status` once. Cheap enough to call on layout mount, on
/// recording start, and on Settings-panel open. Keeps the chip in sync
/// with loads / unloads that happen outside the frontend's observation
/// path (first-run, background reload). The `aiTier` input short-circuits
/// to "off" so we don't show a chip when the user has opted out.
export async function refreshLlmStatus(aiTier: string): Promise<void> {
if (aiTier === "off") {
llmStatus.kind = "off";
llmStatus.detail = null;
return;
}
if (!hasTauriRuntime()) {
// Running in a pure-browser preview (vite dev without tauri) — leave
// the chip off rather than asserting a loaded state we can't verify.
llmStatus.kind = "off";
llmStatus.detail = null;
return;
}
try {
const loaded = await invoke<boolean>("get_llm_status");
// Don't clobber a "generating" state with "ready" — a parallel
// cleanup call in flight is a truer signal than the load status.
if (llmStatus.kind === "generating") return;
llmStatus.kind = loaded ? "ready" : "warming";
llmStatus.detail = null;
} catch (err) {
llmStatus.kind = "error";
llmStatus.detail = typeof err === "string" ? err : (err as Error)?.message ?? "Unknown error";
}
}
export function markGenerating(detail: string | null = null): void {
llmStatus.kind = "generating";
llmStatus.detail = detail;
}
export function markGenerationDone(success: boolean, detail: string | null = null): void {
if (success) {
llmStatus.kind = "ready";
llmStatus.detail = null;
} else {
llmStatus.kind = "error";
llmStatus.detail = detail;
}
}