feat(canvas): 云端 Agent - 完成策略分层、节点能力注册与可解释审批改造
This commit is contained in:
@@ -514,6 +514,49 @@ func TestImageResponseKeepsBase64AsDataURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenAIImagesEditUsesJSONImageReferences(t *testing.T) {
|
||||
adapter := officialPackageAdapter(t, "openai-images.yingce-plugin", "openai-image")
|
||||
if !adapter.Metadata().RequiresPublicMediaURLs {
|
||||
t.Fatal("OpenAI Images reference inputs must be hydrated as public URLs")
|
||||
}
|
||||
spec, err := adapter.BuildCreate(context.Background(), RequestContext{Request: GenerationRequest{
|
||||
Model: "gpt-image-2.5",
|
||||
Prompt: "combine both references",
|
||||
Images: []MediaReference{
|
||||
{URL: "https://cdn.example/reference-1.png", Role: "edit_source", Order: 0},
|
||||
{URL: "https://cdn.example/reference-2.png", Role: "edit_source", Order: 1},
|
||||
{URL: "https://cdn.example/mask.png", Role: "mask", Order: 2},
|
||||
},
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if spec.Path != "/v1/images/edits" || spec.ContentType != "application/json" || len(spec.Files) != 0 {
|
||||
t.Fatalf("edit request = path:%q contentType:%q files:%#v", spec.Path, spec.ContentType, spec.Files)
|
||||
}
|
||||
body, ok := spec.Body.(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("body = %#v", spec.Body)
|
||||
}
|
||||
images, ok := body["images"].([]any)
|
||||
if !ok || len(images) != 2 {
|
||||
t.Fatalf("images = %#v", body["images"])
|
||||
}
|
||||
for index, want := range []string{"https://cdn.example/reference-1.png", "https://cdn.example/reference-2.png"} {
|
||||
image, ok := images[index].(map[string]any)
|
||||
if !ok || image["image_url"] != want {
|
||||
t.Fatalf("images[%d] = %#v, want image_url %q", index, images[index], want)
|
||||
}
|
||||
}
|
||||
mask, ok := body["mask"].(map[string]any)
|
||||
if !ok || mask["image_url"] != "https://cdn.example/mask.png" {
|
||||
t.Fatalf("mask = %#v", body["mask"])
|
||||
}
|
||||
if _, exists := body["response_format"]; exists {
|
||||
t.Fatalf("response_format should not be sent by default: %#v", body["response_format"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestAsyncMediaPollKeepsResultKind(t *testing.T) {
|
||||
cases := []struct {
|
||||
packageName, id, payload, want string
|
||||
|
||||
Reference in New Issue
Block a user