feat: support image quality control
This commit is contained in:
@@ -660,3 +660,56 @@ func TestParamProcessorImageResolutionAndOutputCount(t *testing.T) {
|
||||
t.Fatalf("image count should be capped to 4, got %+v", processed["n"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestParamProcessorImageQualityControl(t *testing.T) {
|
||||
body := map[string]any{
|
||||
"model": "mock-image",
|
||||
"prompt": "draw",
|
||||
"quality": "high",
|
||||
}
|
||||
|
||||
unsupported := preprocessRequestWithLog("images.generations", body, store.RuntimeModelCandidate{
|
||||
ModelType: "image_generate",
|
||||
Capabilities: map[string]any{
|
||||
"image_generate": map[string]any{
|
||||
"output_resolutions": []any{"1K"},
|
||||
},
|
||||
},
|
||||
})
|
||||
if _, ok := unsupported.Body["quality"]; ok {
|
||||
t.Fatalf("quality should be removed when capability does not support it: %+v", unsupported.Body)
|
||||
}
|
||||
if len(unsupported.Log.Changes) == 0 || unsupported.Log.Changes[len(unsupported.Log.Changes)-1].CapabilityPath != "capabilities.image_generate.support_quality_control" {
|
||||
t.Fatalf("expected quality removal to be logged against support_quality_control, got %+v", unsupported.Log.Changes)
|
||||
}
|
||||
|
||||
supported := preprocessRequest("images.generations", body, store.RuntimeModelCandidate{
|
||||
ModelType: "image_generate",
|
||||
Capabilities: map[string]any{
|
||||
"image_generate": map[string]any{
|
||||
"support_quality_control": true,
|
||||
"output_resolutions": []any{"1K"},
|
||||
},
|
||||
},
|
||||
})
|
||||
if supported["quality"] != "high" {
|
||||
t.Fatalf("quality should be retained when capability supports it: %+v", supported)
|
||||
}
|
||||
|
||||
incompatible := preprocessRequest("images.generations", map[string]any{
|
||||
"model": "mock-image",
|
||||
"prompt": "draw",
|
||||
"quality": "standard",
|
||||
}, store.RuntimeModelCandidate{
|
||||
ModelType: "image_generate",
|
||||
Capabilities: map[string]any{
|
||||
"image_generate": map[string]any{
|
||||
"support_quality_control": true,
|
||||
"output_resolutions": []any{"1K"},
|
||||
},
|
||||
},
|
||||
})
|
||||
if _, ok := incompatible["quality"]; ok {
|
||||
t.Fatalf("OpenAI-compatible GPT image quality should reject standard: %+v", incompatible)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user