iFlytek's Loomy gateway serves three image generators, each listed in its /v1/models with type "image": Hy-Image-3.5-preview, doubao-seedream-5-lite, qwen-image-3.0-pro. An OpenAI-compatible plugin in front of it lists all three, and the reporter measured all three answering a normal OpenAI-shaped draw on the images API with a 200 and a URL each. qwen-image and seedream match catalog.ImagesAPI's words, so those two reach Settings' image generation picker and draw. hy-image matches only DrawsID's "image", so Hy-Image-3.5-preview stayed a chat model with no way to pick it for drawing — the same reason WorkBuddy's Hy-Image models need their wbDrawers path. Add "hy-image" to ImagesAPI's words: the model is then a drawer on the plugin's row like the other two, and the gateway asks it on the images API instead of chat. No other model's answer changes — every id the new word catches was already a drawer by DrawsID's broader "image"; only where it is asked moves. Test: TestLoomyPluginDraws (internal/gateway) installs a fake Loomy plugin listing the three generators beside a chat model, checks Drawers lists all three, and draws Hy-Image-3.5-preview (images API, image back, chat never asked). Broken by hand: without "hy-image" it is red (drawers [doubao-seedream-5-lite qwen-image-3.0-pro], the Hy-Image one missing). Review: applied as ggbdpq posted it (patch sha256 checked against the issue's). Broken by hand at the reviewed head: catalog.go reverted to its parent, TestLoomyPluginDraws red; restored, green. Run at the pushed tree (this stack of nine on origin/main3c2dceb34), on mote (macOS arm64, Go 1.26.8): - go test -count=1 -timeout 45m ./internal/catalog/... ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...: catalog, plugin and davsync ok; gateway red on one test only, TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's Codex identity reaches it in a full package run). It passes run alone at this tree, 3 of 3. - go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok. gofmt -l on every tracked .go file: clean. - The hand breaks above ran on this stack before its rebase onto3c2dceb34. That commit changed member.go only, nothing these tests reach. Not tried: the GUI suite, since no GUI file changed. Windows and Linux test runs (the Claude bridge tests use a shell fake and skip on Windows). No real vendor, Claude Code or network was used; every case runs against fakes. Generated-by: GLM-5.3-Flash (ZCode)
87 lines
2.8 KiB
Go
87 lines
2.8 KiB
Go
package gateway
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"io"
|
|
"net/http"
|
|
"slices"
|
|
"strings"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// loomy is iFlytek's Loomy gateway (#4913): an OpenAI model list naming
|
|
// three image generators beside its chat models, and an images API all
|
|
// three answer in OpenAI's shape (measured live: 200 with a URL each).
|
|
type loomy struct {
|
|
mu sync.Mutex
|
|
sent map[string][]string
|
|
}
|
|
|
|
func (v *loomy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
body, _ := io.ReadAll(r.Body)
|
|
v.mu.Lock()
|
|
if v.sent == nil {
|
|
v.sent = map[string][]string{}
|
|
}
|
|
v.sent[r.URL.Path] = append(v.sent[r.URL.Path], string(body))
|
|
v.mu.Unlock()
|
|
w.Header().Set("Content-Type", "application/json")
|
|
switch r.URL.Path {
|
|
case "/v1/models":
|
|
io.WriteString(w, `{"object":"list","data":[{"id":"Hy-Image-3.5-preview","object":"model"},{"id":"doubao-seedream-5-lite","object":"model"},{"id":"qwen-image-3.0-pro","object":"model"},{"id":"spark-lite-max","object":"model"}]}`)
|
|
case "/v1/images/generations":
|
|
io.WriteString(w, `{"created":1,"data":[{"b64_json":"`+base64.StdEncoding.EncodeToString(pngBytes)+`"}]}`)
|
|
default:
|
|
w.WriteHeader(404)
|
|
}
|
|
}
|
|
|
|
func (v *loomy) got(path string) []string {
|
|
v.mu.Lock()
|
|
defer v.mu.Unlock()
|
|
return append([]string(nil), v.sent[path]...)
|
|
}
|
|
|
|
// The Loomy plugin lists all three image generators its gateway serves
|
|
// (#4913): qwen-image and seedream draw on the images API as any such
|
|
// model does, and Hy-Image-3.5-preview, named for images only by
|
|
// "hy-image", draws there too — not left a chat model with no way to
|
|
// pick it for drawing.
|
|
func TestLoomyPluginDraws(t *testing.T) {
|
|
t.Setenv("FAKE_LOOMY", "1")
|
|
v := &loomy{}
|
|
pid := besideFake(t, "loomy", v)
|
|
p, err := provider.Find(pid)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var drawers []string
|
|
for _, m := range Drawers(*p) {
|
|
if m.Provider != pid {
|
|
t.Fatalf("drawer %s of %q", m.ID, m.Provider)
|
|
}
|
|
drawers = append(drawers, m.ID)
|
|
}
|
|
slices.Sort(drawers)
|
|
if want := []string{"Hy-Image-3.5-preview", "doubao-seedream-5-lite", "qwen-image-3.0-pro"}; !slices.Equal(drawers, want) {
|
|
t.Fatalf("drawers %v, want %v", drawers, want)
|
|
}
|
|
s := New()
|
|
code, a, raw := postImages(t, s, "/v1/images/generations", "application/json", `{"model":"`+pid+`/Hy-Image-3.5-preview","prompt":"a magpie","size":"1024x1024"}`)
|
|
if code != 200 || len(a.Data) != 1 {
|
|
t.Fatalf("%d %s", code, raw)
|
|
}
|
|
if b, _ := base64.StdEncoding.DecodeString(a.Data[0].B64); string(b) != string(pngBytes) {
|
|
t.Fatalf("image %q", b)
|
|
}
|
|
if sent := v.got("/v1/images/generations"); len(sent) != 1 || !strings.Contains(sent[0], `"model":"Hy-Image-3.5-preview"`) {
|
|
t.Fatalf("generation was sent %v", sent)
|
|
}
|
|
if sent := v.got("/v1/chat/completions"); len(sent) != 0 {
|
|
t.Fatalf("an image model was asked on chat: %v", sent)
|
|
}
|
|
}
|