gui: Usage's Requests tag a request streamed on Gemini's streamGenerateContent as Gemini, not with no protocol
ledProtoOf matched generateContent case-sensitively, so a request Gemini
CLI streams (/v1beta/models/<model>:streamGenerateContent) had no
protocol tag in the Requests list and none in its details. A request
translated for Vertex AI, which is always asked on streamGenerateContent
(the next commits), would have had none either. GenerateContent matches
too now.
Verified: ledger-protocol.test.cjs's two new rows, Gemini CLI's streamed
path ("Gemini") and a Chat request sent on to Vertex AI ("Chat →
Gemini"), both come out untagged with the old pattern and pass with this
one, in Chromium and WebKit, en and zh.
This commit is contained in:
@@ -15593,9 +15593,11 @@ function ledServed(r) {
|
||||
// out on, and the one its agent spoke when that was another: the
|
||||
// endpoint reads "/v1/chat/completions → /v1/messages" for a request
|
||||
// translated, the agent's own path alone for one sent as it came (蓝猫 on
|
||||
// Discord). null for a request with no path kept, a session file's.
|
||||
// Discord). null for a request with no path kept, a session file's. Gemini's
|
||||
// is generateContent, or streamGenerateContent streamed (Gemini CLI's,
|
||||
// Vertex AI's).
|
||||
const ledProtoOf = (path) => /\/messages\b/.test(path) ? "Anthropic" : /\/responses\b/.test(path) ? "Responses"
|
||||
: /\/chat\/completions\b/.test(path) ? "Chat" : /generateContent|\/generate\b/.test(path) ? "Gemini" : "";
|
||||
: /\/chat\/completions\b/.test(path) ? "Chat" : /[gG]enerateContent|\/generate\b/.test(path) ? "Gemini" : "";
|
||||
function ledProtos(r) {
|
||||
if (!r.ep || r.source === "log") return null;
|
||||
const [a, b] = String(r.ep).split(" → ");
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// The protocol each request was sent upstream in (蓝猫 on Discord: 「请求」
|
||||
// 列表里每条请求显示它用的是 Anthropic / Responses / Chat 哪种协议): the
|
||||
// Usage page's Requests list tags each row with it, "Chat → Anthropic"
|
||||
// for one translated from the agent's own, and a request's details name
|
||||
// it beside the upstream's own stop reason. A row read from a session
|
||||
// file, which has no path, has no tag. No click moves the page, no
|
||||
// left-border accent. English and Chinese; the API is faked.
|
||||
// for one translated from the agent's own, Gemini for one on Gemini's
|
||||
// streamGenerateContent (Gemini CLI's, Vertex AI's), and a request's
|
||||
// details name it beside the upstream's own stop reason. A row read from
|
||||
// a session file, which has no path, has no tag. No click moves the page,
|
||||
// no left-border accent. English and Chinese; the API is faked.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -25,7 +26,11 @@ const ROWS = [
|
||||
row(0, "/v1/chat/completions → /v1/messages", "end_turn"),
|
||||
row(1, "/v1/messages", "tool_use"),
|
||||
row(2, "/v1/responses", ""),
|
||||
row(3, "", "", { source: "log", status: 0, provider: "", providerName: "" }),
|
||||
row(3, "/v1beta/models/gemini-2.5-pro:streamGenerateContent", "STOP",
|
||||
{ provider: "google", providerName: "Google Gemini", req: "google/gemini-2.5-pro", model: "gemini-2.5-pro", served: "gemini-2.5-pro" }),
|
||||
row(4, "/v1/chat/completions → /publishers/google/models/gemini-3.8-flash:streamGenerateContent?alt=sse", "STOP",
|
||||
{ provider: "google-vertex", providerName: "Google Vertex AI", req: "google-vertex/gemini-3.8-flash", model: "gemini-3.8-flash", served: "gemini-3.8-flash" }),
|
||||
row(5, "", "", { source: "log", status: 0, provider: "", providerName: "" }),
|
||||
];
|
||||
|
||||
function serve(lang) {
|
||||
@@ -85,7 +90,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// the list: every request the gateway logged says its protocol
|
||||
const tags = await rows.evaluateAll((rs) => rs.map((r) => r.querySelector(".src.proto")?.textContent || ""));
|
||||
assert.deepEqual(tags, ["Chat → Anthropic", "Anthropic", "Responses", ""]);
|
||||
assert.deepEqual(tags, ["Chat → Anthropic", "Anthropic", "Responses", "Gemini", "Chat → Gemini", ""]);
|
||||
const look = await page.locator(".led .src.proto").evaluateAll((es) => es.map((e) => {
|
||||
const cell = e.closest("td").getBoundingClientRect(), b = e.getBoundingClientRect(), cs = getComputedStyle(e);
|
||||
return { inCell: b.left >= cell.left - 0.5 && b.right <= cell.right + 0.5 && b.width > 0, full: e.clientWidth >= e.scrollWidth, border: cs.borderLeftWidth, top: cs.borderTopWidth, title: e.title };
|
||||
@@ -115,7 +120,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(await dd(0, [want[lang].proto, want[lang].stop]), ["Chat → Anthropic", "end_turn"]);
|
||||
assert.deepEqual(await dd(1, [want[lang].proto, want[lang].stop]), ["Anthropic", "tool_use"]);
|
||||
assert.deepEqual(await dd(2, [want[lang].proto, want[lang].stop]), ["Responses", ""]);
|
||||
assert.deepEqual(await dd(3, [want[lang].proto, want[lang].stop]), ["", ""]);
|
||||
assert.deepEqual(await dd(3, [want[lang].proto, want[lang].stop]), ["Gemini", "STOP"]);
|
||||
assert.deepEqual(await dd(4, [want[lang].proto, want[lang].stop]), ["Chat → Gemini", "STOP"]);
|
||||
assert.deepEqual(await dd(5, [want[lang].proto, want[lang].stop]), ["", ""]);
|
||||
if (process.env.ARTIFACT_DIR) await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-protocol-list.png`) });
|
||||
for (const l of ["zh", "ja", "de"]) {
|
||||
const missing = await page.evaluate((l) => ["Protocol", "Upstream stop reason",
|
||||
|
||||
Reference in New Issue
Block a user