Files
magpie/internal/gui/pipecheck.go
T
yetone 2c644da040 settings: a Quick check tests image, speech, transcription and search with one real call (EV_John_Liu on X)
EV_John_Liu on X: "现在不是有图片生成、asr、tts管线和网络搜索。能不能做个快速
检测。可用". Settings › Models now ends with a Quick check: a row per
pipeline, each with Test, and Test all. A check makes the smallest real
call through the gateway, the way an agent's request goes:

- image generation: the image model in force (drawer), prompt "a dot", n 1
  (quality low for gpt-image);
- text to speech: the first enabled model that serves speech, "Hi.";
- speech to text: the first that serves transcription, 1s of silence as a
  16 kHz WAV;
- web search: one query through the searcher in force.

A row says ok with the model and how long it took, the vendor's error with
its status (provider.APIError's reading), or that nothing is set up. A 200
with an empty body is not ok. A check costs the user money, so it runs only
on a click: drawing the page calls nothing (the GUI test counts calls).
Disabled models are skipped. tts/whisper models are read from the
provider's own list, since the kept listing leaves them out.
POST /api/pipelines/check answers "Another magpie serves the gateway"
when this one doesn't serve it. pipecheck.js is loaded lazily, so the
core script budget is unchanged.

Run at this head (rebased on ce0cbff61). mote's disk was full (113 MB
free), so the Go and GUI runs went to the Linux box (WSL magpie-desktop):
- gofmt -l clean; go vet linux (-tags nogui) and windows on the Linux box,
  darwin on mote once it had room: all clean.
- go test -tags nogui ./internal/gui/ ok (2033s); go test -run
  'TestCheck|TestPipeline|TestAudio|TestSpeech|TestTranscri'
  ./internal/gateway/ ok; go build -tags nogui . ok.
- pipeline-check.test.cjs, chromium and webkit, en/zh/zh-TW/ja/de, 1100px
  and 400px: 16 of 16 ok. i18n-keys, search-key-list and video-gen-pick
  ok.
- Red the same at origin/main ce0cbff61, not this change: old-webkit
  (headerpresets.js #6030, Safari 15 :has() #5919), settings-search
  (/api/update/using, #5982), settings-hints ja/de 420px in both engines
  (#6073, Linux numbers added there).

The test brings a row into view with the wheel and waits for the scroll
to rest (WebKit's runs on after the event; script scrolls are put back
by app.js), then presses where the button is.

Broken by hand, each red, then restored:
- FirstServing ignoring the provider's own model list: SpeechSaysAWord,
  SpeechSaysTheVendorsError, TranscriptionSendsASecondOfSilence red.
- taking a disabled model: TestCheckSkipsADisabledModel red.
- any answer counted ok: SpeechSaysTheVendorsError red (OK:true Status:400).
- a check run when the page draws: pipeline-check.test.cjs 8 of 8 red in
  chromium (a row showing "Testing…").
- not red: a press that scrolls #view-settings, or that adds 60px above
  the list. app.js holds the clicked element in both cases, so the test's
  "stays put" check guards that app-wide rule (click-scroll owns it), not
  pipecheck.js.

Not tried: a real call to any vendor (fakes only); the real app window
on Windows, Linux or macOS; the whole GUI suite (only the files this can
reach, listed above).
2026-11-11 15:10:25 +08:00

33 lines
890 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package gui
import (
"encoding/json"
"errors"
"net/http"
"slices"
"github.com/yetone/magpie/internal/gateway"
)
// Settings › Models' Check (EV_John_Liu on X): each pipeline besides chat
// (image generation, speech-to-text, text-to-speech, web search) checked
// with one real call through the gateway, as an agent's would go. Each
// costs the user what the call costs, so only a press runs one.
func handlePipelineCheck(rw http.ResponseWriter, r *http.Request) {
var in struct{ Kind string }
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
fail(rw, err)
return
}
if !slices.Contains(gateway.Pipelines, in.Kind) {
fail(rw, errors.New("no such pipeline: "+in.Kind))
return
}
gw := served.Load()
if gw == nil {
fail(rw, errors.New("Another magpie serves the gateway: check there"))
return
}
writeJSON(rw, gw.CheckPipeline(r.Context(), in.Kind))
}