heyiwei5 on X: "快速检测 联网搜索 是不是只检测第一个api 多个api的话 是不是不能检测?"
The Web search check ran one search (webSearch), which stops at the first
searcher that answers, so a second search API was never asked and a broken
one read as ok.
CheckPipeline's search now goes through checkSearch: it asks each searcher
a search can go to once, at the same time, by the path a search takes to
it, with no other standing in: the provider that searches (searcher, via
searchBy) unless provider search is off, and each search API on
(provider.SearchAPIs, via askSearchAPIKeys), in the order a search asks
them. The answer gains `searches` (name, ok, ms, error); the check is ok
only when every one is. Nothing set up, or the plugin off, says so as
before. pipecheck.js draws one line per searcher under the Web search row,
"Exa · 1.5 s" or "Tavily · <its error>" in red. Test and Test all are the
only things that ask, one call per searcher. No new strings. Documented
in docs/subsystems/gateway-routing.md.
Run (mica):
- TestCheckSearchAsksEveryAPI red on the old pipeline_check.go ("a broken
API reads as ok: {"kind":"search","ok":true}"), green now.
- pipeline-check.test.cjs red on the old pipecheck.js (0/16), green now
with i18n-keys.test.cjs, chromium + webkit, en/zh/zh-TW/ja/de, 1100px
and 400px.
- At 56c988cb5: go test -timeout 45m ./internal/gateway ./internal/gui
./internal/cli ok; search-*.test.cjs and i18n-en-no-cjk both engines:
284 pass, search-mcp-library webkit 420px "Turn on the Library" red,
also red on a clean origin/main 9c4e87736 copy (open as #4756).
- Rebased on 9c4e87736 (this head's parent): go test -run
'Check|Search|Pipeline|Searcher' ./internal/gateway, go test
./internal/gui ./internal/cli, pipeline-check + i18n-keys in chromium
and webkit: all ok.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows for
internal/gateway.
Not tried: a real provider searcher or real search API keys (fakes only).
80 lines
3.2 KiB
JavaScript
80 lines
3.2 KiB
JavaScript
// Settings › Models' Quick check (EV_John_Liu on X): each pipeline besides
|
||
// chat checked with one real call through the gateway (/api/pipelines/
|
||
// check): a one-dot drawing, a second of silence to transcribe, a word to
|
||
// speak, one web search. Each costs what the call costs, so only a press
|
||
// runs one, never a draw. app.js imports this when Settings draws Models.
|
||
|
||
const pipes = [["image", "Image generation"], ["transcription", "Speech to text"], ["speech", "Text to speech"], ["search", "Web search"]];
|
||
const pipeChecks = {}; // kind → { busy } or what the check found
|
||
|
||
function pipeRun(kind) {
|
||
if (pipeChecks[kind]?.busy) return;
|
||
pipeChecks[kind] = { busy: true };
|
||
pipeCheckFill();
|
||
api("pipelines/check", { kind })
|
||
.then((r) => { pipeChecks[kind] = r; }, (e) => { pipeChecks[kind] = { error: t(e.message) }; })
|
||
.finally(pipeCheckFill);
|
||
}
|
||
|
||
// pipeSaid: what a check found, and whether it is a failure
|
||
function pipeSaid(c) {
|
||
if (c?.searches?.length) return [c.searches.map(pipePartSaid).map(([text]) => text).join("\n"), !c.ok];
|
||
if (!c || c.busy) return ["", false];
|
||
if (c.ok) return [(c.model ? c.model + " · " : "") + ledTook(c.ms), false];
|
||
if (c.unset) return [t(c.error), false];
|
||
return [(c.model ? c.model + " · " : "") + (c.status ? c.status + " · " : "") + t(c.error || ""), true];
|
||
}
|
||
|
||
// pipePartSaid: what one searcher's search found in the web search check
|
||
// (heyiwei5 on X: each search API is checked, not only the first)
|
||
function pipePartSaid(r) {
|
||
return [r.name + " · " + (r.ok ? ledTook(r.ms) : t(r.error || "")), !r.ok];
|
||
}
|
||
|
||
// pipeCheckFill draws the rows into #pipeCheckList, once, and then each
|
||
// row's state in place, so a press keeps its focus
|
||
window.pipeCheckFill = function () {
|
||
const box = document.getElementById("pipeCheckList");
|
||
if (!box) return;
|
||
const all = document.getElementById("pipeCheckAll");
|
||
all.onclick = () => pipes.forEach(([k]) => pipeRun(k));
|
||
all.disabled = pipes.every(([k]) => pipeChecks[k]?.busy);
|
||
if (!box.children.length) {
|
||
for (const [kind, name] of pipes) {
|
||
const row = el("div", "row pref pipe-check");
|
||
row.dataset.pipe = kind;
|
||
const who = el("div", "who");
|
||
const line = el("div", "sub say pipe-said");
|
||
line.setAttribute("role", "status");
|
||
who.append(el("div", "name", t(name)), line);
|
||
const b = el("button", "text pipe-test");
|
||
b.type = "button";
|
||
b.onclick = () => pipeRun(kind);
|
||
row.append(who, b);
|
||
box.append(row);
|
||
}
|
||
}
|
||
for (const row of box.children) {
|
||
const c = pipeChecks[row.dataset.pipe];
|
||
const b = row.querySelector(".pipe-test"), line = row.querySelector(".pipe-said");
|
||
b.textContent = c?.busy ? t("Testing…") : t("Test");
|
||
b.disabled = !!c?.busy;
|
||
const [text, bad] = pipeSaid(c);
|
||
line.hidden = !text;
|
||
line.title = text;
|
||
// the web search check says each searcher's on a line of its own
|
||
if (c?.searches?.length) {
|
||
line.replaceChildren(...c.searches.map((r) => {
|
||
const [said, off] = pipePartSaid(r);
|
||
const part = el("div", "pipe-part", said);
|
||
part.classList.toggle("err", off);
|
||
return part;
|
||
}));
|
||
line.classList.remove("err");
|
||
} else {
|
||
line.textContent = text;
|
||
line.classList.toggle("err", bad);
|
||
}
|
||
}
|
||
};
|