ryugyosoft commited on
Commit
c49b593
·
verified ·
1 Parent(s): aff4893

onw 3.5.1: OpenBLAS 8 threads; chat, window and benchmark fixes

Browse files
CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@
5
  日付は日本時間です。各版は Hugging Face の `ryugyosoft/onw` にタグ(`v0.4.2` 以降)付きで残っています。
6
  onw ウィンドウは、新しい版があるとこのファイルから変更点を表示します(`## v…` の見出しで区切っています)。
7
 
 
 
 
 
 
 
8
  ## v3.5.0 (2026-10-31)
9
  - 検証ページを **ベンチマーク**(`/bench`)に変えました。128・1K・2K・4K(8K も選べます)トークンのプロンプトで、プロンプトの読み込み(プリフィル)の速さと、そのあとの生成(デコード)の速さを表にします。プロンプトはそのモデル自身のトークナイザーで長さを合わせ、毎回違う一文で始めるので前の会話は再利用されません。「結果をコピー(Markdown)」で、アプリ・モデル・CPU・OS と一緒に表をコピーできます(記事などに)。トレイとウィンドウの「検証ページ」も「ベンチマーク」になり、前のアドレス(`/check`)はベンチマークへ移ります
10
  - チャット画面の上部に、直前の回答のプリフィル速度と生成速度を出すようにしました
 
5
  日付は日本時間です。各版は Hugging Face の `ryugyosoft/onw` にタグ(`v0.4.2` 以降)付きで残っています。
6
  onw ウィンドウは、新しい版があるとこのファイルから変更点を表示します(`## v…` の見出しで区切っています)。
7
 
8
+ ## v3.5.1 (2026-10-31)
9
+ - サーバーの numpy が CPU のスレッド数ぶん確保していたメモリ(コミット済み、約 750 MB)を約 250 MB にしました(使う量は変わりません)
10
+ - チャット画面:回答中の会話を履歴から開き直すと、直前の質問と途中の回答が消えることがあったのを直しました。上部の速度表示は、新しい会話・別の会話・モデルの切り替えで消えるようにしました。狭いウィンドウでヘッダーが崩れていたのを直しました
11
+ - ウィンドウ:設定を保存した直後に、古い値が一瞬表示に戻ることがあったのを直しました
12
+ - ベンチマーク:コピーする条件(生成トークン数・回数)を、測ったときのものにしました。2 回目以降が失敗しても、それまでの結果を残します。最良値は、いちばん速かった回のトークン数・再利用数で出します。モデルの読み込み中に開いても、読み込みが終われば使えます。考えるモデルでは、コンテキストに収まるかの判定に思考の分も入れました
13
+
14
  ## v3.5.0 (2026-10-31)
15
  - 検証ページを **ベンチマーク**(`/bench`)に変えました。128・1K・2K・4K(8K も選べます)トークンのプロンプトで、プロンプトの読み込み(プリフィル)の速さと、そのあとの生成(デコード)の速さを表にします。プロンプトはそのモデル自身のトークナイザーで長さを合わせ、毎回違う一文で始めるので前の会話は再利用されません。「結果をコピー(Markdown)」で、アプリ・モデル・CPU・OS と一緒に表をコピーできます(記事などに)。トレイとウィンドウの「検証ページ」も「ベンチマーク」になり、前のアドレス(`/check`)はベンチマークへ移ります
16
  - チャット画面の上部に、直前の回答のプリフィル速度と生成速度を出すようにしました
CHANGELOG_en.md CHANGED
@@ -4,6 +4,12 @@
4
 
5
  Dates are JST. Every version is on Hugging Face `ryugyosoft/onw`, tagged from `v0.4.2` on.
6
 
 
 
 
 
 
 
7
  ## v3.5.0 (2026-10-31)
