fix(llamaswap): use A1111 /sdapi/v1/txt2img so seed is honored
CI / Tidy (pull_request) Successful in 9m24s
CI / Build & Test (pull_request) Successful in 9m45s
Adversarial Review (Gadfly) / review (pull_request) Successful in 11m30s

The OpenAI /v1/images/generations endpoint ignores `seed` on our
stable-diffusion.cpp build — every render of a given prompt comes back
byte-identical, so a drawbot batch of N collapsed to one image. Switch the
image provider to sd-server's A1111 /sdapi/v1/txt2img endpoint, which honors
`seed` (verified live: distinct seeds -> distinct images on SDXL and
Qwen-Image). Size is split into width/height; llama-swap still routes by the
`model` field. Tests + ADR-0016 updated.
This commit is contained in:
2026-06-28 22:56:25 -04:00
parent a744cdc335
commit a213c18263
3 changed files with 74 additions and 52 deletions
+6 -9
View File
@@ -166,11 +166,11 @@ func TestRunningRaw(t *testing.T) {
func TestImageGenerate(t *testing.T) {
var gotBody map[string]any
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/v1/images/generations" {
if r.URL.Path != "/sdapi/v1/txt2img" {
t.Errorf("path = %q", r.URL.Path)
}
_ = json.NewDecoder(r.Body).Decode(&gotBody)
_, _ = w.Write([]byte(`{"created":1,"data":[{"b64_json":"` + onePixelPNG + `"}]}`))
_, _ = w.Write([]byte(`{"images":["` + onePixelPNG + `"]}`))
}))
defer srv.Close()
@@ -192,12 +192,9 @@ func TestImageGenerate(t *testing.T) {
if len(res.Images[0].Data) == 0 {
t.Error("decoded image has no bytes")
}
// response_format must be forced to b64_json, and options applied.
if gotBody["response_format"] != "b64_json" {
t.Errorf("response_format = %v, want b64_json", gotBody["response_format"])
}
if gotBody["size"] != "512x512" {
t.Errorf("size = %v, want 512x512", gotBody["size"])
// Size is split into width/height ints for the A1111 endpoint.
if gotBody["width"] != float64(512) || gotBody["height"] != float64(512) {
t.Errorf("width/height = %v/%v, want 512/512", gotBody["width"], gotBody["height"])
}
}
@@ -205,7 +202,7 @@ func TestImageGenerateSettings(t *testing.T) {
var gotBody map[string]any
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = json.NewDecoder(r.Body).Decode(&gotBody)
_, _ = w.Write([]byte(`{"created":1,"data":[{"b64_json":"` + onePixelPNG + `"}]}`))
_, _ = w.Write([]byte(`{"images":["` + onePixelPNG + `"]}`))
}))
defer srv.Close()