fix(platform): 模型能力 - 修复前台默认参数与后台空状态

This commit is contained in:
ddCat
2026-08-19 09:08:34 +08:00
parent d2a089f1ec
commit 6a698129bd
14 changed files with 518 additions and 120 deletions

View File

@@ -83,6 +83,36 @@ func TestDefaultVideoCapabilityUsesProtocolSpecificResolutionTiers(t *testing.T)
}
}
func TestCapabilitySpecFromModelCapabilityConfigRestoresLegacyWildcardImageSizes(t *testing.T) {
config := &ModelCapabilityConfig{
Version: 1,
Image: &ImageCapabilityConfig{
Size: ImageSizeConfig{Parameter: "size", Values: []string{"*"}, AllowCustom: true},
},
}
spec, err := CapabilitySpecFromModelCapabilityConfig(config, "image")
if err != nil {
t.Fatalf("CapabilitySpecFromModelCapabilityConfig() error = %v", err)
}
constraint, ok := spec.Options["size"]
if !ok {
t.Fatal("size constraint is missing")
}
values := make(map[string]int)
for _, value := range constraint.Values {
values[fmt.Sprint(value)]++
}
for _, value := range legacyImageSizeValues() {
if values[value] != 1 {
t.Fatalf("size constraint missing %q: %v", value, constraint.Values)
}
}
if values["*"] != 1 {
t.Fatalf("size constraint wildcard count = %d, values = %v", values["*"], constraint.Values)
}
}
func TestNormalizeResolutionSupportsCommonAliases(t *testing.T) {
tests := map[string]string{
"1440": "1440p",
@@ -145,8 +175,8 @@ func TestCapabilitySpecFromModelCapabilityConfigProjectsImageSizeOnce(t *testing
if err != nil {
t.Fatalf("CapabilitySpecFromModelCapabilityConfig() error = %v", err)
}
if got := spec.Options["size"].Values; len(got) != 1 || got[0] != "*" {
t.Fatalf("size projection = %#v, want wildcard", got)
if got := spec.Options["size"].Values; len(got) != 3 || got[0] != "1:1" || got[1] != "16:9" || got[2] != "*" {
t.Fatalf("size projection = %#v, want configured values plus wildcard", got)
}
if got := spec.Inputs["image"].Max; got != 3 {
t.Fatalf("image input max = %d, want 3", got)
@@ -169,8 +199,8 @@ func TestCapabilitySpecFromModelCapabilityConfigProjectsCustomImageSizeAsWildcar
if err != nil {
t.Fatalf("CapabilitySpecFromModelCapabilityConfig() error = %v", err)
}
if got := spec.Options["size"].Values; len(got) != 1 || got[0] != "*" {
t.Fatalf("custom size projection = %#v, want wildcard", got)
if got := spec.Options["size"].Values; len(got) != 2 || got[0] != "1:1" || got[1] != "*" {
t.Fatalf("custom size projection = %#v, want configured value plus wildcard", got)
}
}