diff --git a/internal/cli/groups_cli.go b/internal/cli/groups_cli.go index a99942cda..3608f8a88 100644 --- a/internal/cli/groups_cli.go +++ b/internal/cli/groups_cli.go @@ -104,7 +104,8 @@ const groupUsage = `usage: order the first model until it can't answer, then the next drain one account or key until it is used up, then the next, and stays there: an earlier one that renews meanwhile doesn't take the requests back - rotate each conversation's next turn goes to the next member's account or key + rotate each message you send goes to the next member's account or key, its tool calls + staying with it; with stays=session a whole conversation stays on one usage the account or key with the most of its allowance left first pace the account with the most of its week left per hour until it renews first, so less of a week is lost at its reset diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 44fbe88c4..2946c1df5 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -3679,6 +3679,19 @@ body:not(.side-nav) #addSheet > .row-head.stuck::before { box-shadow: 0 1px 0 va /* a provider's Routing and Stays, with "unsaved" beside a pick not saved yet */ .route-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; } .route-pick > .hint { margin: 0; } +/* In turn, drawn (app.js rotateFigure): quiet greys from the theme's own + tokens, an account told by its letter and its shade */ +.rot-wrap { margin-top: 8px; max-width: 100%; overflow-x: auto; } +.rot-fig { display: block; max-width: 100%; height: auto; font-family: var(--font); } +.rot-fig .rot-track { fill: var(--card-2); stroke: var(--line); } +.rot-fig .rot-link { stroke: var(--line); stroke-width: 1.5; } +.rot-fig .rot-l { font-size: 9px; font-weight: 600; fill: var(--card); } +.rot-fig .rot-l.rot-c { fill: var(--fg); } +.rot-fig .rot-acct.rot-a, .rot-fig .rot-call.rot-a { fill: var(--fg-2); } +.rot-fig .rot-acct.rot-b, .rot-fig .rot-call.rot-b { fill: var(--muted); } +.rot-fig .rot-acct.rot-c, .rot-fig .rot-call.rot-c { fill: var(--faint); } +.rot-fig .rot-key { fill: none; stroke: var(--muted); } +.rot-fig .rot-legend { font-size: 9.5px; fill: var(--muted); } .thumb.still { transition: none; } .link { font-size: 12px; color: var(--accent); padding: 3px 4px; white-space: nowrap; } .link:hover { text-decoration: underline; text-underline-offset: 2px; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index b88376dea..0898864a9 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -12196,13 +12196,18 @@ const ROUTINGS = [ // dzxx0496 on Discord: free accounts one after another, the first not // taking the requests back once it renews (routes.Drain) ["drain", "Until used up", "Requests stay on one until it is used up, then go to the next in the list and stay there: one before it that renews meanwhile doesn't take them back. One rate limited or failing is passed over while it rests, and requests come back to it after."], - ["rotate", "In turn", "Each turn of a conversation goes to the next one, spreading the load evenly; the requests within a turn stay where it began, so the prompt cache holds, and one that fails is passed over while it rests."], + // the unit that goes round is the user's message (affine's "new-turn"), + // not a session (Wing8Aqua on X) + ["rotate", "In turn", "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead."], ["usage", "Least used first", "Each request goes to the one used least: a subscription by the share of its allowance used, a key by the tokens it served in the last hours."], ["pace", "Use before expiry", "Each request goes to the subscription with the most left per hour until it is lost, at its reset or as credits expire; one at 90% of its five hours waits until the others can't answer, a week at 90% is still spent before its reset. A key goes by the tokens it served in the last hours."], ["weight", "By weight", "Requests spread over the keys or accounts by the weight set beside each: one weighing 3 takes three requests for every one weighing 1 takes, evenly over a few requests. One that fails is passed over while it rests, and the others share its requests; a conversation stays with it as Stays says."], ["free", "Free first", "Requests go to what costs nothing first: the models their vendor serves at no cost to this subscription's allowance or credits, in their listed order, and only when those can't answer to one that spends them. Nothing that cost nothing is left unused."], ["fast", "Speed first", "Requests go to the one that has answered this model fastest lately, by its time to the first token and how fast it writes; those within a tenth of each other keep their listed order. One not measured lately gets one request in five, so it is measured again, and one that fails is passed over while it rests."], ]; +// drawRotFig shows In turn's figure (rotfig.js, imported when first +// drawn) in box while on, as Stays has it; off, the box is hidden and empty +const drawRotFig = (b, on, a) => (b.hidden = !on) ? b.replaceChildren() : (drawRotFig.p ||= import("./rotfig.js")).then(() => b.hidden || b.replaceChildren(rotateFigure(a))); // the routings besides Smart are the built-in plugin rotation's // (plugins/rotation): off, their options leave the page (data-feature), // and Smart is left — one in use keeps it on @@ -12295,9 +12300,12 @@ function renderRouting(p) { return u; }; const rHint = el("div", "hint expl"), rUnsaved = unsaved(); + // In turn drawn under its words, as Stays has it + const rFig = el("div", "rot-wrap"), drawFig = () => drawRotFig(rFig, routingNow() === "rotate", affinityNow()); const drawRouting = () => { const cur = routingsOf(p).find(([id]) => id === routingNow()) || ROUTINGS[0]; rHint.textContent = (ROUTINGS.includes(cur) ? t(cur[2]) : cur[2]) + own(cur[0]); + drawFig(); rUnsaved.hidden = routingNow() === (p.routing || ""); // in turn and by weight go round already kLabel.hidden = kWrap.hidden = routingNow() === "rotate" || routingNow() === "weight"; @@ -12308,7 +12316,7 @@ function renderRouting(p) { const rRow = el("div", "route-pick"); rRow.append(rPick, rUnsaved); const rWrap = el("div", "fld"); - rWrap.append(rRow, rHint); + rWrap.append(rRow, rHint, rFig); const kHint = el("div", "hint expl"), kUnsaved = unsaved(); const drawSink = () => { kHint.textContent = t(SINKS[sinkNow() ? 1 : 0][2]); @@ -12325,6 +12333,7 @@ function renderRouting(p) { const cur = STAYS.find(([id]) => id === affinityNow()) || STAYS[0]; sHint.textContent = t(cur[2]); sUnsaved.hidden = affinityNow() === (p.affinity || ""); + drawFig(); }; const sPick = segs(STAYS.map(([id, name]) => [id, t(name)]), affinityNow(), (affinity) => { draft.affinity = affinity; drawStays(); }); const sRow = el("div", "route-pick"); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 748a0a9cc..c92542bad 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -2223,7 +2223,7 @@ const I18N = { "Weight {n}": "权重 {n}", "{key} weighs {n}": "{key} 的权重已设为 {n}", "Requests go to the first; the next takes over when the one before runs out of quota, hits a rate limit or fails.": "请求先发给第一个;它额度用完、被限流或出错时,由下一个接手。", - "Each turn of a conversation goes to the next one, spreading the load evenly; the requests within a turn stay where it began, so the prompt cache holds, and one that fails is passed over while it rests.": "会话每一轮轮流交给下一个,均摊负载;同一轮内的请求留在起始处,保持提示词缓存;出错的在暂停期间跳过。", + "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "你每发一条消息,就按列表顺序交给下一个;Agent 为这条消息做的工具调用留在同一个上。每换一次会损失部分提示词缓存;会话保持选「整个会话」时,改为整个会话固定在一个上。", "Each request goes to the one used least: a subscription by the share of its allowance used, a key by the tokens it served in the last hours.": "每个请求发给用量最少的:订阅看已用额度比例,密钥看最近几小时经它的 token 数。", "Use before expiry": "到期前用完", "Each request goes to the subscription with the most left per hour until it is lost, at its reset or as credits expire; one at 90% of its five hours waits until the others can't answer, a week at 90% is still spent before its reset. A key goes by the tokens it served in the last hours.": "每个请求发给剩余额度 ÷ 距作废小时数最高的订阅——周额度在重置时作废,更早过期的积分按过期时间算;5 小时额度用到 90% 以上的,等其他都无法响应时才用,周额度用到 90% 的仍会在重置前用掉。密钥按最近几小时处理的 token 数排序。", @@ -3737,6 +3737,7 @@ const I18N = { "{n} messages": "{n} 条消息", "Length": "时长", "Tool calls": "工具调用", + "Your message": "你的消息", "Tool use": "Tool 使用", "Other": "其他", "+{n} more": "还有 {n} 个", @@ -7373,7 +7374,7 @@ const I18N = { "Weight {n}": "權重 {n}", "{key} weighs {n}": "{key} 的權重已設為 {n}", "Requests go to the first; the next takes over when the one before runs out of quota, hits a rate limit or fails.": "請求先發給第一個;它額度用完、被限流或出錯時,由下一個接手。", - "Each turn of a conversation goes to the next one, spreading the load evenly; the requests within a turn stay where it began, so the prompt cache holds, and one that fails is passed over while it rests.": "會話每一輪輪流交給下一個,均攤負載;同一輪內的請求留在起始處,保持提示詞快取;出錯的在暫停期間跳過。", + "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "你每發一則訊息,就按清單順序交給下一個;Agent 為這則訊息做的工具呼叫留在同一個上。每換一次會損失部分提示詞快取;會話保持選「整個會話」時,改為整個會話固定在一個上。", "Each request goes to the one used least: a subscription by the share of its allowance used, a key by the tokens it served in the last hours.": "每個請求發給用量最少的:訂閱看已用額度比例,金鑰看最近幾小時經它的 token 數。", "Use before expiry": "到期前用完", "Each request goes to the subscription with the most left per hour until it is lost, at its reset or as credits expire; one at 90% of its five hours waits until the others can't answer, a week at 90% is still spent before its reset. A key goes by the tokens it served in the last hours.": "每個請求發給剩餘額度 ÷ 距作廢小時數最高的訂閱——週額度在重置時作廢,更早過期的點數按過期時間算;5 小時額度用到 90% 以上的,等其他都無法回應時才用,週額度用到 90% 的仍會在重置前用掉。金鑰按最近幾小時處理的 token 數排序。", @@ -8877,6 +8878,7 @@ const I18N = { "{n} messages": "{n} 條訊息", "Length": "時長", "Tool calls": "工具呼叫", + "Your message": "你的訊息", "Tool use": "Tool 使用", "Other": "其他", "+{n} more": "還有 {n} 個", @@ -12499,7 +12501,7 @@ const I18N = { "Weight {n}": "重み {n}", "{key} weighs {n}": "{key} の重みを {n} にしました", "Requests go to the first; the next takes over when the one before runs out of quota, hits a rate limit or fails.": "リクエストは最初のものに送られます。クォータ切れ、レート制限、エラーのときは次のものが引き継ぎます。", - "Each turn of a conversation goes to the next one, spreading the load evenly; the requests within a turn stay where it began, so the prompt cache holds, and one that fails is passed over while it rests.": "会話のターンごとに次のものへ送り、負荷を均等に分散します。ターン内のリクエストは開始した場所に留まるのでプロンプトキャッシュが効きます。エラーになったものは休止中スキップされます。", + "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "メッセージを送るたびに、リストの順で次のものへ回します。そのメッセージのためのエージェントのツール呼び出しは同じものに残ります。移るたびにプロンプトキャッシュの一部を失います。維持を「セッション」にすると、会話全体が一つに留まります。", "Each request goes to the one used least: a subscription by the share of its allowance used, a key by the tokens it served in the last hours.": "各リクエストは使用量が最も少ないものに送られます。サブスクリプションは利用枠の使用割合、キーは直近数時間に処理したトークン数で判断します。", "Use before expiry": "期限前に使い切る", "Each request goes to the subscription with the most left per hour until it is lost, at its reset or as credits expire; one at 90% of its five hours waits until the others can't answer, a week at 90% is still spent before its reset. A key goes by the tokens it served in the last hours.": "各リクエストは、失われるまでの1時間あたりの残りが最も多いサブスクリプションに送られます — 週の枠はリセットで、それより早く期限切れになるクレジットはその期限で失われるため、リセットや期限切れで無駄になる分を減らします。5 時間枠を 90% 以上使用したものは他が応答できないときまで待機しますが、週の枠が 90% のものはリセット前に使い切ります。キーは直近数時間に処理したトークン数で判断します。", @@ -14025,6 +14027,7 @@ const I18N = { "{n} messages": "{n} 件のメッセージ", "Length": "長さ", "Tool calls": "ツール呼び出し", + "Your message": "送ったメッセージ", "Tool use": "ツールの使用", "Other": "その他", "+{n} more": "ほか {n} 件", @@ -17656,7 +17659,7 @@ const I18N = { "Weight {n}": "Gewicht {n}", "{key} weighs {n}": "{key} hat jetzt Gewicht {n}", "Requests go to the first; the next takes over when the one before runs out of quota, hits a rate limit or fails.": "Anfragen gehen an das erste; das nächste übernimmt, wenn das vorherige kein Kontingent mehr hat, ein Rate-Limit erreicht oder fehlschlägt.", - "Each turn of a conversation goes to the next one, spreading the load evenly; the requests within a turn stay where it began, so the prompt cache holds, and one that fails is passed over while it rests.": "Jede Runde eines Gesprächs geht an das nächste, damit sich die Last gleichmäßig verteilt; die Anfragen einer Runde bleiben dort, wo sie begann, damit der Prompt-Cache greift, und ein fehlgeschlagenes wird übersprungen, solange es pausiert.", + "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "Jede Nachricht, die Sie senden, geht an den nächsten in der Liste, reihum; die Tool-Aufrufe des Agenten dazu bleiben beim selben. Jeder Wechsel kostet etwas Prompt-Cache; mit Bleibt auf Sitzung bleibt eine ganze Unterhaltung bei einem.", "Each request goes to the one used least: a subscription by the share of its allowance used, a key by the tokens it served in the last hours.": "Jede Anfrage geht an das am wenigsten genutzte: ein Abo nach dem verbrauchten Anteil seines Kontingents, ein Schlüssel nach den Token, die er in den letzten Stunden geliefert hat.", "Use before expiry": "Vor Ablauf aufbrauchen", "Each request goes to the subscription with the most left per hour until it is lost, at its reset or as credits expire; one at 90% of its five hours waits until the others can't answer, a week at 90% is still spent before its reset. A key goes by the tokens it served in the last hours.": "Jede Anfrage geht an das Abo mit dem meisten Rest pro Stunde, bis er verfällt — seine Woche beim Reset oder Guthaben darin, das früher abläuft —, damit weniger durch Resets und Ablauf verfällt; eines mit 90 % oder mehr seiner fünf Stunden wartet, bis die anderen nicht antworten können, eine Woche bei 90 % wird dagegen vor ihrem Reset noch aufgebraucht. Ein Schlüssel richtet sich nach den Token, die er in den letzten Stunden geliefert hat.", @@ -19182,6 +19185,7 @@ const I18N = { "{n} messages": "{n} Nachrichten", "Length": "Länge", "Tool calls": "Tool-Aufrufe", + "Your message": "Ihre Nachricht", "Tool use": "Tool-Nutzung", "Other": "Sonstige", "+{n} more": "+{n} weitere", diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index 576d113ed..a366a82fa 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -633,7 +633,8 @@ function routingPage(part) { "": ["Smart", "Smart: of the accounts with quota to spare, the one whose allowance renews soonest goes first — what it has left would be lost at the reset. The week decides; an account with five hours and no week goes by its five hours, and one whose month its weeks can no longer use up before it renews by its week. One at 90% or more waits until the others can't answer; one resting after a failure goes last."], order: ["In order", "In order: the first answers everything until it can't; then the next."], drain: ["Until used up", "Until used up: one answers everything until its quota is used up; then the next, which keeps them even after the one before renews."], - rotate: ["In turn", "In turn: each conversation's next turn goes to the account after the one that answered its last, and a new conversation starts one further along; the requests within a turn stay put, keeping the prompt cache."], + // the unit that goes round is the user's message (Wing8Aqua on X) + rotate: ["In turn", "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead."], usage: ["Least used", "Least used first: the account with the most of its allowance left goes first; a key by the tokens magpie sent it lately."], pace: ["Use before expiry", "Use before expiry: the account with the most left per hour until it is lost goes first — at its reset, or, when credits in it expire sooner, by those that expire first; an account with five hours and no week by what its five hours have left per hour. One at 90% or more waits until the others can't answer; a key by the tokens magpie sent it lately."], manual: ["Manual", "Manual: every request goes to the model picked on the group's card, over its own accounts or keys."], @@ -5994,7 +5995,7 @@ function routingPage(part) { "": "Smart, over the members' accounts and keys together: of the subscriptions with quota to spare, the one whose allowance renews soonest goes first — the week decides, and an account with five hours and no week (Claude Enterprise) goes by its five hours, so ahead of every week renewing later, and one whose month its weeks can no longer use up before it renews by its week; one resting after a failure goes last.", order: "In order: the first model until it can't answer, then the next — each over its own accounts or keys as its provider routes them.", drain: "Until used up: one account or key, across the members, takes every request until it is used up; then the next in the list, which keeps them even after an earlier one renews. One rate limited or failing is passed over only while it rests.", - rotate: "In turn: each conversation's next turn goes to the next member's account or key, spreading the load.", + rotate: "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.", usage: "Least used first: the account or key with the most of its allowance left goes first.", pace: "Use before expiry: the account with the most left per hour until it is lost goes first — its week at its reset, or credits in it that expire sooner — so less of each member's allowance is lost; an account with five hours and no week (Claude Enterprise) by what its five hours have left per hour until they renew, so almost always first; a key by the tokens magpie sent it lately.", weight: GROUP_WEIGHT, @@ -7836,8 +7837,12 @@ function routingPage(part) { const gHint = (v) => GROUP_HINT[v] ? t(GROUP_HINT[v]) : MODES[v] || !v ? t(GROUP_HINT[""]) : modeOf(v)[1]; const rHint = el("div", "hint", gHint(d.routing)); + // In turn drawn under its words, as Stays has it (app.js drawRotFig) + const rFig = el("div", "rot-wrap"); + const drawFig = () => drawRotFig(rFig, d.routing === "rotate", d.affinity || ""); + drawFig(); const rw = el("div"); - rw.append(routingSegs(withJS(GROUP_ROUTE_OPTS, d.routing).map(([id, n, js]) => [id, t(n), , js]), d.routing, (v) => { d.routing = v; rHint.textContent = gHint(v); draw(); drawRules(); drawSink(); }), rHint); + rw.append(routingSegs(withJS(GROUP_ROUTE_OPTS, d.routing).map(([id, n, js]) => [id, t(n), , js]), d.routing, (v) => { d.routing = v; rHint.textContent = gHint(v); drawFig(); draw(); drawRules(); drawSink(); }), rHint, rFig); rw.append(el("div", "hint", t(GROUP_NEST))); advIn.append(el("label", "", t("Routing")), rw); // one rate limited with quota left: its place, or the back @@ -7969,7 +7974,7 @@ function routingPage(part) { advIn.append(el("label", "", t("Compact at")), cmpIn); const aHint = el("div", "hint", t(AFF_HINT[d.affinity] || AFF_HINT[""])); const aw = el("div"); - aw.append(segs(AFF_OPTS.map(([id, n]) => [id, t(n)]), d.affinity, (v) => { d.affinity = v; aHint.textContent = t(AFF_HINT[v] || AFF_HINT[""]); }), aHint); + aw.append(segs(AFF_OPTS.map(([id, n]) => [id, t(n)]), d.affinity, (v) => { d.affinity = v; aHint.textContent = t(AFF_HINT[v] || AFF_HINT[""]); drawFig(); }), aHint); advIn.append(el("label", "", t("Stays")), aw); // which gateway keys may use it, and masking: set by few, so under // Advanced with the rest (the owner, 11-12) diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.js index b54813ca5..ead63316c 100644 --- a/internal/gui/assets/plugins/routing/i18n.js +++ b/internal/gui/assets/plugins/routing/i18n.js @@ -420,7 +420,7 @@ magpie.strings({ "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "这里只开了一个账号或 Key,路由没有可选的。在供应商的编辑页再开一个,路由方式就在下面的「多账号 / 多 Key」里设置。", "Smart, over the members' accounts and keys together: of the subscriptions with quota to spare, the one whose allowance renews soonest goes first — the week decides, and an account with five hours and no week (Claude Enterprise) goes by its five hours, so ahead of every week renewing later, and one whose month its weeks can no longer use up before it renews by its week; one resting after a failure goes last.": "智能:成员的账号和 Key 统一排序。有余量的订阅中额度最先重置的排第一,以周额度为准;只有 5 小时额度的账号(如 Claude Enterprise)按 5 小时重置,排在更晚重置的周额度之前;月额度已来不及靠每周额度用完的按周重置;失败后休息中的排最后。", "In order: the first model until it can't answer, then the next — each over its own accounts or keys as its provider routes them.": "按顺序:先用第一个模型,无法响应再换下一个;各成员按其供应商的路由在自己的账号或 Key 间分配。", - "In turn: each conversation's next turn goes to the next member's account or key, spreading the load.": "轮流:会话的每一轮交给下一个成员的账号或 Key,均摊负载。", + "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "轮流:你每发一条消息,就按列表顺序交给下一个成员的账号或 Key;Agent 为这条消息做的工具调用留在同一个上。每换一次会损失部分提示词缓存;会话保持选「整个会话」时,改为整个会话固定在一个上。", "Least used first: the account or key with the most of its allowance left goes first.": "最少使用优先:剩余额度最多的账号或 Key 排第一。", "Use before expiry: the account with the most left per hour until it is lost goes first — its week at its reset, or credits in it that expire sooner — so less of each member's allowance is lost; an account with five hours and no week (Claude Enterprise) by what its five hours have left per hour until they renew, so almost always first; a key by the tokens magpie sent it lately.": "到期前用完:按剩余额度 ÷ 距作废小时数排序,越高越先用——周额度在重置时作废,更早过期的积分按过期时间算。只有 5 小时额度的账号(如 Claude Enterprise)按 5 小时窗口计算,几乎总排第一;Key 按最近发给它的 token 数排。", "A group among the models, and a model whose provider routes its accounts or keys other than Smart, keeps its own routing: this group only picks between it and the others, weighing it by the account or key it would try first, then tries it whole in its own order. A group among the models left on Smart is routed as this group is, unless this one goes In order, By weight or Manual.": "成员中的路由组,以及服务商路由不是“智能”的模型,都保留自己的路由:本组只在它与其他成员间选择(按它会先用的账号或 Key 比较),选中后按其自身顺序整体尝试。成员中路由留在“智能”的路由组,按本组的路由走,除非本组是“按顺序”“按权重”或“手动”。", @@ -488,7 +488,7 @@ magpie.strings({ "Smart: of the accounts with quota to spare, the one whose allowance renews soonest goes first — what it has left would be lost at the reset. The week decides; an account with five hours and no week goes by its five hours, and one whose month its weeks can no longer use up before it renews by its week. One at 90% or more waits until the others can't answer; one resting after a failure goes last.": "智能:有余量的账号中额度最先重置的排第一,以免剩余额度在重置时作废。以周额度为准;只有 5 小时额度的账号按 5 小时重置,月额度已来不及靠每周额度用完的按周重置。用到 90% 以上的,等其他都无法响应时才用;失败后休息中的排最后。", "Smart: keys that suit the request go first — one made for the model's own API — then in their order. One resting after a failure goes last.": "智能:适合此请求的 Key(为该模型原生 API 准备的)排前,其余按顺序。失败后休息中的排最后。", "In order: the first answers everything until it can't; then the next.": "按顺序:第一个处理所有请求,无法响应时再换下一个。", - "In turn: each conversation's next turn goes to the account after the one that answered its last, and a new conversation starts one further along; the requests within a turn stay put, keeping the prompt cache.": "轮流:会话的下一轮交给上一轮回答者的下一个账号,新会话再往后一个;一轮之内不换账号,保持提示词缓存。", + "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead.": "轮流:你每发一条消息,就按列表顺序交给下一个账号;Agent 为这条消息做的工具调用留在同一个上。会话保持选「整个会话」时,改为整个会话固定在一个上。", "Least used first: the account with the most of its allowance left goes first; a key by the tokens magpie sent it lately.": "最少使用优先:剩余额度最多的账号排第一;Key 按 magpie 最近发给它的 token 数排。", "Use before expiry: the account with the most left per hour until it is lost goes first — at its reset, or, when credits in it expire sooner, by those that expire first; an account with five hours and no week by what its five hours have left per hour. One at 90% or more waits until the others can't answer; a key by the tokens magpie sent it lately.": "到期前用完:按剩余额度 ÷ 距作废小时数排序,越高越先用——额度在重置时作废,有积分更早过期的按最先过期的那部分算;只有 5 小时额度的账号按 5 小时窗口计算。用到 90% 以上的,等其他都无法响应时才用;Key 按最近发给它的 token 数排。", "Nothing could take {model}.": "没有谁能处理 {model}。", @@ -1167,7 +1167,7 @@ magpie.strings({ "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "這裡只開了一個帳號或 Key,路由沒有可選的。在供應商的編輯頁再開一個,路由方式就在下面的「多帳號 / 多 Key」裡設定。", "Smart, over the members' accounts and keys together: of the subscriptions with quota to spare, the one whose allowance renews soonest goes first — the week decides, and an account with five hours and no week (Claude Enterprise) goes by its five hours, so ahead of every week renewing later, and one whose month its weeks can no longer use up before it renews by its week; one resting after a failure goes last.": "智慧:成員的帳號和 Key 統一排序。有餘量的訂閱中額度最先重置的排第一,以週額度為準;只有 5 小時額度的帳號(如 Claude Enterprise)按 5 小時重置,排在更晚重置的週額度之前;月額度已來不及靠每週額度用完的按週重置;失敗後休息中的排最後。", "In order: the first model until it can't answer, then the next — each over its own accounts or keys as its provider routes them.": "按順序:先用第一個模型,無法回應再換下一個;各成員按其供應商的路由在自己的帳號或 Key 間分配。", - "In turn: each conversation's next turn goes to the next member's account or key, spreading the load.": "輪流:會話的每一輪交給下一個成員的帳號或 Key,均攤負載。", + "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "輪流:你每發一則訊息,就按清單順序交給下一個成員的帳號或 Key;Agent 為這則訊息做的工具呼叫留在同一個上。每換一次會損失部分提示詞快取;會話保持選「整個會話」時,改為整個會話固定在一個上。", "Least used first: the account or key with the most of its allowance left goes first.": "最少使用優先:剩餘額度最多的帳號或 Key 排第一。", "Use before expiry: the account with the most left per hour until it is lost goes first — its week at its reset, or credits in it that expire sooner — so less of each member's allowance is lost; an account with five hours and no week (Claude Enterprise) by what its five hours have left per hour until they renew, so almost always first; a key by the tokens magpie sent it lately.": "到期前用完:按剩餘額度 ÷ 距作廢小時數排序,越高越先用——週額度在重置時作廢,更早過期的點數按過期時間算。只有 5 小時額度的帳號(如 Claude Enterprise)按 5 小時時段計算,幾乎總排第一;Key 按最近發給它的 token 數排。", "A group among the models, and a model whose provider routes its accounts or keys other than Smart, keeps its own routing: this group only picks between it and the others, weighing it by the account or key it would try first, then tries it whole in its own order. A group among the models left on Smart is routed as this group is, unless this one goes In order, By weight or Manual.": "成員中的路由組,以及服務商路由不是「智慧」的模型,都保留自己的路由:本組只在它與其他成員間選擇(按它會先用的帳號或 Key 比較),選中後按其自身順序整體嘗試。成員中路由留在「智慧」的路由組,按本組的路由走,除非本組是「按順序」「按權重」或「手動」。", @@ -1235,7 +1235,7 @@ magpie.strings({ "Smart: of the accounts with quota to spare, the one whose allowance renews soonest goes first — what it has left would be lost at the reset. The week decides; an account with five hours and no week goes by its five hours, and one whose month its weeks can no longer use up before it renews by its week. One at 90% or more waits until the others can't answer; one resting after a failure goes last.": "智慧:有餘量的帳號中額度最先重置的排第一,以免剩餘額度在重置時作廢。以週額度為準;只有 5 小時額度的帳號按 5 小時重置,月額度已來不及靠每週額度用完的按週重置。用到 90% 以上的,等其他都無法回應時才用;失敗後休息中的排最後。", "Smart: keys that suit the request go first — one made for the model's own API — then in their order. One resting after a failure goes last.": "智慧:適合此請求的 Key(為該模型原生 API 準備的)排前,其餘按順序。失敗後休息中的排最後。", "In order: the first answers everything until it can't; then the next.": "按順序:第一個處理所有請求,無法回應時再換下一個。", - "In turn: each conversation's next turn goes to the account after the one that answered its last, and a new conversation starts one further along; the requests within a turn stay put, keeping the prompt cache.": "輪流:會話的下一輪交給上一輪迴答者的下一個帳號,新會話再往後一個;一輪之內不換帳號,保持提示詞快取。", + "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead.": "輪流:你每發一則訊息,就按清單順序交給下一個帳號;Agent 為這則訊息做的工具呼叫留在同一個上。會話保持選「整個會話」時,改為整個會話固定在一個上。", "Least used first: the account with the most of its allowance left goes first; a key by the tokens magpie sent it lately.": "最少使用優先:剩餘額度最多的帳號排第一;Key 按 magpie 最近發給它的 token 數排。", "Use before expiry: the account with the most left per hour until it is lost goes first — at its reset, or, when credits in it expire sooner, by those that expire first; an account with five hours and no week by what its five hours have left per hour. One at 90% or more waits until the others can't answer; a key by the tokens magpie sent it lately.": "到期前用完:按剩餘額度 ÷ 距作廢小時數排序,越高越先用——額度在重置時作廢,有點數更早過期的按最先過期的那部分算;只有 5 小時額度的帳號按 5 小時時段計算。用到 90% 以上的,等其他都無法回應時才用;Key 按最近發給它的 token 數排。", "Nothing could take {model}.": "沒有誰能處理 {model}。", @@ -1912,7 +1912,7 @@ magpie.strings({ "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "有効なアカウントやキーが 1 つだけなので、ルーティングに選択肢はありません。プロバイダの編集画面で 2 つ目を有効にすると、ルーティングは下の「複数のアカウントやキー」で設定できます。", "Smart, over the members' accounts and keys together: of the subscriptions with quota to spare, the one whose allowance renews soonest goes first — the week decides, and an account with five hours and no week (Claude Enterprise) goes by its five hours, so ahead of every week renewing later, and one whose month its weeks can no longer use up before it renews by its week; one resting after a failure goes last.": "スマート(メンバーのアカウントとキーをまとめて扱う):クォータに余裕のあるサブスクリプションのうち、利用枠のリセットが最も早いものが先頭です。週の枠で判断し、5 時間枠のみで週の枠がないアカウント(Claude Enterprise)は 5 時間枠で判断するため、それより後にリセットされるどの週の枠よりも前になります。月の枠をリセットまでに週の枠では使い切れなくなったものは週の枠で判断します。失敗後に休止中のものは最後です。", "In order: the first model until it can't answer, then the next — each over its own accounts or keys as its provider routes them.": "順番:先頭のモデルが応答できなくなるまで使い、その後次へ。各モデルはそのプロバイダのルーティングに従って自身のアカウントやキーを使います。", - "In turn: each conversation's next turn goes to the next member's account or key, spreading the load.": "交互:各会話の次のターンを次のメンバーのアカウントやキーに送り、負荷を分散します。", + "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "交互:メッセージを送るたびに、リストの順で次のメンバーのアカウントやキーへ回します。そのメッセージのためのエージェントのツール呼び出しは同じものに残ります。移るたびにプロンプトキャッシュの一部を失います。維持を「セッション」にすると、会話全体が一つに留まります。", "Least used first: the account or key with the most of its allowance left goes first.": "使用量が最少を優先:利用枠の残りが最も多いアカウントやキーが先頭です。", "Use before expiry: the account with the most left per hour until it is lost goes first — its week at its reset, or credits in it that expire sooner — so less of each member's allowance is lost; an account with five hours and no week (Claude Enterprise) by what its five hours have left per hour until they renew, so almost always first; a key by the tokens magpie sent it lately.": "期限前に使い切る:失われるまでの 1 時間あたりの残りが最も多いアカウントが先頭になり、各メンバーの枠が失われる分が減ります — 週の枠はリセットで、それより早く期限切れになるクレジットはその期限で失われます。5 時間枠のみで週の枠がないアカウント(Claude Enterprise)は、リセットまでの 1 時間あたりの 5 時間枠の残りで判断するため、ほぼ常に先頭です。キーは magpie が最近送ったトークン数で判断します。", "A group among the models, and a model whose provider routes its accounts or keys other than Smart, keeps its own routing: this group only picks between it and the others, weighing it by the account or key it would try first, then tries it whole in its own order. A group among the models left on Smart is routed as this group is, unless this one goes In order, By weight or Manual.": "モデルの中のグループと、プロバイダーのルーティングがスマート以外のモデルは、独自のルーティングを保ちます。このグループはそれと他のメンバーの間で選ぶだけで、そのグループが最初に試すアカウントやキーで比較し、選ばれたらそのグループ全体を独自の順番で試します。ルーティングをスマートのままにしたモデルの中のグループは、このグループのルーティングに従います。ただし、このグループが順番、重み付け、手動の場合を除きます。", @@ -1980,7 +1980,7 @@ magpie.strings({ "Smart: of the accounts with quota to spare, the one whose allowance renews soonest goes first — what it has left would be lost at the reset. The week decides; an account with five hours and no week goes by its five hours, and one whose month its weeks can no longer use up before it renews by its week. One at 90% or more waits until the others can't answer; one resting after a failure goes last.": "スマート:クォータに余裕のあるアカウントのうち、利用枠が最も早く更新されるものが先です — 残りはリセット時に失われるためです。週の枠で決まり、5 時間枠だけで週の枠がないアカウントは 5 時間枠で、月の枠を更新までに週の枠では使い切れなくなったアカウントは週の枠で決まります。90% 以上使ったアカウントは他が応答できなくなるまで待ち、失敗後に休止中のアカウントは最後になります。", "Smart: keys that suit the request go first — one made for the model's own API — then in their order. One resting after a failure goes last.": "スマート:リクエストに合うキー — モデル本来の API 用のキー — が先で、その後は設定順です。失敗後に休止中のキーは最後になります。", "In order: the first answers everything until it can't; then the next.": "順番:最初の 1 つが応答できなくなるまですべてに応答し、その後は次へ。", - "In turn: each conversation's next turn goes to the account after the one that answered its last, and a new conversation starts one further along; the requests within a turn stay put, keeping the prompt cache.": "交互:各会話の次のターンは前回応答したアカウントの次のアカウントへ、新しい会話はさらにその次から始まります。ターン内のリクエストは同じアカウントのままで、プロンプトキャッシュを保ちます。", + "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead.": "交互:メッセージを送るたびに、リストの順で次のアカウントへ回します。そのメッセージのためのエージェントのツール呼び出しは同じものに残ります。維持を「セッション」にすると、会話全体が一つに留まります。", "Least used first: the account with the most of its allowance left goes first; a key by the tokens magpie sent it lately.": "使用量が最少:利用枠の残りが最も多いアカウントが先です。キーは magpie が最近送ったトークン数で決まります。", "Use before expiry: the account with the most left per hour until it is lost goes first — at its reset, or, when credits in it expire sooner, by those that expire first; an account with five hours and no week by what its five hours have left per hour. One at 90% or more waits until the others can't answer; a key by the tokens magpie sent it lately.": "期限前に使い切る:失われるまでの 1 時間あたりの残りが最も多いアカウントが先です — 残りはリセットで失われ、それより早く期限切れになるクレジットがあれば最初に期限切れになる分で決まります。5 時間枠だけで週の枠がないアカウントは 5 時間枠の 1 時間あたりの残りで決まります。90% 以上使ったアカウントは他が応答できなくなるまで待ち、キーは magpie が最近送ったトークン数で決まります。", "Nothing could take {model}.": "{model} を処理できる相手がいませんでした。", @@ -2659,7 +2659,7 @@ magpie.strings({ "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "Hier ist nur ein Konto oder Schlüssel aktiv, also hat die Weiterleitung keine Wahl. Aktiviere im Editor des Anbieters ein zweites; wie weitergeleitet wird, legst du dann unten unter „Mehrere Konten oder Schlüssel“ fest.", "Smart, over the members' accounts and keys together: of the subscriptions with quota to spare, the one whose allowance renews soonest goes first — the week decides, and an account with five hours and no week (Claude Enterprise) goes by its five hours, so ahead of every week renewing later, and one whose month its weeks can no longer use up before it renews by its week; one resting after a failure goes last.": "Intelligent, über Konten und Schlüssel aller Mitglieder zusammen: Von den Abos mit freiem Kontingent kommt das zuerst, dessen Kontingent sich am frühesten erneuert – die Woche entscheidet, und ein Konto mit fünf Stunden und ohne Woche (Claude Enterprise) richtet sich nach seinen fünf Stunden, also vor jeder später erneuerten Woche, und eines, dessen Monat seine Wochen vor der Erneuerung nicht mehr aufbrauchen können, nach seiner Woche; eines, das nach einem Fehler pausiert, kommt zuletzt.", "In order: the first model until it can't answer, then the next — each over its own accounts or keys as its provider routes them.": "Der Reihe nach: das erste Modell, bis es nicht mehr antworten kann, dann das nächste – jedes über seine eigenen Konten oder Schlüssel, wie sein Anbieter sie weiterleitet.", - "In turn: each conversation's next turn goes to the next member's account or key, spreading the load.": "Abwechselnd: Die nächste Runde jeder Unterhaltung geht an Konto oder Schlüssel des nächsten Mitglieds und verteilt so die Last.", + "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.": "Abwechselnd: Jede Nachricht, die Sie senden, geht an das nächste Konto oder den nächsten Schlüssel der Mitglieder, reihum; die Tool-Aufrufe des Agenten dazu bleiben beim selben. Jeder Wechsel kostet etwas Prompt-Cache; mit Bleibt auf Sitzung bleibt eine ganze Unterhaltung bei einem.", "Least used first: the account or key with the most of its allowance left goes first.": "Am wenigsten genutzt zuerst: Das Konto oder der Schlüssel mit dem größten Restkontingent kommt zuerst.", "Use before expiry: the account with the most left per hour until it is lost goes first — its week at its reset, or credits in it that expire sooner — so less of each member's allowance is lost; an account with five hours and no week (Claude Enterprise) by what its five hours have left per hour until they renew, so almost always first; a key by the tokens magpie sent it lately.": "Vor Ablauf aufbrauchen: Das Konto mit dem meisten Rest pro Stunde, bis er verfällt, kommt zuerst – seine Woche beim Zurücksetzen oder Guthaben darin, das früher abläuft –, damit von jedem Mitglied weniger verfällt; ein Konto mit fünf Stunden und ohne Woche (Claude Enterprise) nach dem Rest seiner fünf Stunden pro Stunde bis zur Erneuerung, also fast immer zuerst; ein Schlüssel nach den Token, die magpie ihm zuletzt gesendet hat.", "A group among the models, and a model whose provider routes its accounts or keys other than Smart, keeps its own routing: this group only picks between it and the others, weighing it by the account or key it would try first, then tries it whole in its own order. A group among the models left on Smart is routed as this group is, unless this one goes In order, By weight or Manual.": "Eine Gruppe unter den Modellen und ein Modell, dessen Anbieter seine Konten oder Schlüssel anders als „Intelligent“ weiterleitet, behalten ihre eigene Weiterleitung: Diese Gruppe wählt nur zwischen ihr und den anderen, gewichtet nach dem Konto oder Schlüssel, den sie zuerst versuchen würde, und versucht sie dann als Ganzes in ihrer eigenen Reihenfolge. Eine Gruppe unter den Modellen, deren Weiterleitung auf „Intelligent“ steht, wird wie diese Gruppe weitergeleitet, außer diese geht „Der Reihe nach“, „Nach Gewicht“ oder „Manuell“.", @@ -2727,7 +2727,7 @@ magpie.strings({ "Smart: of the accounts with quota to spare, the one whose allowance renews soonest goes first — what it has left would be lost at the reset. The week decides; an account with five hours and no week goes by its five hours, and one whose month its weeks can no longer use up before it renews by its week. One at 90% or more waits until the others can't answer; one resting after a failure goes last.": "Intelligent: Von den Konten mit freiem Kontingent kommt das zuerst, dessen Kontingent sich am frühesten erneuert – sein Rest würde beim Zurücksetzen verfallen. Die Woche entscheidet; ein Konto mit fünf Stunden und ohne Woche richtet sich nach seinen fünf Stunden, eines, dessen Monat seine Wochen vor der Erneuerung nicht mehr aufbrauchen können, nach seiner Woche. Eines ab 90 % wartet, bis die anderen nicht antworten können; eines, das nach einem Fehler pausiert, kommt zuletzt.", "Smart: keys that suit the request go first — one made for the model's own API — then in their order. One resting after a failure goes last.": "Intelligent: Schlüssel, die zur Anfrage passen, kommen zuerst – einer für die eigene API des Modells –, dann in ihrer Reihenfolge. Einer, der nach einem Fehler pausiert, kommt zuletzt.", "In order: the first answers everything until it can't; then the next.": "Der Reihe nach: Der erste beantwortet alles, bis er nicht mehr kann; dann der nächste.", - "In turn: each conversation's next turn goes to the account after the one that answered its last, and a new conversation starts one further along; the requests within a turn stay put, keeping the prompt cache.": "Abwechselnd: Die nächste Runde jeder Unterhaltung geht an das Konto nach dem, das die letzte beantwortet hat, und eine neue Unterhaltung beginnt eines weiter; die Anfragen innerhalb einer Runde bleiben, sodass der Prompt-Cache erhalten bleibt.", + "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead.": "Abwechselnd: Jede Nachricht, die Sie senden, geht an das nächste Konto in der Liste, reihum; die Tool-Aufrufe des Agenten dazu bleiben beim selben. Mit Bleibt auf Sitzung bleibt eine ganze Unterhaltung bei einem.", "Least used first: the account with the most of its allowance left goes first; a key by the tokens magpie sent it lately.": "Am wenigsten genutzt zuerst: Das Konto mit dem größten Restkontingent kommt zuerst; ein Schlüssel nach den Token, die magpie ihm zuletzt gesendet hat.", "Use before expiry: the account with the most left per hour until it is lost goes first — at its reset, or, when credits in it expire sooner, by those that expire first; an account with five hours and no week by what its five hours have left per hour. One at 90% or more waits until the others can't answer; a key by the tokens magpie sent it lately.": "Vor Ablauf aufbrauchen: Das Konto mit dem meisten Rest pro Stunde, bis er verfällt, kommt zuerst – beim Zurücksetzen oder, wenn Guthaben darin früher abläuft, nach dem, das zuerst abläuft; ein Konto mit fünf Stunden und ohne Woche nach dem Rest seiner fünf Stunden pro Stunde. Eines ab 90 % wartet, bis die anderen nicht antworten können; ein Schlüssel nach den Token, die magpie ihm zuletzt gesendet hat.", "Nothing could take {model}.": "Nichts konnte {model} übernehmen.", diff --git a/internal/gui/assets/rotfig.js b/internal/gui/assets/rotfig.js new file mode 100644 index 000000000..bea9149f6 --- /dev/null +++ b/internal/gui/assets/rotfig.js @@ -0,0 +1,49 @@ +// rotateFigure: In turn, drawn: two conversations, three of the user's +// messages each (a pill naming the account it went to), each followed by +// the agent's tool calls (dots in that account's shade). As Stays has it +// (gateway affine): Auto and Within a turn move each message on, Session +// and Strict keep a conversation on one, Off moves every request on. +// Wing8Aqua on X: the words alone left the unit that goes round unclear. +// app.js's drawRotFig imports this when In turn is first shown, so it +// weighs nothing on the core. +window.rotateFigure = function (affinity) { + const NS = "http://www.w3.org/2000/svg"; + const mk = (tag, attrs, text) => { + const n = document.createElementNS(NS, tag); + for (const [k, v] of Object.entries(attrs)) n.setAttribute(k, v); + if (text) n.textContent = text; + return n; + }; + const s = mk("svg", { viewBox: "0 0 232 70", width: 232, height: 70, class: "rot-fig", "aria-hidden": "true" }); + s.dataset.affinity = affinity || ""; + const whole = affinity === "session" || affinity === "strict"; + const each = affinity === "off"; + for (let row = 0; row < 2; row++) { + const y = 4 + row * 26; + s.append(mk("rect", { x: 0.5, y: y + 0.5, width: 231, height: 21, rx: 10.5, class: "rot-track" })); + let n = row; // a new conversation starts one further along + for (let m = 0; m < 3; m++) { + const x = 6 + m * 75, at = whole ? row : each ? n : row + m; + const g = mk("g", { class: "rot-msg" }); + g.append(mk("line", { x1: x + 22, y1: y + 11, x2: x + 50, y2: y + 11, class: "rot-link" })); + g.append(mk("rect", { x, y: y + 4, width: 22, height: 14, rx: 7, class: "rot-acct rot-" + "abc"[at % 3] })); + g.append(mk("text", { x: x + 11, y: y + 14.5, "text-anchor": "middle", class: "rot-l rot-" + "abc"[at % 3] }, "ABC"[at % 3])); + if (each) n++; + for (let d = 0; d < 2; d++) { + const k = each ? n++ : at; + g.append(mk("circle", { cx: x + 34 + d * 10, cy: y + 11, r: 3, class: "rot-call rot-" + "abc"[k % 3] })); + } + g.dataset.to = "ABC"[at % 3]; + s.append(g); + } + } + // what a pill and a dot are + const ly = 65; + s.append(mk("rect", { x: 0.5, y: ly - 7, width: 14, height: 9, rx: 4.5, class: "rot-key" })); + const msg = mk("text", { x: 19, y: ly, class: "rot-legend" }, t("Your message")); + s.append(msg); + s.append(mk("circle", { cx: 122, cy: ly - 2.5, r: 2.5, class: "rot-key" })); + s.append(mk("circle", { cx: 130, cy: ly - 2.5, r: 2.5, class: "rot-key" })); + s.append(mk("text", { x: 138, y: ly, class: "rot-legend" }, t("Tool calls"))); + return s; +}; diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 8a4ce3ac6..ecd8b0aac 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -18,7 +18,7 @@ import ( // `git log -L` of this file. const ( appScriptBudget = 1_086_267 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had - coreScriptBudget = 1_266_008 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to + coreScriptBudget = 1_266_341 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form ) // codeBytes is how many bytes of b are code: its blank lines, its lines diff --git a/internal/gui/tests/old-webkit.test.cjs b/internal/gui/tests/old-webkit.test.cjs index e5c048bdc..b7a2f22e1 100644 --- a/internal/gui/tests/old-webkit.test.cjs +++ b/internal/gui/tests/old-webkit.test.cjs @@ -178,9 +178,10 @@ test("compat.js is the first of the page's own scripts", async () => { // pipecheck.js when Settings draws Models; // addfloat.js when the Providers page's add sheet first opens; // plugingrid.js when Plugins first draws; + // rotfig.js when a routing's In turn is first shown; // the checks above // still read them - for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); + for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "rotfig.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html"); }); test("the styles hold up in Safari 15.0", async () => { diff --git a/internal/gui/tests/rotate-figure.test.cjs b/internal/gui/tests/rotate-figure.test.cjs new file mode 100644 index 000000000..697bce448 --- /dev/null +++ b/internal/gui/tests/rotate-figure.test.cjs @@ -0,0 +1,180 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// In turn says which unit goes round, and draws it (Wing8Aqua on X: "each +// turn of a conversation goes to the next one" read as every message of a +// session moving, and a session as the unit expected). The hint names the +// message you send, the tool calls that stay with it, and Stays: Session +// for a whole conversation on one. Under it a small figure: two +// conversations of three messages each, a pill naming the account each +// went to, then its tool calls in that account's shade — moved on per +// message under Auto, one account a conversation under Session, every +// request under Off, as the gateway's affine routes them. In a provider's +// editor and a routing group's, every language, wide and narrow, Chromium +// and WebKit; the figure fits, nothing scrolls sideways, and it is gone +// for any other routing. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(process.env.MAGPIE_ROTATE_ASSETS || path.join(__dirname, "../assets")); +const sub = { + icon: "generic", catalog: "", models: [{ id: "gpt-5.5", name: "GPT-5.5", on: true }], agents: [], fallback: [], headers: {}, routing: "rotate", affinity: "", ready: true, + id: "codex", name: "Codex", chat: "", responses: "", anthropic: "", keyList: [], + account: { + agent: "codex", agentName: "Codex", user: "one@example.test", plan: "Plus", + logins: ["one", "two", "three"].map((n, i) => ({ user: `${n}@example.test`, plan: "Plus", active: i === 0, on: true })), + }, +}; +const models = [ + { id: "a/sol", name: "sol", providerName: "A", icon: "generic" }, + { id: "b/sol", name: "sol", providerName: "B", icon: "generic" }, +]; +const members = models.map((m) => m.id); +const groups = () => ({ + models, pools: [], + groups: [{ id: "sol", name: "Sol", members, routing: "rotate", ready: true, memberInfo: members.map((id) => ({ id, ready: true })) }], +}); + +function serve(lang, theme) { + const state = { agents: [{ id: "pi", name: "Pi", path: "/test/pi", fields: [] }], profiles: [], settings: { lang, theme } }; + const providers = { providers: [sub], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } }; + return async (r) => { + const url = new URL(r.request().url()); + const json = (data) => r.fulfill({ json: data }); + if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:${JSON.stringify(lang)},theme:${JSON.stringify(theme)},web:true};` }); + if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return json(state); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/gateway/trace") { + if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes + return json({ mine: true, now: new Date().toISOString(), seq: 0, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] }); + } + if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] }); + if (url.pathname === "/api/groups") return json(groups()); + if (url.pathname === "/api/providers") return json(providers); + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + try { await r.fulfill({ body: await fs.readFile(file), contentType }); } catch { await r.fulfill({ status: 404, body: "" }); } + }; +} + +const LANGS = ["en", "zh", "zh-TW", "ja", "de"]; +// the hint names the message you send as what goes round +const SAYS = { en: /Each message you send goes to the next/i, zh: /你每发一条消息/, "zh-TW": /你每發一則訊息/, ja: /メッセージを送るたびに/, de: /Jede Nachricht, die Sie senden/ }; +const HINTS = [ + "Each message you send goes to the next one, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.", + "In turn: each message you send goes to the next member's account or key, round the list; the agent's tool calls for it stay on the same one. A move costs some prompt cache; with Stays on Session, a whole conversation stays on one instead.", + "In turn: each message you send goes to the next account, round the list; the agent's tool calls for it stay on the same one. With Stays on Session, a whole conversation stays on one instead.", + "Your message", "Tool calls", +]; +// what the figure draws: each conversation's three messages, the account +// each went to, and the accounts its tool calls went to +const fig = (scope) => scope.locator("svg.rot-fig").evaluate((s) => ({ + affinity: s.dataset.affinity, + msgs: [...s.querySelectorAll(".rot-msg")].map((g) => g.dataset.to).join(""), + calls: [...s.querySelectorAll(".rot-call")].map((c) => [...c.classList].find((k) => /^rot-[abc]$/.test(k)).slice(4).toUpperCase()).join(""), + legend: [...s.querySelectorAll(".rot-legend")].map((x) => x.textContent), + box: (() => { const r = s.getBoundingClientRect(); return { x: r.x, r: r.right, w: r.width, h: r.height }; })(), +})); +const fits = async (page, scope, name) => { + const f = await fig(scope); + const ed = await scope.boundingBox(); + assert.ok(f.box.w > 100 && f.box.h > 20, `${name}: the figure is drawn: ${JSON.stringify(f.box)}`); + assert.ok(f.box.x >= ed.x - 1 && f.box.r <= ed.x + ed.width + 1, `${name}: the figure past the editor's edge: ${JSON.stringify(f.box)} in ${JSON.stringify(ed)}`); + // the legend's two words don't run into each other + const [a, b] = await scope.locator("svg.rot-fig .rot-legend").evaluateAll((ts) => ts.map((x) => { const r = x.getBoundingClientRect(); return { l: r.left, r: r.right }; })); + assert.ok(a.r < b.l - 6, `${name}: the legend's words overlap: ${JSON.stringify([a, b])}`); + assert.equal(await page.evaluate(() => document.scrollingElement.scrollWidth <= innerWidth), true, `${name}: no sideways scroll`); +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + const launch = () => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }); + for (const lang of LANGS) { + const tr = (page, s) => page.evaluate(([k, lang]) => lang === "en" ? k : (I18N[lang][k] ?? window.ROUTING_I18N?.[lang]?.[k] ?? k), [s, lang]); + for (const width of [900, 420]) { + const theme = width === 420 ? "dark" : "light"; + test(`${engine} ${lang} ${width}px ${theme}: a provider's In turn says and draws the message going round`, async (t) => { + const browser = await launch(); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", serve(lang, theme)); + await page.goto("http://magpie.test/?view=providers"); + await page.locator(".row.provider", { hasText: sub.name }).first().click(); + await page.locator(".editor .accts").first().waitFor(); + if (lang !== "en") assert.deepEqual(await page.evaluate(([keys, lang]) => keys.filter((k) => !I18N[lang][k]), [[HINTS[0], HINTS[3], HINTS[4]], lang]), [], "translated"); + const ed = page.locator(".editor").first(); + const routing = ed.locator("label", { hasText: new RegExp(`^${await tr(page, "Routing")}$`) }).locator("xpath=following-sibling::div[1]"); + assert.match(await routing.locator(".hint.expl").first().textContent(), SAYS[lang]); + // Auto: each message on to the next, its tool calls with it, a new + // conversation one further along + let f = await fig(routing); + assert.equal(f.affinity, ""); + assert.equal(f.msgs, "ABCBCA"); + assert.equal(f.calls, "AABBCCBBCCAA"); + assert.deepEqual(f.legend, [await tr(page, "Your message"), await tr(page, "Tool calls")]); + await fits(page, ed, "provider"); + if (process.env.ARTIFACT_DIR) { + await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true }); + await routing.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-provider-rotate.png`) }); + } + const stays = ed.locator("label", { hasText: new RegExp(`^${await tr(page, "Stays")}$`) }).locator("xpath=following-sibling::div[1]"); + // Session: a whole conversation on one + await stays.locator(".segs .opt", { hasText: new RegExp(`^${await tr(page, "Session")}$`) }).click(); + f = await fig(routing); + assert.equal(f.msgs, "AAABBB"); + assert.equal(f.calls, "AAAAAABBBBBB"); + // Off: every request on to the next + await stays.locator(".segs .opt", { hasText: new RegExp(`^${await tr(page, "Off")}$`) }).click(); + f = await fig(routing); + assert.equal(f.msgs, "AAABBB"); + assert.equal(f.calls, "BCBCBCCACACA"); + // another routing: no figure + await routing.locator(".segs .opt", { hasText: new RegExp(`^${await tr(page, "In order")}$`) }).click(); + assert.equal(await routing.locator("svg.rot-fig").count(), 0, "drawn for In turn only"); + assert.equal(await routing.locator(".rot-wrap").isHidden(), true); + assert.deepEqual(errors, []); + }); + + test(`${engine} ${lang} ${width}px ${theme}: a routing group's In turn says and draws the message going round`, async (t) => { + const browser = await launch(); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width, height: 1400 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", serve(lang, theme)); + await page.goto("http://magpie.test/?view=groups"); + const card = page.locator(".rt-group", { hasText: "Sol" }); + await card.waitFor(); + await card.locator("button", { hasText: new RegExp(`^${await tr(page, "Edit")}$`) }).click(); + const adv = page.locator(".rt-gedit .rt-gadv"); + await adv.waitFor({ state: "attached" }); + if (!(await adv.evaluate((e) => e.open))) await adv.locator(":scope > summary").click(); + const ed = page.locator(".rt-gedit"); + const routing = ed.locator("label", { hasText: new RegExp(`^${await tr(page, "Routing")}$`) }).locator("xpath=following-sibling::div[1]"); + const hint = await routing.locator(".hint").first().textContent(); + assert.match(hint, SAYS[lang]); + if (lang !== "en") assert.notEqual(hint, HINTS[1], "translated"); + let f = await fig(routing); + assert.equal(f.msgs, "ABCBCA"); + await fits(page, ed, "group"); + if (process.env.ARTIFACT_DIR) await routing.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-group-rotate.png`) }); + const stays = ed.locator("label", { hasText: new RegExp(`^${await tr(page, "Stays")}$`) }).locator("xpath=following-sibling::div[1]"); + await stays.locator(".segs .opt", { hasText: new RegExp(`^${await tr(page, "Session")}$`) }).click(); + f = await fig(routing); + assert.equal(f.affinity, "session"); + assert.equal(f.msgs, "AAABBB"); + await routing.locator(".segs .opt", { hasText: new RegExp(`^${await tr(page, "Smart")}$`) }).click(); + assert.equal(await routing.locator("svg.rot-fig").count(), 0, "drawn for In turn only"); + assert.deepEqual(errors, []); + }); + } + } +} diff --git a/site/public/docs/ja/routing-groups.html b/site/public/docs/ja/routing-groups.html index 3616f3ac1..eec19a622 100644 --- a/site/public/docs/ja/routing-groups.html +++ b/site/public/docs/ja/routing-groups.html @@ -185,7 +185,7 @@
プロバイダーに二つ目のアカウントやキーを追加してオンにすると、編集画面に ルーティング と 維持 が現れ、リクエストをどう分けるかを決めます。
枠が残っているのにレート制限(429)されたものの扱いも選べます。位置を維持 はベンダーの指定どおり休んでから元の位置に戻り、最後尾へ はレート制限されていないものの後ろに回り、毎回先頭に戻らず負荷が回ります。
維持 は、会話を答えたアカウントやキーに留めるかを決めます。
smartorderdrainrotaterotateusagepaceweightOnce a provider has a second account or key switched on, its editor gets Routing and Stays, which decide how requests go between them.
You can also choose what one rate limited (429) while it still has quota does: Keeps its place rests as long as the vendor asks, then takes its place again; Goes to the back goes behind every one not rate limited since, so the load goes round rather than back to the first each time.
Stays decides whether a conversation stays with the account or key that answered it:
smartorderdrainrotaterotateusagepaceweight给同一个供应商加上第二个账号或第二个 Key 并打开后,它的编辑页会多出 路由 和 会话保持 两项,决定请求在这些账号或 Key 之间怎么分。
被限流(429)但还有额度的那个怎么办,也可以选:保持原位:休息到供应商要求的时间,再回到原来的位置;排到最后:排到所有没被限流的后面,让负载轮转起来,而不是每次都回到第一个。
会话保持 决定一段对话是否留在答过它的那个账号或 Key 上:
smartorderdrainrotaterotateusagepaceweight