8
  - The check page is now a **benchmark** (`/bench`): prompts of 128, 1K, 2K and 4K tokens (8K can be added), with how fast the prompt is read (prefill) and how fast the answer is then generated (decode). The prompts are cut to length by the model's own tokenizer and start with a different sentence every time, so nothing of an earlier conversation is reused. "Copy the results (Markdown)" copies the table with the app, model, CPU and OS (for articles and posts). The tray's and the window's "check page" entries open the benchmark, and the old address (`/check`) leads there
9
  - The chat page shows the last answer's prefill and decode speed at the top
 
4
 
5
  Dates are JST. Every version is on Hugging Face `ryugyosoft/onw`, tagged from `v0.4.2` on.
6
 
7
+ ## v3.5.1 (2026-10-31)
8
+ - The server's numpy reserved memory per CPU thread (about 750 MB committed); now about 250 MB (what it uses is unchanged)
9
+ - Chat page: reopening the conversation that is being answered could lose its last question and the partial answer: fixed. The speeds at the top go away with a new conversation, another conversation or another model. The header no longer breaks up in narrow windows
10
+ - Window: right after a save the old values could flash back for a moment: fixed
11
+ - Benchmark: the copied conditions (tokens generated, runs) are the measured run's; a failed later run keeps the results before it; the best result shows the fastest run's own token and reuse counts; opened while the model loads, it works once the model is in; for thinking models the context check counts the thinking too
12
+
13
  ## v3.5.0 (2026-10-31)
14
  - The check page is now a **benchmark** (`/bench`): prompts of 128, 1K, 2K and 4K tokens (8K can be added), with how fast the prompt is read (prefill) and how fast the answer is then generated (decode). The prompts are cut to length by the model's own tokenizer and start with a different sentence every time, so nothing of an earlier conversation is reused. "Copy the results (Markdown)" copies the table with the app, model, CPU and OS (for articles and posts). The tray's and the window's "check page" entries open the benchmark, and the old address (`/check`) leads there
15
  - The chat page shows the last answer's prefill and decode speed at the top
onw/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
 
3
  A small engine that runs LLMs entirely on the Intel NPU: static segment graphs + host-managed state.
4
  """
5
- __version__ = "3.5.0"
 
2
 
3
  A small engine that runs LLMs entirely on the Intel NPU: static segment graphs + host-managed state.
4
  """
5
+ __version__ = "3.5.1"
onw/app.py CHANGED
@@ -844,6 +844,9 @@ def _start_server(cfg):
844
  if not cfg.get("pld", True):
845
  args.append("--no-pld")
846
  env = {**os.environ, "PYTHONUTF8": "1"}
 
 
 
847
  if cfg.get("api_key"):
848
  env["ONW_API_KEY"] = cfg["api_key"]
849
  if cfg.get("big_blocks") in ("on", "off"):
 
844
  if not cfg.get("pld", True):
845
  args.append("--no-pld")
846
  env = {**os.environ, "PYTHONUTF8": "1"}
847
+ # [bugs 10-31] numpy's OpenBLAS reserves a buffer per CPU thread at import (~750 MB committed with 24-32 threads,
848
+ # ~30 MB used); 8 threads keep the CPU-side matrix work (image encoders) fast
849
+ env.setdefault("OPENBLAS_NUM_THREADS", "8")
850
  if cfg.get("api_key"):
851
  env["ONW_API_KEY"] = cfg["api_key"]
852
  if cfg.get("big_blocks") in ("on", "off"):
onw/web/bench.html CHANGED
@@ -68,7 +68,7 @@ td.big { font-weight: 700; }
68
  <script>
69
  translate(document.body);
70
  const $ = id => document.getElementById(id);
71
- let INFO = {}, KEY = new URLSearchParams(location.search).get("key") || "", RESULTS = [];
72
 
73
  const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
74
  const fmt = (x, d) => (x == null || !isFinite(x)) ? "-" : Number(x).toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
