Route direct image-edit requests through the img2img pipeline

Direct `models/infer` image requests were defaulting to `image.text2image`, which dropped reference inputs and produced unrelated generations. Route image-edit payloads to `image.img2img`, accept canonical `image` URLs during reference resolution, and preserve reference-aware prompt hints.

Constraint: The test server must continue accepting both canonical `image` and legacy alias fields from callers already in circulation
Rejected: Fix only reference URL parsing | direct overrides would still be misrouted as text2image before reference resolution runs
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Any future image-model route inference must inspect input shape before defaulting to text2image
Tested: `env GOCACHE=/tmp/popiartserver-gocache go test ./internal/server -run 'TestInferRouteKeyForModelRecognizesViduAsVideo|TestInferRouteKeyForModelRecognizesImageEditInputs|TestResolveImageToImageReferenceAcceptsCanonicalImageURL|TestGenerateEditedImageRefsUsesSeedreamImagesGenerationsEndpoint'`; deployed to `101.42.99.35` and verified Seedream gateway requests include `image`
Not-tested: Full manual validation against every non-Seedream image-edit provider
This commit is contained in:
wtgoku
2026-04-13 17:08:07 +08:00
parent 214ffa1dfc
commit a73b85c45f
3 changed files with 69 additions and 4 deletions
+16 -1
View File
@@ -31,8 +31,23 @@ func TestInferRouteKeyForModelRecognizesViduAsVideo(t *testing.T) {
}
for modelID, want := range cases {
if got := inferRouteKeyForModel(modelID); got != want {
if got := inferRouteKeyForModel(modelID, nil); got != want {
t.Fatalf("inferRouteKeyForModel(%q) = %q, want %q", modelID, got, want)
}
}
}
func TestInferRouteKeyForModelRecognizesImageEditInputs(t *testing.T) {
cases := []map[string]any{
{"image": "https://example.com/reference.jpg"},
{"image_url": "https://example.com/reference.jpg"},
{"reference_image_url": "https://example.com/reference.jpg"},
{"source_artifact_id": "art_123"},
}
for _, input := range cases {
if got := inferRouteKeyForModel("seedream-4-5-251128", input); got != "image.img2img" {
t.Fatalf("inferRouteKeyForModel(seedream, %#v) = %q, want image.img2img", input, got)
}
}
}