dsh-think-translate 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +18 -6
- package/lib/index.js +8 -6
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -238,7 +238,7 @@ window.__ModuleLoader__.load({
|
|
|
238
238
|
// ------------------------------------------------------------------
|
|
239
239
|
var mem = new Map();
|
|
240
240
|
var pend = new Map();
|
|
241
|
-
var stats = { ok: 0, fail: 0, lastError: null, lastProvider: null };
|
|
241
|
+
var stats = { ok: 0, fail: 0, lastError: null, lastProvider: null, lastModel: null };
|
|
242
242
|
// Diagnostic ledger surfaced in the settings panel (2026-08-24): bundle
|
|
243
243
|
// version, apply execution, per-slot registration outcome, current lang.
|
|
244
244
|
var diag = { version: "v3-priority-1", applied: false, lang: "?", slots: {}, lastLangChange: 0 };
|
|
@@ -395,7 +395,7 @@ window.__ModuleLoader__.load({
|
|
|
395
395
|
} catch (e2) { r = null; if (e2 && e2.message) lastErr = e2; }
|
|
396
396
|
}
|
|
397
397
|
if (r && r.ok) {
|
|
398
|
-
stats.ok++; stats.lastError = null; stats.lastProvider = r.provider;
|
|
398
|
+
stats.ok++; stats.lastError = null; stats.lastProvider = r.provider; stats.lastModel = r.model || null;
|
|
399
399
|
memSet(key, r);
|
|
400
400
|
return r;
|
|
401
401
|
}
|
|
@@ -792,7 +792,7 @@ window.__ModuleLoader__.load({
|
|
|
792
792
|
var t = UI_TEXT[s.lang] || UI_TEXT.en;
|
|
793
793
|
return createElement("div", null,
|
|
794
794
|
createElement("div", { className: "xl-kv" }, createElement("b", null, t.status), createElement("span", null, stats.ok + " / " + stats.fail)),
|
|
795
|
-
createElement("div", { className: "xl-kv" }, createElement("b", null, t.providerOf), createElement("span", null, stats.lastProvider ? (t.labels[stats.lastProvider] || stats.lastProvider) : t.providerDesc)),
|
|
795
|
+
createElement("div", { className: "xl-kv" }, createElement("b", null, t.providerOf), createElement("span", null, stats.lastProvider ? ((t.labels[stats.lastProvider] || stats.lastProvider) + (stats.lastModel ? " · " + stats.lastModel : "")) : t.providerDesc)),
|
|
796
796
|
createElement("div", { className: "xl-kv" }, createElement("b", null, t.cacheEntries), createElement("span", null, String(mem.size))),
|
|
797
797
|
stats.lastError ? createElement("div", { className: "xl-err" }, t.lastError + ": " + stats.lastError) : null,
|
|
798
798
|
createElement("button", {
|
|
@@ -889,7 +889,7 @@ window.__ModuleLoader__.load({
|
|
|
889
889
|
fetch("/_xlate/translate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: "Hello world, this is a connection test. [" + Date.now().toString(36) + "]", target: store.lang }) })
|
|
890
890
|
.then(function (r) { return r.json(); })
|
|
891
891
|
.then(function (j) {
|
|
892
|
-
setMsg(j && j.ok ? t.connOk + " ✓ (" + (j.provider ||
|
|
892
|
+
setMsg(j && j.ok ? t.connOk + " ✓ (" + (t.labels[j.provider] || j.provider) + (j.model ? ": " + j.model : "") + ")" : t.connFail + ": " + (j.error || "unknown"));
|
|
893
893
|
})
|
|
894
894
|
.catch(function (e) { setMsg(t.connFail + ": " + (e && e.message ? e.message : e)); });
|
|
895
895
|
};
|
|
@@ -975,9 +975,21 @@ window.__ModuleLoader__.load({
|
|
|
975
975
|
createElement("select", {
|
|
976
976
|
className: "xl-sel", value: cfg.priority || "google",
|
|
977
977
|
onChange: function (e) {
|
|
978
|
-
var
|
|
978
|
+
var p = e.target.value;
|
|
979
|
+
var next = Object.assign({}, cfg, { priority: p });
|
|
979
980
|
setCfg(next);
|
|
980
|
-
|
|
981
|
+
// Selecting the local model must also enable the openai
|
|
982
|
+
// provider — priority and enabled are independent fields,
|
|
983
|
+
// and a disabled provider is silently skipped by the chain
|
|
984
|
+
// (falls back to google), which confused users (2026-08-25).
|
|
985
|
+
var patch = { priority: p };
|
|
986
|
+
if (p === "openai" && cfg.providers && cfg.providers.openai && !cfg.providers.openai.enabled) {
|
|
987
|
+
patch.providers = { openai: { enabled: true } };
|
|
988
|
+
}
|
|
989
|
+
fetch("/_xlate/config", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(patch) })
|
|
990
|
+
.then(function (r) { return r.json(); })
|
|
991
|
+
.then(function (c) { setCfg(c); })
|
|
992
|
+
.catch(function () {});
|
|
981
993
|
}
|
|
982
994
|
}, priorities.map(function (p) {
|
|
983
995
|
return createElement("option", { key: p, value: p }, (t.labels[p] || p));
|
package/lib/index.js
CHANGED
|
@@ -21,16 +21,16 @@ export const inject = ['webServer', 'subprocess', 'timer']
|
|
|
21
21
|
|
|
22
22
|
const CONFIG_PATH = fileURLToPath(new URL('./config.json', import.meta.url))
|
|
23
23
|
|
|
24
|
-
// Defaults:
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
24
|
+
// Defaults: local model (Ollama) enabled from the start — the chain is
|
|
25
|
+
// fail-open, so if Ollama is down it falls back to google/bing. Selecting the
|
|
26
|
+
// local model in the UI also re-enables the provider (priority and enabled
|
|
27
|
+
// are independent fields; a disabled provider is silently skipped).
|
|
28
28
|
const DEFAULT_CONFIG = {
|
|
29
29
|
priority: 'google',
|
|
30
30
|
providers: {
|
|
31
31
|
google: { enabled: true },
|
|
32
32
|
bing: { enabled: true },
|
|
33
|
-
openai: { enabled:
|
|
33
|
+
openai: { enabled: true, baseURL: 'http://localhost:11434/v1', model: 'qwen2.5:7b-instruct', apiKey: 'ollama-local' },
|
|
34
34
|
},
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -437,7 +437,9 @@ async function translateViaChain(text, target, cfg) {
|
|
|
437
437
|
state.ok++
|
|
438
438
|
state.lastProvider = id
|
|
439
439
|
state.lastError = null
|
|
440
|
-
|
|
440
|
+
// Carry the concrete model name for openai (local Ollama) so the UI can
|
|
441
|
+
// show e.g. "local model: qwen2.5:14b" instead of the bare provider id.
|
|
442
|
+
return { ok: true, text: outs.join(''), provider: id, ...(id === 'openai' ? { model: cfg.providers.openai.model } : {}) }
|
|
441
443
|
} catch (e) {
|
|
442
444
|
lastErr = e
|
|
443
445
|
if (id === 'bing') bingCache = null
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-think-translate",
|
|
3
3
|
"description": "Display-layer translation for the DSH web app: thinking chain, task cards, and optional answer text, in 8 target languages (local Ollama / Google / Bing, fail-open)",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|