fix(video): 视频任务 - 规范化数字清晰度价格档

This commit is contained in:
ddcat666
2026-09-27 20:09:41 +08:00
parent 414d367416
commit a0ba303b02
3 changed files with 51 additions and 0 deletions

View File

@@ -133,6 +133,13 @@ func normalizeModelRequestOption(name string, value any) any {
case "4k", "2160", "2160p":
return "2160p"
default:
// Providers expose additional resolutions such as 768P and 960P.
// Canonicalize numeric P values generically so billing selectors match
// regardless of whether the client sends "960" or "960P".
pixels := strings.TrimSuffix(strings.ToLower(strings.TrimSpace(resolution)), "p")
if numeric, err := strconv.Atoi(pixels); err == nil && numeric > 0 {
return strconv.Itoa(numeric) + "p"
}
return value
}
}

View File

@@ -62,6 +62,21 @@ func TestModelRequestIntentNormalizesVideoResolution(t *testing.T) {
}
}
func TestModelRequestIntentNormalizesNumericVideoResolution(t *testing.T) {
for value, want := range map[string]string{
"768": "768p", "768p": "768p", "768P": "768p",
"960": "960p", "960P": "960p",
} {
intent := ModelRequestIntentFromTaskInput(map[string]any{
"mode": "video",
"config": map[string]any{"vquality": value},
}, "canvas_video", "image_to_video")
if got := intent.Options["vquality"]; got != want {
t.Errorf("vquality %q normalized to %#v, want %s", value, got, want)
}
}
}
func TestModelRequestIntentNormalizesImageSpecificationValues(t *testing.T) {
input := map[string]any{
"mode": "image",

View File

@@ -172,6 +172,35 @@ func TestResolveSystemChannelModelSelectionRebuildsAuthoritativeExecutionSpec(t
}
}
func TestResolveSystemChannelModelSelectionMatchesMiniMax768PTier(t *testing.T) {
profile := DefaultModelCapabilityConfigForModel(string(model.ChannelInterfaceMiniMaxVideo), "MiniMax-H3")
svc, _, channel, channelModel := createSystemChannelSelectionFixture(t, "video", model.ChannelInterfaceMiniMaxVideo, profile, []model.ChannelModelPriceTier{
newSelectionPriceTier("tier-768p", `{"vquality":"768p"}`, "MiniMax-H3", "per_second"),
newSelectionPriceTier("tier-2k", `{"vquality":"1440p"}`, "MiniMax-H3", "per_second"),
})
resolved, err := svc.resolveSystemChannelModelSelection(map[string]any{
"mode": "video",
"referenceImages": []any{map[string]any{"storageKey": "resource:test"}},
"config": map[string]any{
"channelId": channel.ID,
"model": channelModel.ModelKey,
"vquality": "768",
"videoSeconds": "15",
},
}, "canvas_video", "image_to_video")
if err != nil {
t.Fatalf("resolveSystemChannelModelSelection() error = %v", err)
}
config := resolved["config"].(map[string]any)
if config["priceTierId"] != "tier-768p" {
t.Fatalf("priceTierId = %#v, want tier-768p", config["priceTierId"])
}
if config["vquality"] != "768" {
t.Fatalf("execution vquality = %#v, want original provider-facing value 768", config["vquality"])
}
}
func TestResolveSystemChannelModelSelectionAppliesServerDefaults(t *testing.T) {
profile := DefaultModelCapabilityConfigForModel(string(model.ChannelInterfaceGrokImage), "grok-image")
svc, _, channel, channelModel := createSystemChannelSelectionFixture(t, "image", model.ChannelInterfaceGrokImage, profile, []model.ChannelModelPriceTier{