feat: media expansion surfaces — edit mask, upscale, background removal, interpolation, diarization, meshgen (ADR-0020)
- imagegen.EditRequest.Mask -> sd-server img2img inpainting (white=repaint) - imagegen.Upscaler + BackgroundRemover, videogen.Interpolator, audio.DiarizationModel: new optional provider-minted surfaces - NEW meshgen leaf package (image->3D, glb/stl/obj) - provider/llamaswap: all five via the /upstream/<model>/<path> passthrough (upstreamPath helper, shared one-file multipart builder); binary success bodies validated (non-image, non-video, JSON-mesh rejection); diarization pins output=json (vtt/srt drop speaker labels) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -108,3 +108,47 @@ func TestImageEditValidation(t *testing.T) {
|
||||
t.Errorf("out-of-range strength: err = %v, want ErrUnsupported", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageEditWithMask(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(`{"images":["` + onePixelPNG + `"]}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
p := New(WithBaseURL(srv.URL), WithHTTPClient(srv.Client()))
|
||||
im, _ := p.ImageModel("sd")
|
||||
ed := im.(imagegen.Editor)
|
||||
|
||||
mask := imagegen.Image{MIME: "image/png", Data: []byte{0xDE, 0xAD}}
|
||||
if _, err := ed.Edit(context.Background(),
|
||||
imagegen.EditRequest{Prompt: "replace the sky", Init: editInit(t)},
|
||||
imagegen.WithEditMask(mask),
|
||||
); err != nil {
|
||||
t.Fatalf("Edit: %v", err)
|
||||
}
|
||||
if got := gotBody["mask"]; got != base64.StdEncoding.EncodeToString(mask.Data) {
|
||||
t.Errorf("mask = %v, want the b64 mask", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageEditWithoutMaskOmitsField(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(`{"images":["` + onePixelPNG + `"]}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
p := New(WithBaseURL(srv.URL), WithHTTPClient(srv.Client()))
|
||||
im, _ := p.ImageModel("sd")
|
||||
ed := im.(imagegen.Editor)
|
||||
if _, err := ed.Edit(context.Background(),
|
||||
imagegen.EditRequest{Prompt: "p", Init: editInit(t)}); err != nil {
|
||||
t.Fatalf("Edit: %v", err)
|
||||
}
|
||||
if _, ok := gotBody["mask"]; ok {
|
||||
t.Error("mask field sent for unmasked edit; want omitted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user