gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)
axelburks on Discord: a vendor that queues reports loads past 100%, and
the only way to a threshold such as 150 was settings.json. Settings ›
Network and sharing › Busy models last now ends in Custom…, one more
choice in the same in-app switch (no <select>). It opens a small field
in the row whose sub says what the number means: a load in percent as
the plugin reports it, 100 is all the vendor serves at once, past 100
requests queue (200 is twice that), 1 to 9999. Enter or Apply saves it
through settings/busy-load, Escape or Cancel closes it untouched. A
value that is not a whole number from 1 to 9999 is said in red in the
sub and nothing is posted; the field keeps it to correct. The number
saved shows as its own choice ("Over 150%"), and Custom… opens with it
filled in. The site docs (en, zh, ja) and gateway-routing.md say
Custom… instead of settings.json. Code in plugins/gateway/settings.js
and i18n.js only, so the core budget is untouched.
Run on mote at this tree:
- node --test model-load, i18n-keys, bare-ids, gateway-port: all pass.
model-load's new test runs in Chromium and WebKit, at 420 and 900, in
en, zh, zh-TW, ja and de: Custom… focuses the field, says what the
number means, refuses abc, 0, 10000, 1.5 and -3 with nothing posted,
Escape closes, 150 posts {at:150} and shows Over 150% picked, 2000 by
Enter replaces it, the row and settings don't run sideways, and no
press moves the page more than the row changed height.
- go test ./internal/gui -run Budget: ok. gofmt -l: clean.
Broken by hand: validation turned off (if (false)) went red in every
language; the Custom… entry taken out went red in the old and new
tests; the field without flex:none was squeezed to ~20px and the width
check went red.
Not tried: the real app window (only Playwright's engines), and the
full GUI and Go suites, which run after the push (one suite on mote at
a time).
This commit is contained in:
@@ -206,7 +206,7 @@ recorded as a prediction failure (`noPrediction`).
|
||||
- A turn's end is told to the app for the "Task done alert" notification (itieniu on X, `turndone.go`). The trace follows each agent session's turn (`turns`, keyed by agent and session): a request is of the turn unless it has a `Kind` or is a Claude Code subagent's (`agentTurnOf`), and its reply is scanned on the way to the agent for a tool call in any wire format (`toolScan`, a JSON value such as `"type":"tool_use"` or `"finish_reason":"tool_calls"`, never a key or text). The turn is done when no request of it is going, the last reply was whole, under 400 and called no tool, and nothing more came for `turnQuiet` (4s); a session idle past `turnStale` (30m) starts over. Only a turn that ran at least `settings.TurnDoneAlert` seconds is told (`TurnDone`, set by the GUI; nil under `magpie serve`, so nothing is followed). The ChatGPT backend path (`codexBackend`) is followed the same way. `TestTurnDoneSaidAtTheTurnsEnd`, `TestTurnDoneCodexBackend`, `TestToolScan`, `turn-done.test.cjs`.
|
||||
- A request's masking record is told to the app for the "Masking alert" notification (Must2333 on X, `OnMasked` in [`masked.go`](../../internal/gateway/masked.go), set by the GUI; nil under `magpie serve`), after `maskrec.Hold` and with its text around placeholders (`Snips`, `Back`) taken out. [`mask_alert.go`](../../internal/gui/mask_alert.go) keeps the records while `settings.MaskAlert` is on (off until turned on, in Settings → Usage, hidden with masking) and says only the values a record masked for the first time (`maskrec.Fresh`, [`first.go`](../../internal/maskrec/first.go): each placeholder by the key of the first record that had it, read from memory and the days kept, so a conversation's history sent again each turn, or after a restart, is not news; a value sent as written is not one masked). A burst is gathered for `maskGather` (3s) and said as one, and one is said at most every `maskGap` (1 minute), what came in between said after it. It says each kind with its count and up to two agents, never a value nor its hint; a click opens the Masking page on the latest record (`clickView`, `masking&key=`). A held-back request (`noteBlocked`) is not said; a value whose records have all aged out (30 days) is new again. `TestFreshOnlyTheFirstTime`, `TestMaskAlertFirstTimeOnly`, `TestMaskAlertNeverSaysTheValue`, `TestMaskAlertCoalesces`, `mask-alert.test.cjs`.
|
||||
- A resting candidate is tried last (`restLast`). Of the resting candidates, a request asks only the one whose rest ends soonest, the first in order on a tie (`probeOne`, #1799). The others aren't asked by that request, so a member that is down isn't asked by every request its rest was meant to spare it from, and a group that is down whole takes one upstream request per request, not one per member. Every ready candidate is still asked in its order. A lone candidate is tried even while it rests, because there is no other. The trace still lists every member, the resting ones with their rest. Only rests are read, and a failure about the request's content or its model rests no member (a model refusal rests only `restID`), so neither leaves a member out. The same applies in `count_tokens`, embeddings and rerank, image accounts and a group's System One decision models. A Codex reset (`autoReset`) still looks over every candidate. This is like AxonHub's error-aware load balancing: the rest and its backoff are the penalty that decays, and the member back soonest is the one asked to show it is back. Keys out of their allowance aren't asked even so, not even the one back soonest or a lone one (#1772: four Ollama Cloud keys out for the week, each asked again and refused on every request). The refusal given again says when they are asked again on this magpie's clock with its offset (`heldClock`: "20:12 UTC+8", "Oct 16 09:00 UTC+8"), as do the gateway's other held errors (a capped window, a spent searcher or describer): its reader may be a Remote magpie's user on another clock. When every candidate left is a key (not a subscription account, whose resets `autoReset` may spend) resting out of quota or credit after a 429 or 402, none is asked. The first one's refusal is given again (`quotaHeld`, its words kept in the rest's `said`), saying when it is asked again. A key whose rest magpie guessed the length of, the vendor and the user naming no time (`creditRest`, or `quotaRest` with no `Provider.OwnQuotaRest`), is held so only once it was refused so twice in a row (`Rest.first`): a single refusal may be a moment's, and the next request, the agent's retry first, asks it again (zoecats on Discord: a local aggregator said 429 `insufficient_quota` "quota exhausted" for the moment it switched upstreams, and every request was answered from its rest of 15 or 30 minutes, which only the provider's "Rests" switch, `LimitRestOff`, let through before). Held, it is asked again a minute on (`Rest.askAt`, `fallbackCooldown`), once, and held again if refused (`Rest.asksAt`); a time the vendor named, or the user set, holds it from the first refusal to then. The rest itself stays as long as before, so the order still passes it over for a candidate that is ready. The last key left rests too when it is refused so, as the keys before it do, and so does the last account left (a Codex or other subscription account; `quotaHeld` still holds keys alone, and `autoReset` lifts the rest of an account it spends a reset of): before, an account last in an in-order group, out of its quota, was never rested, so every request a relay ahead of it failed for a moment went on to it and ended on its 429 (dbydd on Discord; `TestGroupSpentLastAccountRests`). Any 429 that reaches the agent without a vendor `Retry-After`, while every candidate tried is resting, carries one: the seconds until the first of them is asked again (`soonestBack`, by `asksAt`), none after a key's first refusal. `TestRetryAfterALimitIsAsked`, `TestHeldLimitAskedAgainInAMinute`. A quota refusal with no word of when it is back rests `quotaRest` (15 minutes), or the provider's own `quotaRest` in minutes (`Provider.QuotaRestFor`, at most `MaxQuotaRest`, 8 days; `magpie provider quota-rest <id> 7d`), or until the time of day the user said its allowance comes back (`QuotaResetAt`, `Provider.OwnQuotaRest`; `magpie provider quota-rest <id> until 08:00`, or `until 00:00+08:00` on the vendor's clock; #2008, a free tier's "today's free-model token quota"). Whichever of the two was set last counts. A time the vendor names stands over it, and so does its `Retry-After`, unless that was more than `longestWait` (an hour) and so cut to it while the user's own rest is longer: then the user's stands (`TestQuotaRestsUntilTheTimeOfDaySet`). A key listed in `keys` as well as in `key` is one candidate (`KeysOn`), not asked twice. `TestAllRestingAnswersFromRest`, `TestOwnQuotaRest`, `TestQuotaHeldOnlyForKeysOutOfAllowance`, `TestFirstKeyListedTwiceAskedOnce`.
|
||||
- A model its plugin reports busier than the user's *Busy models last* (`settings.BusyLoad`, 1 to 9999 (`BusyLoadMost`-1), past 100 for a vendor that queues, off by default; axelburks on Discord) goes behind the ready candidates, ahead of the resting ones (`restLast`, `busyOf`), and its trace row has `busy` with the load. The load comes from the plugin through `plugin.ModelLoad` (see [provider plugins](provider-plugins.md#a-models-load)); one not reported in the last 5 minutes is unknown and keeps its place. A lone candidate is asked whatever its load. A conversation it answered moves, at its next turn, to the ready one that leads (`affine`'s Why `busy`, `busyBehind`); within a turn it stays. A turn going round (`after`), a new conversation spread (`readyForNew`) or In turn (`leastHeld`) never lands on it past a ready one. When every candidate is busy, nothing moves.
|
||||
- A model its plugin reports busier than the user's *Busy models last* (`settings.BusyLoad`, 1 to 9999 (`BusyLoadMost`-1), past 100 for a vendor that queues, its Custom… field taking any of them, off by default; axelburks on Discord) goes behind the ready candidates, ahead of the resting ones (`restLast`, `busyOf`), and its trace row has `busy` with the load. The load comes from the plugin through `plugin.ModelLoad` (see [provider plugins](provider-plugins.md#a-models-load)); one not reported in the last 5 minutes is unknown and keeps its place. A lone candidate is asked whatever its load. A conversation it answered moves, at its next turn, to the ready one that leads (`affine`'s Why `busy`, `busyBehind`); within a turn it stays. A turn going round (`after`), a new conversation spread (`readyForNew`) or In turn (`leastHeld`) never lands on it past a ready one. When every candidate is busy, nothing moves.
|
||||
- A key resting after an outage that names no time is asked again in the background (`rest_probe.go`, heatonz on Discord). Behind ready keys, `probeOne` never asks it before its rest ends, though its vendor may be back in a minute. `restAfterMarked` marks the rest `Probed` when it is a key's own (not an account's or a plugin's, not one model's `restID`), `failOther` by `backoff` after a 5xx, a 408 or no connection, with no Retry-After or reset header, at a provider whose `List` asks over the network (`Provider.ListAsks`), and long enough for a first ask. `keepProbingRests`, started in `ListenAndServe`, then asks the vendor's model list with that key through its proxy (`Provider.List`, which saves nothing) 1, 2, 5 and then every 10 minutes into the rest, while it is the same rest. When the list answers, the rest is lifted as Try now lifts it (`liftedLocked`, `unsink`, the trace's lift). Not asked: rate limits (a list answers while the chat endpoint still refuses, and lifting one early would undo Sink), quota, credit, a Retry-After or reset, a refused key (401, 403, 400), restrictions and verification, each of which ends on its own time or the vendor's. A key a probe lifted that fails again within 30 minutes isn't asked again until it answers a request (`probeMissed`, `probeAnswered` in `served`): the list answered for the vendor, not for its chat. Only the loop's own `Server` asks (`restProbes.asking`), so a test's `Server` never reaches the network. The cost is one list per resting key per step, never one per request. The key list (`KeyRest.Probed`) and Routing's words for the try (`restHow`) add "checked in the background, back as soon as it answers". `TestRestProbeLiftsAKeyBackUp`, `TestRestProbeLeavesOtherRests`, `TestRestProbeOnlyByARunningLoop`, `rest-probed.test.cjs`.
|
||||
- A provider whose keys are on different plans (`KeyAccount.Plan`, `PlansMixed`; yckonnnn on X) sends each key to its plan's endpoints: every key path takes its copy through `WithKey`, which moves it there (`atKeyPlan`), on the first try and on a failover alike. `perKeyBarred` leaves out a key whose plan's list lacks the model (`PlanServing`: a pay-as-you-go model id at the Agent Plan's endpoint only answers 404), not shown in the trace; only when no key's plan has it are those keys asked. Embeddings and drawing go through the same `perKeyBarred` and `WithKey`; a video started on a mixed provider names its key in the task id (`videoStart.onKey`, `keyMark`) so its poll goes to that key's plan. `TestKeyPlansEachToItsOwnEndpoint`.
|
||||
- A subscription's account whose own model list lacks the model (`Account.Lists`: an Antigravity account's `fetchAvailableModels`, a plugin account's `models`) isn't planned while another of its accounts lists it (`perKeyBarred`'s `left`, `planned.unlisted`, the Routing page's "unlisted, skipped"). It is the next asked when every account of the subscription that lists the model has been asked and one refused it as a model it doesn't serve (`unservedTry`: `modelRefused`, or Code Assist's 404 NOT_FOUND, `codeAssistModelMissing`), before any later member or fallback (`unlistedNext`, `askUnlisted` moves its row from the route's left to its order after the one that refused). A list is fetched once and can be stale: 01huadalang's Gemini 4 was served by one Antigravity account of several, and the one whose list named it refused it with a 404 the agent got while the other could answer. The one that refused rests for that model alone. Not for another refusal (a 403, a quota), a request pinned to an account, a native compaction sealed to one, or a conversation kept strictly on one; a gateway key held to some accounts narrows the unlisted ones too (`allowedCandidates`). `TestUnlistedAccountAskedAfterModelRefused`, `TestUnlistedAccountNotAskedForOtherRefusals`.
|
||||
|
||||
@@ -3258,6 +3258,8 @@ const I18N = {
|
||||
"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": "插件报告负载高于此值的模型,排在请求可去的其他模型之后,因为它的供应商会让请求排队等待。最近 5 分钟内没有报告负载的模型保持原位",
|
||||
"Over {n}%": "高于 {n}%",
|
||||
"A load is in percent, as the plugin reports it: 100 is all its vendor serves at once, and past 100 requests queue (200 is twice that). Type 1 to 9999": "负载以百分比计,由插件报告:100 表示供应商同时能处理的全部量,超过 100 表示请求在排队(200 即两倍)。输入 1 到 9999",
|
||||
"Type a whole number from 1 to 9999": "请输入 1 到 9999 之间的整数",
|
||||
"{n}% busy now, as its plugin says": "插件报告当前负载 {n}%",
|
||||
"Session terminal": "会话终端",
|
||||
"The terminal a session opens in": "打开会话时使用的终端",
|
||||
@@ -7583,6 +7585,8 @@ const I18N = {
|
||||
"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": "外掛回報負載高於此值的模型,排在請求可去的其他模型之後,因為它的供應商會讓請求排隊等待。最近 5 分鐘內沒有回報負載的模型保持原位",
|
||||
"Over {n}%": "高於 {n}%",
|
||||
"A load is in percent, as the plugin reports it: 100 is all its vendor serves at once, and past 100 requests queue (200 is twice that). Type 1 to 9999": "負載以百分比計,由外掛回報:100 表示供應商同時能處理的全部量,超過 100 表示請求在排隊(200 即兩倍)。輸入 1 到 9999",
|
||||
"Type a whole number from 1 to 9999": "請輸入 1 到 9999 之間的整數",
|
||||
"{n}% busy now, as its plugin says": "外掛回報目前負載 {n}%",
|
||||
"Session terminal": "會話終端機",
|
||||
"The terminal a session opens in": "開啟會話時使用的終端機",
|
||||
@@ -11919,6 +11923,8 @@ const I18N = {
|
||||
"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": "プラグインがこの値より混雑していると報告したモデルは、リクエストの送り先になるほかのモデルの後に回します。ベンダーの順番待ちになるためです。直近 5 分間に負荷の報告がないモデルは元の位置のままです",
|
||||
"Over {n}%": "{n}% 超",
|
||||
"A load is in percent, as the plugin reports it: 100 is all its vendor serves at once, and past 100 requests queue (200 is twice that). Type 1 to 9999": "負荷はプラグインが報告するパーセントです。100 はベンダーが同時に処理できる上限、100 を超えるとリクエストが待ち行列に入ります(200 はその 2 倍)。1〜9999 を入力",
|
||||
"Type a whole number from 1 to 9999": "1〜9999 の整数を入力してください",
|
||||
"{n}% busy now, as its plugin says": "プラグインの報告では現在 {n}% の負荷",
|
||||
"Session terminal": "セッション用ターミナル",
|
||||
"The terminal a session opens in": "セッションを開くターミナル",
|
||||
@@ -16266,6 +16272,8 @@ const I18N = {
|
||||
"Busy models last": "Ausgelastete Modelle zuletzt",
|
||||
"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": "Ein Modell, das laut seinem Plugin stärker ausgelastet ist als dieser Wert, kommt nach den anderen, an die eine Anfrage gehen könnte, da sein Anbieter sie warten lässt. Ein Modell ohne gemeldete Last in den letzten 5 Minuten behält seinen Platz",
|
||||
"Over {n}%": "Über {n} %",
|
||||
"A load is in percent, as the plugin reports it: 100 is all its vendor serves at once, and past 100 requests queue (200 is twice that). Type 1 to 9999": "Die Last in Prozent, wie das Plugin sie meldet: 100 ist alles, was der Anbieter gleichzeitig bedient, über 100 stehen Anfragen in der Warteschlange (200 ist das Doppelte). 1 bis 9999 eingeben",
|
||||
"Type a whole number from 1 to 9999": "Eine ganze Zahl von 1 bis 9999 eingeben",
|
||||
"{n}% busy now, as its plugin says": "laut seinem Plugin gerade zu {n} % ausgelastet",
|
||||
"Session terminal": "Sitzungs-Terminal",
|
||||
"The terminal a session opens in": "Das Terminal, in dem eine Sitzung öffnet",
|
||||
|
||||
@@ -86,15 +86,47 @@ function renderBareIds(s) {
|
||||
|
||||
// renderBusyLoad: the load past which a model its plugin says is busy
|
||||
// (magpie.load) goes behind the others (settings.BusyLoad, axelburks on
|
||||
// Discord); one set in settings.json to another number is shown too
|
||||
// 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
|
||||
let busyDraft = null;
|
||||
const BUSY_CUSTOM = -1;
|
||||
function renderBusyLoad(s) {
|
||||
const at = s.busyLoad || 0;
|
||||
const at = s.busyLoad || 0, sub = $("#busyLoadRow .sub"), d = busyDraft;
|
||||
const put = (n) => writingPrefs(api("settings/busy-load", { at: n })).then((ns) => { busyDraft = null; prefs = state.settings = ns; renderSettings(); })
|
||||
.catch((e) => { status(t(e.message), "err"); renderSettings(); });
|
||||
sub.dataset.en ??= sub.textContent; // its English, as translateStatic keeps it
|
||||
sub.classList.toggle("err", !!d?.err);
|
||||
sub.textContent = d ? d.err || t("A load is in percent, as the plugin reports it: 100 is all its vendor serves at once, and past 100 requests queue (200 is twice that). Type 1 to 9999") : t(sub.dataset.en);
|
||||
if (d) {
|
||||
const field = input(d.value, "150");
|
||||
field.className = "words busy-load-at";
|
||||
field.style.cssText = "width:84px;flex:none";
|
||||
field.inputMode = "numeric";
|
||||
field.setAttribute("aria-label", t("Busy models last"));
|
||||
const save = el("button", "text", t("Apply")), no = el("button", "text", t("Cancel"));
|
||||
const close = () => { busyDraft = null; renderBusyLoad(s); };
|
||||
save.onclick = () => {
|
||||
const v = field.value.trim(), n = Number(v);
|
||||
if (!/^\d+$/.test(v) || n < 1 || n > 9999) { busyDraft = { value: field.value, err: t("Type a whole number from 1 to 9999") }; renderBusyLoad(s); return $("#busyLoadRow .busy-load-at").focus(NO_SCROLL); }
|
||||
save.disabled = true;
|
||||
put(n);
|
||||
};
|
||||
no.onclick = close;
|
||||
field.oninput = () => { d.value = field.value; };
|
||||
field.onkeydown = (e) => { e.stopPropagation(); if (e.key === "Enter") save.onclick(); if (e.key === "Escape") close(); };
|
||||
const val = el("div", "val");
|
||||
val.append(field, save, no);
|
||||
return $("#busyLoadSegs").replaceChildren(val);
|
||||
}
|
||||
const opts = [0, 50, 70, 80, 90];
|
||||
if (!opts.includes(at)) opts.push(at);
|
||||
opts.sort((a, b) => a - b);
|
||||
$("#busyLoadSegs").replaceChildren(segs(opts.map((n) => [n, n ? t("Over {n}%", { n }) : t("Off")]), at, (n) =>
|
||||
writingPrefs(api("settings/busy-load", { at: n })).then((ns) => { prefs = state.settings = ns; renderSettings(); })
|
||||
.catch((e) => { status(t(e.message), "err"); renderSettings(); })));
|
||||
$("#busyLoadSegs").replaceChildren(segs([...opts.map((n) => [n, n ? t("Over {n}%", { n }) : t("Off")]), [BUSY_CUSTOM, t("Custom…")]], at, (n) => {
|
||||
if (n !== BUSY_CUSTOM) return put(n);
|
||||
busyDraft = { value: [0, 50, 70, 80, 90].includes(at) ? "" : String(at), err: "" };
|
||||
renderBusyLoad(s);
|
||||
$("#busyLoadRow .busy-load-at").focus(NO_SCROLL);
|
||||
}));
|
||||
}
|
||||
|
||||
// renderCORS: the web pages whose scripts may call the gateway from a
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
// what it is; a model with no load reported shows none. And Settings ›
|
||||
// Network and sharing › Busy models last: Off by default, a threshold
|
||||
// posted on its own as settings/busy-load, one set in settings.json to
|
||||
// another number shown as picked, no click scrolling the page. Every
|
||||
// another number shown as picked, no click scrolling the page; Custom…
|
||||
// opens a field for 1 to 9999 that says what the number means, refuses
|
||||
// anything else without posting, and the number saved shows as its own
|
||||
// choice. Every
|
||||
// language, Chromium and WebKit, at a narrow and a wide window; no
|
||||
// backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -76,11 +79,11 @@ function server(lang, posted, over = {}) {
|
||||
}
|
||||
|
||||
const want = {
|
||||
en: { busy: "87% busy now, as its plugin says", queued: "180% busy now, as its plugin says", idle: "0% busy now, as its plugin says", name: "Busy models last", off: "Off", over: (n) => `Over ${n}%`, sub: "last 5 minutes" },
|
||||
zh: { busy: "插件报告当前负载 87%", queued: "插件报告当前负载 180%", idle: "插件报告当前负载 0%", name: "繁忙的模型靠后", off: "关闭", over: (n) => `高于 ${n}%`, sub: "5 分钟" },
|
||||
"zh-TW": { busy: "外掛回報目前負載 87%", queued: "外掛回報目前負載 180%", idle: "外掛回報目前負載 0%", name: "繁忙的模型靠後", off: "關閉", over: (n) => `高於 ${n}%`, sub: "5 分鐘" },
|
||||
ja: { busy: "プラグインの報告では現在 87% の負荷", queued: "プラグインの報告では現在 180% の負荷", idle: "プラグインの報告では現在 0% の負荷", name: "混雑しているモデルを後回しに", off: "オフ", over: (n) => `${n}% 超`, sub: "5 分間" },
|
||||
de: { busy: "laut seinem Plugin gerade zu 87 % ausgelastet", queued: "laut seinem Plugin gerade zu 180 % ausgelastet", idle: "laut seinem Plugin gerade zu 0 % ausgelastet", name: "Ausgelastete Modelle zuletzt", off: "Aus", over: (n) => `Über ${n} %`, sub: "5 Minuten" },
|
||||
en: { busy: "87% busy now, as its plugin says", queued: "180% busy now, as its plugin says", idle: "0% busy now, as its plugin says", name: "Busy models last", off: "Off", over: (n) => `Over ${n}%`, sub: "last 5 minutes", custom: "Custom…", explain: "200 is twice", refused: "whole number from 1 to 9999" },
|
||||
zh: { busy: "插件报告当前负载 87%", queued: "插件报告当前负载 180%", idle: "插件报告当前负载 0%", name: "繁忙的模型靠后", off: "关闭", over: (n) => `高于 ${n}%`, sub: "5 分钟", custom: "自定义…", explain: "200 即两倍", refused: "1 到 9999 之间的整数" },
|
||||
"zh-TW": { busy: "外掛回報目前負載 87%", queued: "外掛回報目前負載 180%", idle: "外掛回報目前負載 0%", name: "繁忙的模型靠後", off: "關閉", over: (n) => `高於 ${n}%`, sub: "5 分鐘", custom: "自訂…", explain: "200 即兩倍", refused: "1 到 9999 之間的整數" },
|
||||
ja: { busy: "プラグインの報告では現在 87% の負荷", queued: "プラグインの報告では現在 180% の負荷", idle: "プラグインの報告では現在 0% の負荷", name: "混雑しているモデルを後回しに", off: "オフ", over: (n) => `${n}% 超`, sub: "5 分間", custom: "カスタム…", explain: "200 はその 2 倍", refused: "1〜9999 の整数" },
|
||||
de: { busy: "laut seinem Plugin gerade zu 87 % ausgelastet", queued: "laut seinem Plugin gerade zu 180 % ausgelastet", idle: "laut seinem Plugin gerade zu 0 % ausgelastet", name: "Ausgelastete Modelle zuletzt", off: "Aus", over: (n) => `Über ${n} %`, sub: "5 Minuten", custom: "Eigener…", explain: "200 ist das Doppelte", refused: "ganze Zahl von 1 bis 9999" },
|
||||
};
|
||||
const view = (page) => page.locator("#view-settings").evaluate((v) => v.scrollTop);
|
||||
|
||||
@@ -150,7 +153,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(await row.isVisible(), "the row is drawn");
|
||||
assert.equal((await row.locator(".name").textContent()).trim(), w.name);
|
||||
assert((await row.locator(".sub").textContent()).includes(w.sub), "the sub says how long a load counts");
|
||||
assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), [w.off, w.over(50), w.over(70), w.over(80), w.over(90)]);
|
||||
assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), [w.off, w.over(50), w.over(70), w.over(80), w.over(90), w.custom]);
|
||||
assert.equal(await segs.nth(0).evaluate((b) => b.classList.contains("on")), true, "off by default");
|
||||
assert.equal(await row.locator("select").count(), 0, "no native select");
|
||||
assert(await page.locator("#view-settings").evaluate((v) => v.scrollWidth <= v.clientWidth + 1), "the settings scroll sideways");
|
||||
@@ -170,6 +173,72 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await view(page), before, "the click scrolled the page");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${width} ${lang}: a custom threshold is typed in`, async (t) => {
|
||||
const page = await open(engine, width, t, `${lang}-busy-custom`);
|
||||
const errors = [], posted = [];
|
||||
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 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();
|
||||
// a press on what is in sight moves the page no more than the row
|
||||
// grew or shrank by (its sub says more while the field is open):
|
||||
// wheeled to first, so Playwright's own scrolling isn't counted
|
||||
const still = async (what, target, act, done) => {
|
||||
await wheelTo(page, target, 160);
|
||||
const h0 = (await row.boundingBox()).height, v0 = await view(page);
|
||||
await act();
|
||||
await done();
|
||||
await page.waitForTimeout(150);
|
||||
const h1 = (await row.boundingBox()).height, v1 = await view(page);
|
||||
assert(Math.abs(v1 - v0) <= Math.abs(h1 - h0) + 2, `${what} scrolled the page: ${v0} to ${v1}, the row ${h0} to ${h1}`);
|
||||
};
|
||||
await still("Custom…", custom, () => custom.click(), () => field.waitFor());
|
||||
assert(await field.evaluate((f) => document.activeElement === f), "the field takes the keys");
|
||||
assert((await sub.textContent()).includes(w.explain), "the sub says what the number means");
|
||||
assert.equal(await row.locator("select").count(), 0, "no native select");
|
||||
const fits = async (what) => {
|
||||
const rb = await row.boundingBox(), sb = await page.locator("#busyLoadSegs").boundingBox();
|
||||
assert(sb.x + sb.width <= rb.x + rb.width + 1 && sb.x >= rb.x - 1, `${what} runs out of its row`);
|
||||
assert(await page.locator("#view-settings").evaluate((v) => v.scrollWidth <= v.clientWidth + 1), "the settings scroll sideways");
|
||||
};
|
||||
await fits("the field");
|
||||
// wide enough for the four digits it takes
|
||||
assert((await field.boundingBox()).width >= 60, "the field is squeezed");
|
||||
for (const bad of ["abc", "0", "10000", "1.5", "-3"]) {
|
||||
await wheelTo(page, field, 160);
|
||||
await field.fill(bad);
|
||||
await field.press("Enter");
|
||||
await sub.filter({ hasText: w.refused }).waitFor();
|
||||
assert(await sub.evaluate((s) => s.classList.contains("err")), `${bad}: said as an error`);
|
||||
assert.equal(await field.inputValue(), bad, `${bad}: kept to correct`);
|
||||
}
|
||||
await page.waitForTimeout(200);
|
||||
assert.deepEqual(posted, [], "a refused number is posted");
|
||||
// Escape closes it untouched, the choices back as they were
|
||||
await field.press("Escape");
|
||||
await row.locator(".opt.on", { hasText: w.off }).waitFor();
|
||||
assert.deepEqual(posted, []);
|
||||
await still("Custom…", custom, () => custom.click(), () => field.waitFor());
|
||||
await field.fill("150");
|
||||
await still("Apply", apply, () => apply.click(), () => row.locator(".opt.on", { hasText: w.over(150) }).waitFor());
|
||||
assert.deepEqual(posted, [["busy-load", { at: 150 }]]);
|
||||
assert.deepEqual((await row.locator(".opt").allTextContents()).map((s) => s.trim()), [w.off, w.over(50), w.over(70), w.over(80), w.over(90), w.over(150), w.custom]);
|
||||
assert((await sub.textContent()).includes(w.sub), "the sub is back");
|
||||
assert(!(await sub.evaluate((s) => s.classList.contains("err"))), "no error left");
|
||||
await fits("the switch");
|
||||
// the custom value opens again in the field to change it
|
||||
await still("Custom…", custom, () => custom.click(), () => field.waitFor());
|
||||
assert.equal(await field.inputValue(), "150");
|
||||
await field.fill("2000");
|
||||
await field.press("Enter");
|
||||
await row.locator(".opt.on", { hasText: w.over(2000) }).waitFor();
|
||||
assert.deepEqual(posted, [["busy-load", { at: 150 }], ["busy-load", { at: 2000 }]]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +251,7 @@ test("a threshold past 100 set by hand is shown as picked", async (t) => {
|
||||
await page.goto("http://magpie.test/?view=settings&tab=network");
|
||||
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%"]);
|
||||
assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["Off", "Over 50%", "Over 70%", "Over 80%", "Over 90%", "Over 150%", "Custom…"]);
|
||||
assert.equal((await page.locator("#busyLoadSegs .opt.on").textContent()).trim(), "Over 150%");
|
||||
const rb = await page.locator("#busyLoadRow").boundingBox(), sb = await page.locator("#busyLoadSegs").boundingBox();
|
||||
assert(sb.x + sb.width <= rb.x + rb.width + 1, "the switch runs out of its row");
|
||||
@@ -197,7 +266,7 @@ test("a threshold set by hand is shown as picked", async (t) => {
|
||||
await page.goto("http://magpie.test/?view=settings&tab=network");
|
||||
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%"]);
|
||||
assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), ["Off", "Over 50%", "Over 70%", "Over 75%", "Over 80%", "Over 90%", "Custom…"]);
|
||||
assert.equal((await page.locator("#busyLoadSegs .opt.on").textContent()).trim(), "Over 75%");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
@@ -592,7 +592,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
|
||||
<li><b>値。</b>100 はベンダーが同時に処理できる満杯の状態で、待ち行列のあるベンダーはそれを超えて報告できます(200 はその 2 倍)。0 未満は 0、10000 超は 10000 として扱います(異常値の上限)。それ以外(文字列、<code>NaN</code>)は捨てられます。モデル id は大文字小文字を区別せず、<code>model@256k</code> は個別に報告がなければ元のモデルの負荷になります。1 回の呼び出しで最大 1000 モデルまで受け取り、受け取った数を返します。provider が文字列でない、または <code>loads</code> がオブジェクトでないと <code>TypeError</code> を投げます。</li>
|
||||
<li><b>鮮度。</b>各モデルの負荷は報告した呼び出しから 5 分間有効で、その後は不明になり、0 とはみなしません。報告をやめたプラグインのモデルは元の位置のままです。呼び出しで触れなかったモデルは、自分の 5 分が切れるまで前回の負荷を保ちます。</li>
|
||||
<li><b>表示。</b>プロバイダーの編集画面で、モデルの横に小さな灰色の数字で出ます。</li>
|
||||
<li><b>ルーティング。</b>設定 › ネットワークと共有 › 混雑しているモデルを後回しに でしきい値を選ぶと(既定はオフ。50、70、80、90% 超、または settings.json の <code>busyLoad</code> に 1〜9999。待ち行列のあるベンダーなら 150 など)、それより混雑していると報告されたモデルは、リクエストが行ける他の候補の後ろ、失敗後に休んでいる候補の前に回ります。そのモデルが答えた会話は次のターンで先頭の候補に移り、ターンの途中では移りません。負荷が分からないモデルは元の位置のままです。ルーティングのトレースには <code>busy</code> と負荷が出ます。</li>
|
||||
<li><b>ルーティング。</b>設定 › ネットワークと共有 › 混雑しているモデルを後回しに でしきい値を選ぶと(既定はオフ。50、70、80、90% 超、または「カスタム…」で 1〜9999 の任意の数。待ち行列のあるベンダーなら 150 など)、それより混雑していると報告されたモデルは、リクエストが行ける他の候補の後ろ、失敗後に休んでいる候補の前に回ります。そのモデルが答えた会話は次のターンで先頭の候補に移り、ターンの途中では移りません。負荷が分からないモデルは元の位置のままです。ルーティングのトレースには <code>busy</code> と負荷が出ます。</li>
|
||||
</ul>
|
||||
<p>古いホスト向けのプラグインは、上の例のように先に <code>input.magpie?.load</code> を確かめます。</p>
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
|
||||
<li><b>Values.</b> 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, <code>NaN</code>) is dropped. Model ids match whatever their case, and <code>model@256k</code> 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 <code>loads</code> that isn’t an object, throws a <code>TypeError</code>.</li>
|
||||
<li><b>Freshness.</b> 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.</li>
|
||||
<li><b>Where it shows.</b> The provider editor shows it by the model, a small grey number.</li>
|
||||
<li><b>Routing.</b> With Settings › Network and sharing › Busy models last set (Off by default; over 50, 70, 80 or 90%, or <code>busyLoad</code> in settings.json 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 <code>busy</code> with the load.</li>
|
||||
<li><b>Routing.</b> 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 <code>busy</code> with the load.</li>
|
||||
</ul>
|
||||
<p>A plugin written for older hosts checks <code>input.magpie?.load</code> first, as above.</p>
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ magpie quota <span class="c"># acme · Pro · 5h 37%
|
||||
<li><b>取值。</b>100 表示供应商同时能服务的满载;会排队的供应商可以报超过 100 的值(200 是满载的两倍)。小于 0 按 0 算,大于 10000 按 10000 算(防止离谱的值)。其他值(字符串、<code>NaN</code>)丢弃。模型 id 不区分大小写,<code>model@256k</code> 没单独报时用它所属模型的负载。一次最多 1000 个模型,返回收下的个数。provider 不是字符串,或 <code>loads</code> 不是对象,会抛出 <code>TypeError</code>。</li>
|
||||
<li><b>时效。</b>每个模型的负载从报告它的那次调用起算五分钟有效,之后就是未知,绝不当作 0:插件不再报告时,它的模型保持原位。一次调用没提到的模型,保留上次的负载,直到它自己的五分钟到期。</li>
|
||||
<li><b>在哪显示。</b>供应商编辑页里模型旁边的灰色小数字。</li>
|
||||
<li><b>路由。</b>在 设置 › 网络与共享 › 繁忙的模型靠后 选了阈值(默认关闭;可选高于 50、70、80 或 90%,或在 settings.json 里把 <code>busyLoad</code> 设为 1 到 9999,比如会排队的供应商可设 150)后,报告负载高于它的模型会排到请求能去的其他候选之后,但仍在失败后休息的候选之前。它答过的对话在下一轮换到排在最前的那个;同一轮之内不换。没有已知负载的模型保持原位。路由追踪里显示 <code>busy</code> 和负载值。</li>
|
||||
<li><b>路由。</b>在 设置 › 网络与共享 › 繁忙的模型靠后 选了阈值(默认关闭;可选高于 50、70、80 或 90%,或选“自定义…”输入 1 到 9999 之间的任意数,比如会排队的供应商可设 150)后,报告负载高于它的模型会排到请求能去的其他候选之后,但仍在失败后休息的候选之前。它答过的对话在下一轮换到排在最前的那个;同一轮之内不换。没有已知负载的模型保持原位。路由追踪里显示 <code>busy</code> 和负载值。</li>
|
||||
</ul>
|
||||
<p>为旧版宿主写的插件先检查 <code>input.magpie?.load</code>,如上例。</p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user