diff --git a/backend/internal/service/model_capability.go b/backend/internal/service/model_capability.go index 7bf4ff3d6..f48976315 100644 --- a/backend/internal/service/model_capability.go +++ b/backend/internal/service/model_capability.go @@ -540,6 +540,9 @@ func ratioValue(value string) float64 { func normalizeResolution(value string) string { value = strings.ToLower(strings.TrimSpace(value)) value = strings.TrimSuffix(value, "p") + if value == "2k" { + return "1440p" + } if value == "4k" { return "2160p" } diff --git a/backend/internal/service/model_capability_test.go b/backend/internal/service/model_capability_test.go index 296620569..51057c318 100644 --- a/backend/internal/service/model_capability_test.go +++ b/backend/internal/service/model_capability_test.go @@ -82,3 +82,18 @@ func TestDefaultVideoCapabilityUsesProtocolSpecificResolutionTiers(t *testing.T) }) } } + +func TestNormalizeResolutionSupportsCommonAliases(t *testing.T) { + tests := map[string]string{ + "1440": "1440p", + "1440p": "1440p", + "2K": "1440p", + "4K": "2160p", + "768P": "768p", + } + for input, want := range tests { + if got := normalizeResolution(input); got != want { + t.Fatalf("normalizeResolution(%q) = %q, want %q", input, got, want) + } + } +} diff --git a/web/src/components/model-capability-editor.tsx b/web/src/components/model-capability-editor.tsx index ba1757fa8..8186a2963 100644 --- a/web/src/components/model-capability-editor.tsx +++ b/web/src/components/model-capability-editor.tsx @@ -3,9 +3,9 @@ import type { ReactNode } from "react"; import { defaultImageCapabilityConfig, defaultModelCapabilityConfig, type ImageCapabilityConfig, type ModelCapabilityConfig, type VideoCapabilityConfig } from "@/lib/model-capabilities"; import type { ModelProtocol } from "@/lib/model-protocols"; +import { VIDEO_RESOLUTION_CAPABILITY_OPTIONS } from "@/lib/video-generation-options"; const ratioOptions = ["16:9", "9:16", "1:1", "4:3", "3:4", "21:9"]; -const resolutionOptions = ["480p", "720p", "1080p", "2160p"]; const operationOptions = [ { label: "文生视频", value: "text_to_video" }, { label: "图生视频", value: "image_to_video" }, @@ -35,6 +35,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability = const updateReferences = (patch: Partial) => update({ references: { ...profile.references, ...patch } }); const updateDuration = (patch: Partial) => update({ duration: { ...profile.duration, ...patch } }); const durationValues = (profile.duration.values || []).join(","); + const resolutionOptions = Array.from(new Set([...VIDEO_RESOLUTION_CAPABILITY_OPTIONS, ...profile.resolutions])); return (
@@ -75,7 +76,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability =
({ label: item, value: item }))} onChange={(defaultRatio) => update({ defaultRatio })} /> - ({ label: item.toUpperCase(), value: item }))} onChange={(resolutions) => update({ resolutions, defaultResolution: resolutions.includes(profile.defaultResolution) ? profile.defaultResolution : resolutions[0] || "720p" })} />