@@ -116,7 +116,7 @@ async function run() {
116
  const lens = [...document.querySelectorAll(".len")].filter(c => c.checked).map(c => +c.value);
117
  const gen = +$("gen").value, reps = +$("reps").value;
118
  const ctx = INFO.context || INFO.max_context || 0;
119
- $("run").disabled = true; $("copy").disabled = true; RESULTS = []; show();
120
  try {
121
  $("status").textContent = T("慣らし運転…");
122
  await api(await prompt(64, 0), 8);
@@ -124,16 +124,16 @@ async function run() {
124
  let k = 0;
125
  for (const n of lens) {
126
  const label = T("{0} トークン", n.toLocaleString());
127
- if (ctx && n + gen + 64 > ctx) { RESULTS.push({ label, err: T("コンテキスト長({0})を超えるので飛ばしました", ctx) }); show(); continue; }
128
  let best = null;
129
  for (let i = 0; i < reps; i++) {
130
  $("status").textContent = T("{0}({1}/{2}回目)…", label, i + 1, reps);
131
  try {
132
  const m = measure(await api(await prompt(n, ++k), gen));
133
- best = best ? { ...best, prefill_s: Math.min(best.prefill_s, m.prefill_s),
134
- prefill_tps: Math.max(best.prefill_tps || 0, m.prefill_tps || 0),
135
- decode_tps: Math.max(best.decode_tps || 0, m.decode_tps || 0) } : m;
136
- } catch (e) { best = { err: e.message }; break; }
137
  }
138
  RESULTS.push({ label: best.err ? label : T("{0} トークン", best.prompt.toLocaleString()), ...best }); show();
139
  }
@@ -142,7 +142,7 @@ async function run() {
142
 
143
  function markdown() {
144
  const env = [[T("アプリ"), INFO.app], [T("モデル"), INFO.model], [T("デバイス"), Object.values(INFO.devices || {}).join(", ")],
145
- [T("CPU"), INFO.cpu], [T("OS"), INFO.os], [T("条件"), T("温度 0・思考オフ・生成 {0} トークン・{1} 回の最良値", $("gen").value, $("reps").value)],
146
  [T("測定日"), new Date().toLocaleDateString()]].filter(([, v]) => v);
147
  const head = `| ${T("プロンプト")} | ${T("プリフィル")} | ${T("プリフィル速度")} | ${T("生成速度")} |\n|---|---:|---:|---:|`;
148
  const body = RESULTS.filter(r => !r.err).map(r =>
@@ -157,17 +157,21 @@ $("copy").onclick = async () => {
157
  document.execCommand("copy"); a.remove(); $("status").textContent = T("コピーしました"); }
158
  };
159
 
 
160
  fetch("/api/info").then(r => r.json()).then(i => {
 
161
  INFO = i;
162
  document.title = $("h1").textContent = T("{0} ベンチマーク", (i.app || "").split(" ")[0] || "LLM");
163
  const rows = [[T("アプリ"), i.app], [T("モデル名"), i.model], [T("デバイス"), Object.values(i.devices || {}).join(", ")],
164
- [T("CPU"), i.cpu], [T("OS"), i.os], [T("コンテキスト長"), T("{0} トークン", i.context || i.max_context)],
165
  [T("先読み(MTP・ドラフト)"), i.mtp ? T("有効") : T("なし")]].filter(([, v]) => v);
166
  $("info").innerHTML = rows.map(([k, v]) => `<tr><td>${esc(k)}</td><td>${esc(v)}</td></tr>`).join("");
167
  $("base").textContent = location.origin + "/v1"; $("mid").textContent = i.model;
168
  const ctx = i.context || i.max_context || 0;
169
  for (const c of document.querySelectorAll(".len")) if (ctx && +c.value + 512 > ctx) { c.checked = false; c.disabled = true; }
170
- }).catch(() => { $("info").innerHTML = `<tr><td class='bad'>${T("サーバーに接続できません")}</td></tr>`; });
 
 
171
  $("run").onclick = run;
172
  </script>
173
  </body>
 
68
  <script>
69
  translate(document.body);
70
  const $ = id => document.getElementById(id);
71
+ let INFO = {}, KEY = new URLSearchParams(location.search).get("key") || "", RESULTS = [], LAST = {};
72
 
73
  const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
74
  const fmt = (x, d) => (x == null || !isFinite(x)) ? "-" : Number(x).toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
 
116
  const lens = [...document.querySelectorAll(".len")].filter(c => c.checked).map(c => +c.value);
117
  const gen = +$("gen").value, reps = +$("reps").value;
118
  const ctx = INFO.context || INFO.max_context || 0;
119
+ $("run").disabled = true; $("copy").disabled = true; RESULTS = []; LAST = { gen, reps }; show();
120
  try {
121
  $("status").textContent = T("慣らし運転…");
122
  await api(await prompt(64, 0), 8);
 
124
  let k = 0;
125
  for (const n of lens) {
126
  const label = T("{0} トークン", n.toLocaleString());
127
+ if (ctx && n + gen + (INFO.always_thinks ? 1024 : 0) + 64 > ctx) { RESULTS.push({ label, err: T("コンテキスト長({0})を超えるので飛ばしました", ctx) }); show(); continue; }
128
  let best = null;
129
  for (let i = 0; i < reps; i++) {
130
  $("status").textContent = T("{0}({1}/{2}回目)…", label, i + 1, reps);
131
  try {
132
  const m = measure(await api(await prompt(n, ++k), gen));
133
+ const dec = Math.max(best?.decode_tps || 0, m.decode_tps || 0);
134
+ if (!best || (m.prefill_tps || 0) > (best.prefill_tps || 0)) best = { ...m };
135
+ best.decode_tps = dec || null;
136
+ } catch (e) { if (!best) best = { err: e.message }; break; } // (a run that came through stays)
137
  }
138
  RESULTS.push({ label: best.err ? label : T("{0} トークン", best.prompt.toLocaleString()), ...best }); show();
139
  }
 
142
 
143
  function markdown() {
144
  const env = [[T("アプリ"), INFO.app], [T("モデル"), INFO.model], [T("デバイス"), Object.values(INFO.devices || {}).join(", ")],
145
+ [T("CPU"), INFO.cpu], [T("OS"), INFO.os], [T("条件"), T("温度 0・思考オフ・生成 {0} トークン・{1} 回の最良値", LAST.gen, LAST.reps)],
146
  [T("測定日"), new Date().toLocaleDateString()]].filter(([, v]) => v);
147
  const head = `| ${T("プロンプト")} | ${T("プリフィル")} | ${T("プリフィル速度")} | ${T("生成速度")} |\n|---|---:|---:|---:|`;
148
  const body = RESULTS.filter(r => !r.err).map(r =>
 
157
  document.execCommand("copy"); a.remove(); $("status").textContent = T("コピーしました"); }
158
  };
159
 
160
+ function loadInfo() {
161
  fetch("/api/info").then(r => r.json()).then(i => {
162
+ if (!i.model) { setTimeout(loadInfo, 2000); return; } // (the model is still loading)
163
  INFO = i;
164
  document.title = $("h1").textContent = T("{0} ベンチマーク", (i.app || "").split(" ")[0] || "LLM");
165
  const rows = [[T("アプリ"), i.app], [T("モデル名"), i.model], [T("デバイス"), Object.values(i.devices || {}).join(", ")],
166
+ [T("CPU"), i.cpu], [T("OS"), i.os], [T("コンテキスト長"), (i.context || i.max_context) && T("{0} トークン", i.context || i.max_context)],
167
  [T("先読み(MTP・ドラフト)"), i.mtp ? T("有効") : T("なし")]].filter(([, v]) => v);
168
  $("info").innerHTML = rows.map(([k, v]) => `<tr><td>${esc(k)}</td><td>${esc(v)}</td></tr>`).join("");
169
  $("base").textContent = location.origin + "/v1"; $("mid").textContent = i.model;
170
  const ctx = i.context || i.max_context || 0;
171
  for (const c of document.querySelectorAll(".len")) if (ctx && +c.value + 512 > ctx) { c.checked = false; c.disabled = true; }
172
+ }).catch(() => { $("info").innerHTML = `<tr><td class='bad'>${T("サーバーに接続できません")}</td></tr>`; setTimeout(loadInfo, 3000); });
173
+ }
174
+ loadInfo();
175
  $("run").onclick = run;
176
  </script>
177
  </body>
onw/web/index.html CHANGED
@@ -21,8 +21,11 @@
21
  html, body { height: 100%; margin: 0; }
22
  body { background: var(--bg); color: var(--text); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; display: flex; flex-direction: column; }
23
  header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
24
- header h1 { font-size: 16px; margin: 0; font-weight: 600; }
25
- .badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
 
 
 
26
  .badge.ok { color: var(--accent); border-color: var(--accent); }
27
  header .spacer { flex: 1; }
28
  button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 6px 12px; }
@@ -226,6 +229,7 @@ function loadInfo() { // the server's model and settings: tried again until it
226
  const id = i.model || i.title || "", first = !MODEL;
227
  if (MODEL && id === MODEL) return; // the same model: its settings (and the user's changes) stay
228
  MODEL = id;
 
229
  if (i.title) { $("title").textContent = i.title; document.title = i.title + " on NPU"; }
230
  VISION = i.vision !== false; $("attach").style.display = VISION ? "" : "none";
231
  if (!VISION) { pending = []; showThumbs(); if (first && $("empty")) $("empty").textContent = T("メッセージを入力してください。"); }
@@ -398,8 +402,10 @@ document.addEventListener("dragleave", () => document.body.classList.remove("dra
398
  document.addEventListener("drop", e => { e.preventDefault(); document.body.classList.remove("drag"); addFiles(e.dataTransfer.files); });
399
  $("input").addEventListener("input", e => { e.target.style.height = "auto"; e.target.style.height = e.target.scrollHeight + "px"; });
400
  $("input").addEventListener("keydown", e => { if (e.key === "Enter" && !e.shiftKey && !e.isComposing) { e.preventDefault(); if (!controller) send(); } }); // (not while an answer is written)
 
401
  function newChat() {
402
  if (controller) controller.abort();
 
403
  history.length = 0; pending = []; showThumbs(); chat = { id: null, created: 0, title: "", msgs: [] };
404
  $("log").innerHTML = `<div class="empty" id="empty">${T("新しい会話です。")}</div>`;
405
  listChats();
@@ -486,7 +492,9 @@ async function listChats() {
486
  }
487
  }
488
  async function openChat(id) {
 
489
  if (controller) controller.abort();
 
490
  const r = await fetch("/api/chats/" + id); if (!r.ok) return listChats();
491
  const c = await r.json();
492
  chat = { id: c.id, created: c.created, title: c.title, model: c.model, msgs: c.messages || [] };
 
21
  html, body { height: 100%; margin: 0; }
22
  body { background: var(--bg); color: var(--text); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; display: flex; flex-direction: column; }
23
  header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
24
+ header h1 { font-size: 16px; margin: 0; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
25
+ .badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
26
+ @media (max-width: 600px) { #speed { display: none !important; } }
27
+ header button { white-space: nowrap; flex-shrink: 0; }
28
+ #dev { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
29
  .badge.ok { color: var(--accent); border-color: var(--accent); }
30
  header .spacer { flex: 1; }
31
  button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 6px 12px; }
 
229
  const id = i.model || i.title || "", first = !MODEL;
230
  if (MODEL && id === MODEL) return; // the same model: its settings (and the user's changes) stay
231
  MODEL = id;
232
+ clearSpeed();
233
  if (i.title) { $("title").textContent = i.title; document.title = i.title + " on NPU"; }
234
  VISION = i.vision !== false; $("attach").style.display = VISION ? "" : "none";
235
  if (!VISION) { pending = []; showThumbs(); if (first && $("empty")) $("empty").textContent = T("メッセージを入力してください。"); }
 
402
  document.addEventListener("drop", e => { e.preventDefault(); document.body.classList.remove("drag"); addFiles(e.dataTransfer.files); });
403
  $("input").addEventListener("input", e => { e.target.style.height = "auto"; e.target.style.height = e.target.scrollHeight + "px"; });
404
  $("input").addEventListener("keydown", e => { if (e.key === "Enter" && !e.shiftKey && !e.isComposing) { e.preventDefault(); if (!controller) send(); } }); // (not while an answer is written)
405
+ function clearSpeed() { const b = document.getElementById("speed"); if (b) b.style.display = "none"; }
406
  function newChat() {
407
  if (controller) controller.abort();
408
+ clearSpeed();
409
  history.length = 0; pending = []; showThumbs(); chat = { id: null, created: 0, title: "", msgs: [] };
410
  $("log").innerHTML = `<div class="empty" id="empty">${T("新しい会話です。")}</div>`;
411
  listChats();
 
492
  }
493
  }
494
  async function openChat(id) {
495
+ if (id === chat.id) return; // (the open one - an answer may still be coming in)
496
  if (controller) controller.abort();
497
+ clearSpeed();
498
  const r = await fetch("/api/chats/" + id); if (!r.ok) return listChats();
499
  const c = await r.json();
500
  chat = { id: c.id, created: c.created, title: c.title, model: c.model, msgs: c.messages || [] };
onw/web/manage.html CHANGED
@@ -196,14 +196,14 @@
196
  <div class="card">
197
  <div class="row">
198
  <span class="muted">使うモデル</span>
199
- <select class="grow" id="pick"></select>
200
  <button class="primary" id="b-load" onclick="this.dataset.act === 'unload' ? post('unload') : loadPicked()">ロード</button>
201
  </div>
202
  <div class="muted small" style="margin-top:5px">一度に 1 モデル。別のモデルを選んで「切り替え」を押すと、今のモデルをアンロードしてから読み込みます。初回のロードだけ NPU 向けのコンパイルが入ります(数分〜30 分)。</div>
203
  </div>
204
  <div class="card set" id="prefcard">
205
  <div class="row"><b>このモデルの既定</b><span class="muted small" id="pf-model"></span></div>
206
- <div class="opt" id="pf-think-row"><span class="k">思考</span><input type="range" id="pf-think" min="0" max="3" step="1" style="width:220px"><b id="pf-think-label" class="small"></b>
207
  <span class="desc" id="pf-think-desc"></span></div>
208
  <div class="opt"><span class="k">生成設定</span><select id="pf-sampling" style="width:360px;max-width:100%"><option value="greedy">貪欲(温度 0。毎回同じ答え)</option><option value="recommended">モデルの推奨値</option><option value="custom">自分で指定</option></select></div>
209
  <div class="opt" id="pf-custom"><span class="k"></span>
@@ -584,7 +584,7 @@
584
  if ($("pf-think-row").style.display === "none") delete prefs.think;
585
  const r = await post("model_prefs", { key, prefs });
586
  if (r.error) return;
587
- prefDirty = false; $("pf-saved").textContent = T("保存しました(すぐ反映されます)");
588
  }
589
  function strictState() { // the strict option only under the memory-saving mode
590
  const on = $("f-mem_saver").checked;
@@ -687,7 +687,7 @@
687
  const oldLang = S.config.lang || "auto";
688
  const r = await post("settings", body);
689
  if (r.error) return;
690
- setDirty(false);
691
  $("saved").textContent = T("保存しました");
692
  if (r.restart_needed && await ask(T("設定は保存しました。サーバーを新しい設定で今すぐ再起動しますか?(キャンセルしても、次にモデルを読み込むときから反映されます)"))) await post("restart");
693
  if (oldLang !== body.lang) location.reload(); // the page is served in the new language
@@ -793,6 +793,7 @@
793
  // [3.3.2] no answer (offline), the manager's error (its state failed: said with the reason) and a page that cannot draw
794
  // the state (render's own banner) are three things - all three used to show as "offline"
795
  async function refresh() {
 
796
  let j;
797
  try {
798
  const r = await fetch("/api/state?token=" + encodeURIComponent(TOKEN), {cache: "no-store"});
@@ -804,9 +805,11 @@
804
  showError(T("onw の状態を読めません: {0}", (j && j.error) || "?"));
805
  return;
806
  }
 
807
  S = j;
808
  try { render(); } catch (e) { console.error(e); showError(T("表示エラー: {0}", e && e.message || e)); }
809
  }
 
810
  refresh(); setInterval(refresh, 1000);
811
  </script>
812
  </body>
 
196
  <div class="card">
197
  <div class="row">
198
  <span class="muted">使うモデル</span>
199
+ <select class="grow" id="pick" aria-label="モデル"></select>
200
  <button class="primary" id="b-load" onclick="this.dataset.act === 'unload' ? post('unload') : loadPicked()">ロード</button>
201
  </div>
202
  <div class="muted small" style="margin-top:5px">一度に 1 モデル。別のモデルを選んで「切り替え」を押すと、今のモデルをアンロードしてから読み込みます。初回のロードだけ NPU 向けのコンパイルが入ります(数分〜30 分)。</div>
203
  </div>
204
  <div class="card set" id="prefcard">
205
  <div class="row"><b>このモデルの既定</b><span class="muted small" id="pf-model"></span></div>
206
+ <div class="opt" id="pf-think-row"><span class="k">思考</span><input type="range" id="pf-think" aria-label="思考" min="0" max="3" step="1" style="width:220px"><b id="pf-think-label" class="small"></b>
207
  <span class="desc" id="pf-think-desc"></span></div>
208
  <div class="opt"><span class="k">生成設定</span><select id="pf-sampling" style="width:360px;max-width:100%"><option value="greedy">貪欲(温度 0。毎回同じ答え)</option><option value="recommended">モデルの推奨値</option><option value="custom">自分で指定</option></select></div>
209
  <div class="opt" id="pf-custom"><span class="k"></span>
 
584
  if ($("pf-think-row").style.display === "none") delete prefs.think;
585
  const r = await post("model_prefs", { key, prefs });
586
  if (r.error) return;
587
+ STALE = REQ; prefDirty = false; $("pf-saved").textContent = T("保存しました(すぐ反映されます)");
588
  }
589
  function strictState() { // the strict option only under the memory-saving mode
590
  const on = $("f-mem_saver").checked;
 
687
  const oldLang = S.config.lang || "auto";
688
  const r = await post("settings", body);
689
  if (r.error) return;
690
+ STALE = REQ; setDirty(false);
691
  $("saved").textContent = T("保存しました");
692
  if (r.restart_needed && await ask(T("設定は保存しました。サーバーを新しい設定で今すぐ再起動しますか?(キャンセルしても、次にモデルを読み込むときから反映されます)"))) await post("restart");
693
  if (oldLang !== body.lang) location.reload(); // the page is served in the new language
 
793
  // [3.3.2] no answer (offline), the manager's error (its state failed: said with the reason) and a page that cannot draw
794
  // the state (render's own banner) are three things - all three used to show as "offline"
795
  async function refresh() {
796
+ const n = ++REQ;
797
  let j;
798
  try {
799
  const r = await fetch("/api/state?token=" + encodeURIComponent(TOKEN), {cache: "no-store"});
 
805
  showError(T("onw の状態を読めません: {0}", (j && j.error) || "?"));
806
  return;
807
  }
808
+ if (n <= STALE) return; // (asked before the last save: shows the old values)
809
  S = j;
810
  try { render(); } catch (e) { console.error(e); showError(T("表示エラー: {0}", e && e.message || e)); }
811
  }
812
+ let REQ = 0, STALE = 0; // state polls / the last one started before a save
813
  refresh(); setInterval(refresh, 1000);
814
  </script>
815
  </body>