aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/assistant/Config.js
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/assistant/Config.js')
-rw-r--r--desktop/modules/assistant/Config.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/desktop/modules/assistant/Config.js b/desktop/modules/assistant/Config.js
index 4c71b14..5c76e3b 100644
--- a/desktop/modules/assistant/Config.js
+++ b/desktop/modules/assistant/Config.js
@@ -142,8 +142,9 @@ function setEnv(text, key, val) {
return lines.join("\n");
}
-// [[cloud]] tables, the daemon's providers: name, url and key_cmd strings
-// and a one-line models array, as setClouds writes them.
+// [[cloud]] tables, the daemon's providers: name, url and key_cmd strings,
+// a one-line models array and an optional safe boolean, as setClouds
+// writes them.
const CLOUD = /^\s*\[\[cloud\]\]\s*(#.*)?$/;
// A one-line array of strings, ["a", "b"]; null for anything else.
@@ -175,14 +176,14 @@ function cloudBlocks(lines) {
return out;
}
-// [{name, url, key_cmd, models}] in file order, or null when a table holds
+// [{name, url, key_cmd, models, safe}] in file order, or null when a table holds
// a line this cannot read (a multi-line array, another key): the page then
// leaves them to be edited by hand rather than rewrite what it did not read.
function clouds(text) {
const lines = text.split("\n");
const out = [];
for (const b of cloudBlocks(lines)) {
- const c = { name: "", url: "", key_cmd: "", models: [] };
+ const c = { name: "", url: "", key_cmd: "", models: [], safe: false };
for (let i = b.start + 1; i < b.end; i++) {
if (/^\s*(#.*)?$/.test(lines[i])) continue;
const m = KEY.exec(lines[i]);
@@ -191,6 +192,8 @@ function clouds(text) {
const a = strings(m[4]);
if (a === null) return null;
c.models = a;
+ } else if (m[3] === "safe" && /^(true|false)\s*(#.*)?$/.test(m[4])) {
+ c.safe = m[4].startsWith("true");
} else if (["name", "url", "key_cmd"].includes(m[3]) && m[4].startsWith('"')) {
c[m[3]] = value(m[4]).v;
} else return null;
@@ -209,6 +212,7 @@ function setClouds(text, list) {
for (const c of list)
lines.push("", "[[cloud]]", "name = " + quote(c.name), "url = " + quote(c.url),
"key_cmd = " + quote(c.key_cmd),
+ ...(c.safe ? ["safe = true"] : []),
"models = [" + c.models.map(quote).join(", ") + "]");
return lines.join("\n") + "\n";
}