aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/assistant/AssistantModule.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/assistant/AssistantModule.qml')
-rw-r--r--desktop/modules/assistant/AssistantModule.qml25
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);
});
}