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 once0cbff61). 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/maince0cbff61, 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).
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package gui
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/gateway"
|
|
)
|
|
|
|
// POST /api/pipelines/check takes only a pipeline magpie serves, and with
|
|
// no gateway of its own (another magpie serves it) says where to check.
|
|
func TestPipelineCheckRoute(t *testing.T) {
|
|
onePortHome(t)
|
|
prev := served.Swap(nil)
|
|
t.Cleanup(func() { served.Store(prev) })
|
|
post := func(body string) (int, string) {
|
|
w := httptest.NewRecorder()
|
|
handlePipelineCheck(w, httptest.NewRequest("POST", "/api/pipelines/check", strings.NewReader(body)))
|
|
return w.Code, w.Body.String()
|
|
}
|
|
if code, body := post(`{"kind":"chat"}`); code < 400 || !strings.Contains(body, "no such pipeline") {
|
|
t.Fatalf("an unknown kind: %d %s", code, body)
|
|
}
|
|
if code, body := post(`{"kind":"speech"}`); code < 400 || !strings.Contains(body, "Another magpie serves the gateway") {
|
|
t.Fatalf("no gateway here: %d %s", code, body)
|
|
}
|
|
served.Store(gateway.New())
|
|
code, body := post(`{"kind":"speech"}`)
|
|
var c gateway.PipelineCheck
|
|
if err := json.Unmarshal([]byte(body), &c); err != nil || code != 200 || c.Kind != "speech" || !c.Unset {
|
|
t.Fatalf("a fresh home has no speech model: %d %s", code, body)
|
|
}
|
|
}
|