diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-19 11:36:00 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-19 11:36:00 +0200 |
| commit | 2d51494f7aa574da3b054a8bbdcf2532ff32a71f (patch) | |
| tree | 9fab3f2a50b69ba7fc15693e17734bec878bb1ae /desktop/modules | |
| parent | c1fc2001219eb9aa349439b3007b57e1ced25335 (diff) | |
| download | quickshell-2d51494f7aa574da3b054a8bbdcf2532ff32a71f.tar.gz quickshell-2d51494f7aa574da3b054a8bbdcf2532ff32a71f.zip | |
assistant: grey out the mic when the model cannot hear
AssistantModule keeps each router model's input_modalities and exposes
hears: the model loading, else the first not unloaded (the daemon's
rule), reports audio. Unknown inputs or a router that is down count as
yes; the daemon's error covers the rest. The model list is now read on
every canvas open, not only when a preferred model is set, so hears is
current when the card shows.
Checked: the rule against the router's live /models (Gemma resident:
on; Qwen resident or loading: off; router down: on). Not yet seen by
eye after a desktop shell reload.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules')
| -rw-r--r-- | desktop/modules/assistant/AssistantModule.qml | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/desktop/modules/assistant/AssistantModule.qml b/desktop/modules/assistant/AssistantModule.qml index f738ea6..1e3c1e0 100644 --- a/desktop/modules/assistant/AssistantModule.qml +++ b/desktop/modules/assistant/AssistantModule.qml @@ -72,11 +72,19 @@ Module { // A write since the last restart, which the daemon has not read yet. property bool pending: false - // The router's models, [{id, status}], status as it reports it: - // "loaded", "loading", "unloaded" and so on. Empty when it is down. + // The router's models, [{id, status, inputs}], status as it reports it: + // "loaded", "loading", "unloaded" and so on; inputs its + // input_modalities, null when not reported. Empty when it is down. property var models: [] // The id being loaded, "" when none is. property string loading: "" + // Whether the assistant's model takes audio, for the canvas's mic: the + // one loading, else the daemon's pick, the first not unloaded. Unknown + // counts as yes, and the daemon's own error says otherwise. + readonly property bool hears: { + const m = am.models.find(x => am.loading !== "" ? x.id === am.loading : x.status !== "unloaded"); + return !m?.inputs || m.inputs.includes("audio"); + } property string modelError: "" // The router answers /models and /models/load on the server's root, and // the OpenAI API under /v1, which is what the daemon's llm points at. @@ -233,7 +241,9 @@ Module { function listModels(done) { am.run(["curl", "-sf", "-m", "3", am.llm + "/models"], null, (code, out) => { try { - am.models = code === 0 ? JSON.parse(out).data.map(m => ({ id: m.id, status: m.status?.value ?? "" })) : []; + am.models = code === 0 ? JSON.parse(out).data.map(m => ({ + id: m.id, status: m.status?.value ?? "", + inputs: m.architecture?.input_modalities ?? null })) : []; } catch (e) { am.models = []; } if (done) done(); }); @@ -262,13 +272,14 @@ Module { // Called when the assistant canvas opens: the preferred model, if one is // set, still listed, and neither loaded nor loading, is loaded. One model // and one client at a time is how this desktop runs, so opening the - // assistant is the moment to bring its model back. + // assistant is the moment to bring its model back. The list is read on + // every open, preferred model or not, so hears is current. function ensurePreferred() { - const id = Prefs.assistantModel; - if (id === "" || am.loading !== "") return; + if (am.loading !== "") return; am.listModels(() => { + const id = Prefs.assistantModel; const m = am.models.find(x => x.id === id); - if (m && m.status !== "loaded" && m.status !== "loading") am.loadModel(id); + if (id !== "" && m && m.status !== "loaded" && m.status !== "loading") am.loadModel(id); }); } |
