summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-28 09:16:00 +0100
committerDanilo M. <danix@danix.xyz>2026-10-28 09:16:00 +0100
commitad0989dda8dc6420d16aaaa6aa40c47917145342 (patch)
tree977c41f3892854bc1b6c01f3f60de72fd8e3c333
parent779492e8b40084032e218c89f211e60527a28b98 (diff)
downloadquickshell-ad0989dda8dc6420d16aaaa6aa40c47917145342.tar.gz
quickshell-ad0989dda8dc6420d16aaaa6aa40c47917145342.zip
assistant: unload the resident model from the settings page
The Load button reads Unload on the loaded model and posts to the router's /models/unload. An error from the router lands in modelError, the same place a failed load reports, and the list is re-read either way. The model comes back on the next request for it or when the canvas opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--desktop/modules/assistant/AssistantModule.qml12
-rw-r--r--desktop/modules/assistant/AssistantPage.qml10
2 files changed, 18 insertions, 4 deletions
diff --git a/desktop/modules/assistant/AssistantModule.qml b/desktop/modules/assistant/AssistantModule.qml
index a05556d..9e8adbc 100644
--- a/desktop/modules/assistant/AssistantModule.qml
+++ b/desktop/modules/assistant/AssistantModule.qml
@@ -362,6 +362,18 @@ Module {
else { poll.left = 300; poll.start(); }
});
}
+ // Frees the VRAM for every client; the next request for the model, or
+ // the canvas opening, loads it again.
+ function unloadModel(id) {
+ am.modelError = "";
+ am.run(["curl", "-s", "-m", "30", "-X", "POST", "-H", "Content-Type: application/json",
+ "-d", JSON.stringify({ model: id }), am.routerRoot + "/models/unload"], null, (code, out) => {
+ let err = code === 0 ? "" : "the router did not answer";
+ try { const e = JSON.parse(out).error; if (e) err = e.message; } catch (x) {}
+ if (err) am.modelError = `${id}: ${err}`;
+ am.listModels();
+ });
+ }
// Called when the canvas opens and when its chat's model changes, with
// the chat's model, else the preferred one: loaded if it is a router
// model neither loaded nor loading. A cloud id is not in the router's
diff --git a/desktop/modules/assistant/AssistantPage.qml b/desktop/modules/assistant/AssistantPage.qml
index bf35763..b25b33b 100644
--- a/desktop/modules/assistant/AssistantPage.qml
+++ b/desktop/modules/assistant/AssistantPage.qml
@@ -168,7 +168,8 @@ Column {
wrapMode: Text.Wrap
text: "Each chat uses the model picked in the canvas header, else the preferred one. "
+ "Opening the canvas loads that model if it is a local one and another is in. "
- + "Load swaps a model in now, for every client, without changing the preference."
+ + "Load swaps a model in now, for every client, without changing the preference; "
+ + "Unload frees the VRAM until something asks for the model again."
}
Small {
@@ -218,9 +219,10 @@ Column {
Button {
id: loadBtn
anchors { right: parent.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
- text: "Load"
- enabled: page.asst.loading === "" && !modelRow.loaded
- onClicked: page.asst.loadModel(modelRow.modelData.id)
+ text: modelRow.loaded ? "Unload" : "Load"
+ enabled: page.asst.loading === ""
+ onClicked: modelRow.loaded ? page.asst.unloadModel(modelRow.modelData.id)
+ : page.asst.loadModel(modelRow.modelData.id)
}
Button {
anchors { right: loadBtn.left; rightMargin: 6; verticalCenter: parent.verticalCenter }