From a6e4cf7635c453f4863dec484c106b1e80d37317 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 9 Nov 2026 22:42:51 +0800 Subject: [PATCH] =?UTF-8?q?settings:=20what=20routing=20does=20sits=20unde?= =?UTF-8?q?r=20Models=20=E2=80=BA=20Routing,=20and=20the=20Routing=20page?= =?UTF-8?q?=20opens=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scattered settings audit after netube99 on X. Ask again after a refusal, the Retry-After cap and the intent classifier's timeout were under Models › Replies beside rows about a reply's content, and Busy models last sat in Network and sharing, far from the routing it changes. The four are now one Routing section under Models, after Replies, and the Routing page's header has a Settings › button that opens Settings at that section with its first row lit. The docs (reference.md, the site's plugins page in en, zh and ja) name the new place. Run (mote, mote-run): - settings-places, retry-after-cap-setting, refusal-retries-setting, classify-timeout-setting, model-load, i18n-keys and bare-ids, both engines: all pass. - mobile-web against origin/main fdabddeb4 (a git repo made in the copy from git archive, since mote-run carries no .git): 30 of 30. It now takes the new Settings › button out of the Routing page until main has it, as it does for other new rows. - go test -run 'Budget|I18n|Strings' ./internal/gui: ok. gofmt clean. Broken by hand: - the three rows back in Replies and busyLoadRow left where it was: settings-places and retry-after-cap-setting 20 of 20 red (chromium); - the Settings › button's click handler off: settings-places 10 of 10 red. Not tried: the real app; the GUI suite beyond these files runs with the rest of this audit's changes. --- docs/reference.md | 2 +- internal/gui/assets/app.js | 3 +- internal/gui/assets/index.html | 11 ++++--- .../gui/assets/plugins/gateway/settings.js | 8 +++-- internal/gui/assets/plugins/routing/client.js | 5 ++++ .../tests/classify-timeout-setting.test.cjs | 14 ++++----- internal/gui/tests/mobile-web.test.cjs | 7 +++++ internal/gui/tests/model-load.test.cjs | 8 ++--- .../tests/refusal-retries-setting.test.cjs | 14 ++++----- .../tests/retry-after-cap-setting.test.cjs | 14 ++++----- internal/gui/tests/settings-places.test.cjs | 30 ++++++++++++++++++- site/public/docs/ja/plugins.html | 2 +- site/public/docs/plugins.html | 2 +- site/public/docs/zh/plugins.html | 2 +- 14 files changed, 84 insertions(+), 38 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index 3daa3c0c0..71a8e9f7a 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2184,7 +2184,7 @@ it as above. refuses before any of it is said rests nobody: it is about what was asked, not the account. By default the same request is asked of the model's other accounts, then the routing group's other members, until one answers. -Settings › Models › Replies › *Ask again after a refusal* sets how many more +Settings › Models › Routing › *Ask again after a refusal* sets how many more are asked: 1, 2 or 3, or *Never ask again*. When nobody else is asked, an agent on Anthropic's Messages API (Claude Code) gets the refusal as the vendor said it, `stop_reason` `refusal` with its category, which Claude Code diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index ef30ea1f9..b94d84768 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -21677,7 +21677,8 @@ function renderReplies(s, keep) { const u = segRow("claudeTuiRow", t("Claude Code's interactive mode"), t("A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, a request runs as -p only when Anthropic refuses its agent's prompt there. Off runs every request as claude -p"), onOff, s.claudePrintMode ? "off" : "on", (v) => { claudeMode = null; savePrefs({ ...keep, claudePrintMode: v === "off" }); }); - box.append(r, l, f, a, k, c, u); + box.append(r, l, c, u); + $("#routeList").replaceChildren(f, a, k, $("#busyLoadRow")); } // renderDisabledModels: models turned off for every request (#1867), a row per pattern diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index 9659fe13b..27f90bafd 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -347,10 +347,6 @@
Model ids without the provider
The gateway’s model list also names each model by its own id, as gpt-5.6-sol beside codex/gpt-5.6-sol, for apps moved from another proxy. One that several providers serve goes to them in the Providers order
-
-
Busy models last
A model its plugin says is busier than this goes after the others a request could go to, as its vendor makes it wait. One with no load reported in the last 5 minutes keeps its place
-
-
Local network
@@ -367,6 +363,13 @@
Replies
+
Routing
+
+
+
Busy models last
A model its plugin says is busier than this goes after the others a request could go to, as its vendor makes it wait. One with no load reported in the last 5 minutes keeps its place
+
+
+
Disabled models
diff --git a/internal/gui/assets/plugins/gateway/settings.js b/internal/gui/assets/plugins/gateway/settings.js index d6b18d1a8..a58fc7d8f 100644 --- a/internal/gui/assets/plugins/gateway/settings.js +++ b/internal/gui/assets/plugins/gateway/settings.js @@ -1,7 +1,8 @@ // Settings › Network and sharing's gateway rows (the gateway plugin's part // of Settings): its port, model ids without the provider, sharing on the // local network and the addresses let in, and the web pages that may call -// it. Run after app.js, whose helpers it shares (el, segs, input, api, +// it; and a busy model's place, drawn into Settings › Models › Routing. +// Run after app.js, whose helpers it shares (el, segs, input, api, // writingPrefs), and before start.js draws Settings. // renderPort: the gateway's address on this computer (Magic_zero on Discord: @@ -78,13 +79,14 @@ function renderPort(s) { // lists each model by its own id as well, gpt-5.6-sol beside // codex/gpt-5.6-sol. Posted on its own; off by default. function renderBareIds(s) { - renderBusyLoad(s); // the row under it + renderBusyLoad(s); // Models › Routing's row $("#bareIdsSegs").replaceChildren(segs([[false, t("Off")], [true, t("On")]], !!s.bareModelIDs, (on) => writingPrefs(api("settings/bare-ids", { on })).then((ns) => { prefs = state.settings = ns; renderSettings(); }) .catch((e) => { status(t(e.message), "err"); renderSettings(); }))); } -// renderBusyLoad: the load past which a model its plugin says is busy +// renderBusyLoad, in Settings › Models › Routing with the other rows on +// where a request goes: the load past which a model its plugin says is busy // (magpie.load) goes behind the others (settings.BusyLoad, axelburks on // Discord). Custom… opens a field for any other number, 1 to 9999, which // is then shown as its own choice; Enter or Apply saves it, Escape closes diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index 1329bf776..c40f448fc 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -22,6 +22,7 @@ magpie.plugin("routing", (ctx) => { html: `
Routinglive, as the gateway decides +
@@ -55,6 +56,10 @@ function routingPage(part) { // the groups' way in where the header's row has no tab for them (markNav) const toGroups = $("#rtToGroups"); if (toGroups) toGroups.onclick = async () => { if (await window.show("groups")) openedFrom(toGroups); }; + // what routing does when an account refuses or every one rests, and a + // busy model's place, are set in Settings › Models › Routing + const toSet = $("#rtToSet"); + if (toSet) toSet.onclick = (e) => openSettingsAt(e, "models", "#routeList .row"); const NS = "http://www.w3.org/2000/svg"; const still = calm; const shown = () => !$("#view-routing").hidden && !document.hidden; diff --git a/internal/gui/tests/classify-timeout-setting.test.cjs b/internal/gui/tests/classify-timeout-setting.test.cjs index e7765d1f4..2bff021bb 100644 --- a/internal/gui/tests/classify-timeout-setting.test.cjs +++ b/internal/gui/tests/classify-timeout-setting.test.cjs @@ -10,11 +10,11 @@ const { reach, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const words = { - en: { name: "Intent classifier timeout", head: "Replies", sec: (n) => `${n} s`, sub: "A slow classifier may need longer" }, - zh: { name: "意图判断超时", head: "回复", sec: (n) => `${n} 秒`, sub: "较慢的判断模型可能需要更长时间" }, - "zh-TW": { name: "意圖判斷逾時", head: "回覆", sec: (n) => `${n} 秒`, sub: "較慢的判斷模型可能需要更長時間" }, - ja: { name: "インテント判定のタイムアウト", head: "応答", sec: (n) => `${n} 秒`, sub: "遅い分類モデル" }, - de: { name: "Zeitlimit für den Absicht-Klassifikator", head: "Antworten", sec: (n) => `${n} s`, sub: "Ein langsamer Klassifikator" }, + en: { name: "Intent classifier timeout", head: "Routing", sec: (n) => `${n} s`, sub: "A slow classifier may need longer" }, + zh: { name: "意图判断超时", head: "路由", sec: (n) => `${n} 秒`, sub: "较慢的判断模型可能需要更长时间" }, + "zh-TW": { name: "意圖判斷逾時", head: "路由", sec: (n) => `${n} 秒`, sub: "較慢的判斷模型可能需要更長時間" }, + ja: { name: "インテント判定のタイムアウト", head: "ルーティング", sec: (n) => `${n} 秒`, sub: "遅い分類モデル" }, + de: { name: "Zeitlimit für den Absicht-Klassifikator", head: "Weiterleitung", sec: (n) => `${n} s`, sub: "Ein langsamer Klassifikator" }, }; function serve(lang, saved, own) { @@ -54,7 +54,7 @@ async function open(engine, lang, width, saved, own, t) { await watchSettingsReads(page); await page.goto("http://magpie.test/?view=settings&tab=models"); await settingsDrawn(page); // rows found are the ones that stay (#1659) - const row = page.locator("#replyList #classifyTimeoutRow"); + const row = page.locator("#routeList #classifyTimeoutRow"); await row.waitFor(); return { page, row, errors }; } @@ -85,7 +85,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }); assert(fit, `${part} fits at ${width}`); } - assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); + assert.equal(await page.locator("#routeList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); assert.deepEqual(await row.locator(".segs button").allTextContents(), [8, 15, 30, 60].map(w.sec)); assert.equal(await row.locator(".segs button[aria-pressed=true]").textContent(), w.sec(8), "8 s at first"); diff --git a/internal/gui/tests/mobile-web.test.cjs b/internal/gui/tests/mobile-web.test.cjs index 7a17c86b4..613710757 100644 --- a/internal/gui/tests/mobile-web.test.cjs +++ b/internal/gui/tests/mobile-web.test.cjs @@ -378,6 +378,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await current.locator("#claudeTuiRow").evaluate((r) => r.remove()); await current.waitForTimeout(350); } + // The Routing page's Settings › button is new: until BASE_REF + // has it, the page is compared with the button taken out; + // settings-places.test.cjs covers it. + if (view === "routing" && !baselineFile("plugins/routing/client.js").toString().includes("rtToSet")) { + await current.locator("#rtToSet").evaluate((b) => b.remove()); + await current.waitForTimeout(350); + } // A setting row's line wraps whole (arculongus on Discord): // until BASE_REF has that, the page is compared with the lines // held to one line as they were; settings-lines-wrap.test.cjs diff --git a/internal/gui/tests/model-load.test.cjs b/internal/gui/tests/model-load.test.cjs index ecbbe29c7..b711495bc 100644 --- a/internal/gui/tests/model-load.test.cjs +++ b/internal/gui/tests/model-load.test.cjs @@ -148,7 +148,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.route("**/*", server(lang, posted)); await watchSettingsReads(page); if (!web) await page.route("**/boot.js", (r) => r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light"};` })); - await page.goto("http://magpie.test/?view=settings&tab=network"); + await page.goto("http://magpie.test/?view=settings&tab=models"); await settingsDrawn(page); const segs = page.locator("#busyLoadSegs .opt"); await segs.first().waitFor(); @@ -188,7 +188,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", page.on("pageerror", (e) => errors.push(e.message)); await page.route("**/*", server(lang, posted)); await watchSettingsReads(page); - await page.goto("http://magpie.test/?view=settings&tab=network"); + await page.goto("http://magpie.test/?view=settings&tab=models"); await settingsDrawn(page); const row = page.locator("#busyLoadRow"), sub = row.locator(".sub"), field = row.locator("input.busy-load-at"); const custom = row.locator(".opt", { hasText: w.custom }), apply = row.locator("#busyLoadSegs .val button").first(); @@ -256,7 +256,7 @@ test("a threshold past 100 set by hand is shown as picked", async (t) => { const errors = []; page.on("pageerror", (e) => errors.push(e.message)); await page.route("**/*", server("en", [], { busyLoad: 150 })); - await page.goto("http://magpie.test/?view=settings&tab=network"); + await page.goto("http://magpie.test/?view=settings&tab=models"); const segs = page.locator("#busyLoadSegs .opt"); await segs.first().waitFor(); assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["Off", "Over 50%", "Over 70%", "Over 80%", "Over 90%", "Over 150%", "Custom…"]); @@ -271,7 +271,7 @@ test("a threshold set by hand is shown as picked", async (t) => { const errors = []; page.on("pageerror", (e) => errors.push(e.message)); await page.route("**/*", server("en", [], { busyLoad: 75 })); - await page.goto("http://magpie.test/?view=settings&tab=network"); + await page.goto("http://magpie.test/?view=settings&tab=models"); const segs = page.locator("#busyLoadSegs .opt"); await segs.first().waitFor(); assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["Off", "Over 50%", "Over 70%", "Over 75%", "Over 80%", "Over 90%", "Custom…"]); diff --git a/internal/gui/tests/refusal-retries-setting.test.cjs b/internal/gui/tests/refusal-retries-setting.test.cjs index 556bd96a0..c743a252c 100644 --- a/internal/gui/tests/refusal-retries-setting.test.cjs +++ b/internal/gui/tests/refusal-retries-setting.test.cjs @@ -15,11 +15,11 @@ const { reach, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const words = { - en: { name: "Ask again after a refusal", head: "Replies", never: "Never ask again", all: "All", sub: "Claude Code then switches to its own fallback model" }, - zh: { name: "被拒答后再问", head: "回复", never: "不再问", all: "全部", sub: "Claude Code 随后会像直连 Anthropic API 时一样" }, - "zh-TW": { name: "被拒答後再問", head: "回覆", never: "不再問", all: "全部", sub: "Claude Code 隨後會像直連 Anthropic API 時一樣" }, - ja: { name: "拒否のあと聞き直す", head: "応答", never: "聞き直さない", all: "すべて", sub: "フォールバックモデルに切り替えます" }, - de: { name: "Nach einer Ablehnung erneut fragen", head: "Antworten", never: "Nie", all: "Alle", sub: "wechselt dann selbst zu seinem Ausweichmodell" }, + en: { name: "Ask again after a refusal", head: "Routing", never: "Never ask again", all: "All", sub: "Claude Code then switches to its own fallback model" }, + zh: { name: "被拒答后再问", head: "路由", never: "不再问", all: "全部", sub: "Claude Code 随后会像直连 Anthropic API 时一样" }, + "zh-TW": { name: "被拒答後再問", head: "路由", never: "不再問", all: "全部", sub: "Claude Code 隨後會像直連 Anthropic API 時一樣" }, + ja: { name: "拒否のあと聞き直す", head: "ルーティング", never: "聞き直さない", all: "すべて", sub: "フォールバックモデルに切り替えます" }, + de: { name: "Nach einer Ablehnung erneut fragen", head: "Weiterleitung", never: "Nie", all: "Alle", sub: "wechselt dann selbst zu seinem Ausweichmodell" }, }; function serve(lang, saved) { @@ -63,7 +63,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await watchSettingsReads(page); await page.goto("http://magpie.test/?view=settings&tab=models"); await settingsDrawn(page); // rows found are the ones that stay (#1659) - const row = page.locator("#replyList #refusalRetriesRow"); + const row = page.locator("#routeList #refusalRetriesRow"); await row.waitFor(); // scrolled to as a reader does, with the wheel: WebKit at 420 put // back a scroll made from script @@ -86,7 +86,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }); assert(fit, `${part} fits at ${width}`); } - assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); + assert.equal(await page.locator("#routeList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); const opts = row.locator(".segs button"); assert.deepEqual(await opts.allTextContents(), [w.never, "1", "2", "3", w.all]); const all = row.locator(".segs button", { hasText: w.all }); diff --git a/internal/gui/tests/retry-after-cap-setting.test.cjs b/internal/gui/tests/retry-after-cap-setting.test.cjs index 739f6715b..6c6e6cdfa 100644 --- a/internal/gui/tests/retry-after-cap-setting.test.cjs +++ b/internal/gui/tests/retry-after-cap-setting.test.cjs @@ -15,11 +15,11 @@ const { reach, watchSettingsReads, settingsDrawn } = require("./reader.cjs"); const assets = path.resolve(__dirname, "../assets"); const words = { - en: { name: "Longest wait an agent is told", head: "Replies", min: (n) => `${n} min`, none: "No limit", sub: "The accounts rest as long either way" }, - zh: { name: "告诉智能体的最长等待", head: "回复", min: (n) => `${n} 分钟`, none: "不限制", sub: "账号休息的时长不变" }, - "zh-TW": { name: "告訴智慧體的最長等待", head: "回覆", min: (n) => `${n} 分鐘`, none: "不限制", sub: "帳號休息的時長不變" }, - ja: { name: "エージェントに伝える最長の待ち時間", head: "応答", min: (n) => `${n} 分`, none: "上限なし", sub: "アカウントの休止時間は変わりません" }, - de: { name: "Längste Wartezeit für einen Agenten", head: "Antworten", min: (n) => `${n} min`, none: "Kein Limit", sub: "Die Konten ruhen in beiden Fällen gleich lange" }, + en: { name: "Longest wait an agent is told", head: "Routing", min: (n) => `${n} min`, none: "No limit", sub: "The accounts rest as long either way" }, + zh: { name: "告诉智能体的最长等待", head: "路由", min: (n) => `${n} 分钟`, none: "不限制", sub: "账号休息的时长不变" }, + "zh-TW": { name: "告訴智慧體的最長等待", head: "路由", min: (n) => `${n} 分鐘`, none: "不限制", sub: "帳號休息的時長不變" }, + ja: { name: "エージェントに伝える最長の待ち時間", head: "ルーティング", min: (n) => `${n} 分`, none: "上限なし", sub: "アカウントの休止時間は変わりません" }, + de: { name: "Längste Wartezeit für einen Agenten", head: "Weiterleitung", min: (n) => `${n} min`, none: "Kein Limit", sub: "Die Konten ruhen in beiden Fällen gleich lange" }, }; function serve(lang, saved) { @@ -63,7 +63,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await watchSettingsReads(page); await page.goto("http://magpie.test/?view=settings&tab=models"); await settingsDrawn(page); // rows found are the ones that stay (#1659) - const row = page.locator("#replyList #retryAfterCapRow"); + const row = page.locator("#routeList #retryAfterCapRow"); await row.waitFor(); // scrolled to as a reader does, with the wheel: WebKit at 420 put // back a scroll made from script @@ -86,7 +86,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", }); assert(fit, `${part} fits at ${width}`); } - assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); + assert.equal(await page.locator("#routeList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head); const opts = row.locator(".segs button"); assert.deepEqual(await opts.allTextContents(), [w.min(1), w.min(5), w.min(15), w.none]); const none = row.locator(".segs button", { hasText: w.none }); diff --git a/internal/gui/tests/settings-places.test.cjs b/internal/gui/tests/settings-places.test.cjs index 885a1fa2c..9872ab1db 100644 --- a/internal/gui/tests/settings-places.test.cjs +++ b/internal/gui/tests/settings-places.test.cjs @@ -2,7 +2,10 @@ // Settings' rows where their feature is (the scattered settings audit after // netube99 on X): magpie web draws no empty Menu bar cost row, as it has no // menu bar; the alerts (allowance, balance, reset, task done) sit under -// their own Alerts heading, not among the allowances' display. Every +// their own Alerts heading, not among the allowances' display; what routing +// does when an account refuses or every one rests, and a busy model's place +// (from Network), sit under Models › Routing, which the Routing page opens. +// Every // language, Chromium and WebKit, at 1100 and 420 wide, nothing past the // window's edge. No backend, the API is faked here. const assert = require("node:assert/strict"); @@ -80,6 +83,31 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.equal(await page.locator("#trayCostRow").isVisible(), false, "no Menu bar cost row in magpie web"); assert(await fits(page), "fits in magpie web"); assert.deepEqual(page.errors, []); + + // Models › Routing: the rows about where a request goes, after the + // replies' own rows, and the busy model's place out of Network + page = await open(false, "settings&tab=models"); + const rhead = page.locator("#routeList").locator("xpath=preceding-sibling::*[1]"); + await rhead.waitFor(); + assert.equal((await rhead.textContent()).trim(), await tr(page, "Routing")); + for (const id of ["refusalRetriesRow", "retryAfterCapRow", "classifyTimeoutRow", "busyLoadRow"]) { + assert.equal(await page.locator(`#routeList > #${id}`).count(), 1, id + " under Routing"); + } + assert(await page.evaluate(() => document.querySelector("#replyList").compareDocumentPosition(document.querySelector("#routeList")) & Node.DOCUMENT_POSITION_FOLLOWING), "after the replies' rows"); + assert.equal(await page.locator("#busyLoadRow").count(), 1, "one busy model row, not one in Network too"); + assert(await page.locator("#busyLoadRow").isVisible(), "shown on the Models tab"); + assert(await fits(page), "fits"); + assert.deepEqual(page.errors, []); + + // the Routing page leads there + page = await open(false, "routing"); + const go = page.locator("#rtToSet"); + await go.waitFor(); + assert.equal((await go.textContent()).trim(), (await tr(page, "Settings")) + " ›"); + assert(await fits(page), "the Routing page fits"); + await go.click(); + await page.locator("#view-settings #routeList .row.flash").waitFor(); + assert.deepEqual(page.errors, []); }); } } diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.html index 725eeac27..b74842133 100644 --- a/site/public/docs/ja/plugins.html +++ b/site/public/docs/ja/plugins.html @@ -606,7 +606,7 @@ magpie quota # acme · Pro · 5h 37%
  • 値。100 はベンダーが同時に処理できる満杯の状態で、待ち行列のあるベンダーはそれを超えて報告できます(200 はその 2 倍)。0 未満は 0、10000 超は 10000 として扱います(異常値の上限)。それ以外(文字列、NaN)は捨てられます。モデル id は大文字小文字を区別せず、model@256k は個別に報告がなければ元のモデルの負荷になります。1 回の呼び出しで最大 1000 モデルまで受け取り、受け取った数を返します。provider が文字列でない、または loads がオブジェクトでないと TypeError を投げます。
  • 鮮度。各モデルの負荷は報告した呼び出しから 5 分間有効で、その後は不明になり、0 とはみなしません。報告をやめたプラグインのモデルは元の位置のままです。呼び出しで触れなかったモデルは、自分の 5 分が切れるまで前回の負荷を保ちます。
  • 表示。プロバイダーの編集画面で、モデルの横に小さな灰色の数字で出ます。
  • -
  • ルーティング。設定 › ネットワークと共有 › 混雑しているモデルを後回しに でしきい値を選ぶと(既定はオフ。50、70、80、90% 超、または「カスタム…」で 1〜9999 の任意の数。待ち行列のあるベンダーなら 150 など)、それより混雑していると報告されたモデルは、リクエストが行ける他の候補の後ろ、失敗後に休んでいる候補の前に回ります。そのモデルが答えた会話は次のターンで先頭の候補に移り、ターンの途中では移りません。負荷が分からないモデルは元の位置のままです。ルーティングのトレースには busy と負荷が出ます。
  • +
  • ルーティング。設定 › モデル › ルーティング › 混雑しているモデルを後回しに でしきい値を選ぶと(既定はオフ。50、70、80、90% 超、または「カスタム…」で 1〜9999 の任意の数。待ち行列のあるベンダーなら 150 など)、それより混雑していると報告されたモデルは、リクエストが行ける他の候補の後ろ、失敗後に休んでいる候補の前に回ります。そのモデルが答えた会話は次のターンで先頭の候補に移り、ターンの途中では移りません。負荷が分からないモデルは元の位置のままです。ルーティングのトレースには busy と負荷が出ます。
  • 古いホスト向けのプラグインは、上の例のように先に input.magpie?.load を確かめます。

    diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.html index 04d1e9093..7ce5e905e 100644 --- a/site/public/docs/plugins.html +++ b/site/public/docs/plugins.html @@ -606,7 +606,7 @@ magpie quota # acme · Pro · 5h 37%
  • Values. 100 is as busy as the vendor serves at once; a vendor that queues reports past it (200 is twice that). A number below 0 counts as 0, and one past 10000 as 10000, a sanity cap. Anything else (a string, NaN) is dropped. Model ids match whatever their case, and model@256k has its model’s load unless reported itself. One call takes up to 1000 models and returns how many it took. A provider that isn’t a string, or a loads that isn’t an object, throws a TypeError.
  • Freshness. Each model’s load counts for five minutes from the call that reported it. After that it is unknown, never 0: a plugin that stops calling leaves its models where they were. A model a call doesn’t name keeps its last load until its own five minutes run out.
  • Where it shows. The provider editor shows it by the model, a small grey number.
  • -
  • Routing. With Settings › Network and sharing › Busy models last set (Off by default; over 50, 70, 80 or 90%, or Custom… for any number from 1 to 9999, such as 150 for a vendor that queues), a model reported busier than that goes behind every other candidate a request could go to, ahead of those resting after a failure. A conversation it answered moves to the one that leads at its next turn; within a turn it stays. A model with no load known keeps its place. The Routing trace says busy with the load.
  • +
  • Routing. With Settings › Models › Routing › Busy models last set (Off by default; over 50, 70, 80 or 90%, or Custom… for any number from 1 to 9999, such as 150 for a vendor that queues), a model reported busier than that goes behind every other candidate a request could go to, ahead of those resting after a failure. A conversation it answered moves to the one that leads at its next turn; within a turn it stays. A model with no load known keeps its place. The Routing trace says busy with the load.
  • A plugin written for older hosts checks input.magpie?.load first, as above.

    diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.html index 2fbc4f274..8108f5a3b 100644 --- a/site/public/docs/zh/plugins.html +++ b/site/public/docs/zh/plugins.html @@ -606,7 +606,7 @@ magpie quota # acme · Pro · 5h 37%
  • 取值。100 表示供应商同时能服务的满载;会排队的供应商可以报超过 100 的值(200 是满载的两倍)。小于 0 按 0 算,大于 10000 按 10000 算(防止离谱的值)。其他值(字符串、NaN)丢弃。模型 id 不区分大小写,model@256k 没单独报时用它所属模型的负载。一次最多 1000 个模型,返回收下的个数。provider 不是字符串,或 loads 不是对象,会抛出 TypeError。
  • 时效。每个模型的负载从报告它的那次调用起算五分钟有效,之后就是未知,绝不当作 0:插件不再报告时,它的模型保持原位。一次调用没提到的模型,保留上次的负载,直到它自己的五分钟到期。
  • 在哪显示。供应商编辑页里模型旁边的灰色小数字。
  • -
  • 路由。在 设置 › 网络与共享 › 繁忙的模型靠后 选了阈值(默认关闭;可选高于 50、70、80 或 90%,或选“自定义…”输入 1 到 9999 之间的任意数,比如会排队的供应商可设 150)后,报告负载高于它的模型会排到请求能去的其他候选之后,但仍在失败后休息的候选之前。它答过的对话在下一轮换到排在最前的那个;同一轮之内不换。没有已知负载的模型保持原位。路由追踪里显示 busy 和负载值。
  • +
  • 路由。在 设置 › 模型 › 路由 › 繁忙的模型靠后 选了阈值(默认关闭;可选高于 50、70、80 或 90%,或选“自定义…”输入 1 到 9999 之间的任意数,比如会排队的供应商可设 150)后,报告负载高于它的模型会排到请求能去的其他候选之后,但仍在失败后休息的候选之前。它答过的对话在下一轮换到排在最前的那个;同一轮之内不换。没有已知负载的模型保持原位。路由追踪里显示 busy 和负载值。
  • 为旧版宿主写的插件先检查 input.magpie?.load,如上例。