diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index fc95c42e1..855ee6fb4 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -4182,10 +4182,14 @@ function routingPage(part) { const { prompt, read } = promptOf(r); if (prompt) { s.prompt += prompt; s.read += read; s.cached++; } const d = !noAnswer(outcome(r)[1]) && decodeOf(r, r.ms, r.ttft, r.firstText); - if (d) { s.decodeMs += d.w; s.decodeOut += d.n; s.timed++; } + // the same replies over their whole time too, the wait for the + // first token and the reasoning in: what a tool that times the + // whole request reads (@verymoes on X: CC Switch's ≈77 and + // opencode's 76.7 beside this 142) + if (d) { s.decodeMs += d.w; s.decodeOut += d.n; s.timed++; s.wholeMs += r.ms; s.wholeOut += r.out; } } return s; - }, { cost: 0, tokens: 0, priced: 0, unpriced: 0, running: 0, completed: 0, prompt: 0, read: 0, cached: 0, decodeMs: 0, decodeOut: 0, timed: 0 }); + }, { cost: 0, tokens: 0, priced: 0, unpriced: 0, running: 0, completed: 0, prompt: 0, read: 0, cached: 0, decodeMs: 0, decodeOut: 0, timed: 0, wholeMs: 0, wholeOut: 0 }); setText(x.arrow, open ? "▾" : "▸"); // Background workers have their own IDs. Label groups made entirely // for one purpose without renaming a chat that also made helper calls. @@ -4231,7 +4235,8 @@ function routingPage(part) { if (g.key && visibleMetrics.includes("cache") && total.prompt) meta.push(metricElement(["cache-hit", "Avg. cache", hitPct(total.read / total.prompt), t("Total cache reads divided by total prompt tokens; larger prompts carry more weight") + "\n" + coverage(total.cached)])); if (g.key && visibleMetrics.includes("speed") && total.decodeMs) meta.push(metricElement(["speed", "Avg. speed", t("{n} tok/s", { n: Math.round(total.decodeOut * 1000 / total.decodeMs) }), - t("Total output tokens divided by total decode time; excludes waiting and replies without usable timing") + ". " + t("A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it") + ". " + t("No answer text: speed includes reasoning only when visible reasoning streamed; hidden reasoning has no speed") + "\n" + coverage(total.timed)])); + tipLines(t("Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out") + ". " + t("A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it") + ". " + t("No answer text: speed includes reasoning only when visible reasoning streamed; hidden reasoning has no speed"), + total.wholeMs ? t("Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s", { n: Math.round(total.wholeOut * 1000 / total.wholeMs) }) : "", coverage(total.timed))])); const metaSig = JSON.stringify([bits, tokenHelp, meta.map((e) => [e.textContent, e.title])]); if (x.meta.dataset.sig !== metaSig) { x.meta.replaceChildren(...meta); x.meta.dataset.sig = metaSig; } const credits = routeCredits(g.rows); diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.js index faf7f2574..1ba6e983b 100644 --- a/internal/gui/assets/plugins/routing/i18n.js +++ b/internal/gui/assets/plugins/routing/i18n.js @@ -132,7 +132,8 @@ magpie.strings({ "request cache hit rate {p}": "请求缓存命中率 {p}", "Based on {n} of {total} completed requests": "基于 {total} 个已完成请求中的 {n} 个", "Total cache reads divided by total prompt tokens; larger prompts carry more weight": "缓存读取总量除以输入 token 总量;输入越大的请求权重越高", - "Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "输出 token 总量除以输出耗时总和;不计等待时间及缺少有效计时的回复", + "Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "输出 token 总量除以每个回复从首个 token 到结束的时间总和;不计等待首个 token 的时间,也不计缺少有效计时的回复", + "Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "按每个请求的全程时间算,含等待首个 token 的时间和推理:{n} token/秒", "Read the accounts' allowances again": "重新读取各账号的额度", "live, as the gateway decides": "实时 · 网关正在做的决定", "Add another model": "再添加一个模型", @@ -893,7 +894,8 @@ magpie.strings({ "request cache hit rate {p}": "請求快取命中率 {p}", "Based on {n} of {total} completed requests": "基於 {total} 個已完成請求中的 {n} 個", "Total cache reads divided by total prompt tokens; larger prompts carry more weight": "快取讀取總量除以輸入 token 總量;輸入越大的請求權重越高", - "Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "輸出 token 總量除以輸出耗時總和;不計等待時間及缺少有效計時的回覆", + "Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "輸出 token 總量除以每個回覆從首個 token 到結束的時間總和;不計等待首個 token 的時間,也不計缺少有效計時的回覆", + "Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "按每個請求的全程時間算,含等待首個 token 的時間和推理:{n} token/秒", "Read the accounts' allowances again": "重新讀取各帳號的額度", "live, as the gateway decides": "即時 · 閘道正在做的決定", "Add another model": "再新增一個模型", @@ -1632,7 +1634,8 @@ magpie.strings({ "request cache hit rate {p}": "リクエストのキャッシュヒット率 {p}", "Based on {n} of {total} completed requests": "完了した {total} 件中 {n} 件に基づく", "Total cache reads divided by total prompt tokens; larger prompts carry more weight": "キャッシュ読み取り合計を入力トークン合計で割った値。入力が多いリクエストほど重みが大きくなります", - "Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "出力トークン合計を生成時間の合計で割った値。待ち時間と有効な計測のない応答は除きます", + "Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "出力トークンの合計を、各応答の最初のトークンから終わりまでの時間の合計で割った値。最初のトークンを待つ時間と、有効な計測のない応答は除きます", + "Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "各リクエストの全体時間で計算(最初のトークンの待ち時間と推論を含む):{n} tok/s", "Read the accounts' allowances again": "アカウントの利用枠を読み直します", "live, as the gateway decides": "ライブ · ゲートウェイの判断どおり", "Add another model": "別のモデルを追加", @@ -2383,7 +2386,8 @@ magpie.strings({ "request cache hit rate {p}": "Cache-Trefferquote der Anfrage {p}", "Based on {n} of {total} completed requests": "Basierend auf {n} von {total} abgeschlossenen Anfragen", "Total cache reads divided by total prompt tokens; larger prompts carry more weight": "Gesamte Cache-Lese-Token geteilt durch gesamte Eingabe-Token; größere Eingaben erhalten mehr Gewicht", - "Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "Gesamte Ausgabe-Token geteilt durch gesamte Generierungszeit; ohne Wartezeit und Antworten ohne brauchbare Zeitmessung", + "Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "Gesamte Ausgabe-Token geteilt durch die Zeit vom ersten Token jeder Antwort bis zu ihrem Ende; ohne die Wartezeit auf das erste Token und ohne Antworten ohne brauchbare Zeitmessung", + "Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "Über die ganze Dauer jeder Anfrage, Wartezeit auf das erste Token und Reasoning mitgezählt: {n} tok/s", "Read the accounts' allowances again": "Kontingente der Konten neu lesen", "live, as the gateway decides": "live, während der Zugangspunkt entscheidet", "Add another model": "Weiteres Modell hinzufügen", diff --git a/internal/gui/tests/routing-request-metrics.test.cjs b/internal/gui/tests/routing-request-metrics.test.cjs index 49cb16a76..0098f326a 100644 --- a/internal/gui/tests/routing-request-metrics.test.cjs +++ b/internal/gui/tests/routing-request-metrics.test.cjs @@ -126,6 +126,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.doesNotMatch(await unknown.locator(".summary").textContent(), /token|—/, "a session without token counts has no fake zero or dash"); assert.equal(await group.locator(".cache-hit .v").textContent(), "63%", "cache average is weighted by prompt tokens, not by request count"); assert.match(await group.locator(".speed .v").textContent(), /^133 /, "speed is output divided by summed decode windows, not the mean of individual speeds"); + // the same six replies over their whole time, the wait for the first + // token in, as tools that time the whole request read it (@verymoes + // on X): 4,000 tokens over 82 s + const speedTip = await group.locator(".speed").getAttribute("title"); + assert.match(speedTip, lang === "zh" ? /不计等待首个 token 的时间/ : /the wait for the first token, and replies without usable timing, are left out/, "the tooltip says the wait for the first token is left out"); + assert.match(speedTip, lang === "zh" ? /全程时间.*:49 token\/秒/ : /whole time.*: 49 tok\/s/, "the tooltip gives the speed over the whole time too"); assert.match(await group.locator(".cache-hit").getAttribute("title"), /9.*11|11.*9/, "unknown and unfinished requests are excluded and coverage is disclosed"); assert.match(await group.locator(".rt-token-total").getAttribute("title"), /11.*12|12.*11/, "session token breakdown discloses missing records"); await group.click();