fix(kling): 补齐全模态基础视频能力
ci / verify (pull_request) Failing after 4m10s
ci / verify (pull_request) Failing after 4m10s
让 omni_video 模型默认同时注册 video_generate 与 image_to_video,兼容通用视频接口在不显式传 modelType 时的能力推断。 新增迁移同步可灵 O1 与 3.0 Omni 的基础目录、平台映射、能力详情和默认快照;集成测试覆盖两个模型的无 modelType 文生视频与图生视频。
This commit is contained in:
@@ -29,6 +29,23 @@ func TestKlingCompatibilitySimulationFlow(t *testing.T) {
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
var upgradedBaseModels int
|
||||
if err := db.Pool().QueryRow(ctx, `
|
||||
SELECT count(*)
|
||||
FROM base_model_catalog
|
||||
WHERE provider_key = 'keling'
|
||||
AND provider_model_name IN ('kling-video-o1', 'kling-v3-omni')
|
||||
AND model_type @> '["video_generate","image_to_video","omni_video"]'::jsonb
|
||||
AND capabilities ? 'video_generate'
|
||||
AND capabilities ? 'image_to_video'
|
||||
AND capabilities ? 'omni_video'
|
||||
AND metadata->'rawModel'->'types' @> '["video_generate","image_to_video","omni_video"]'::jsonb`).Scan(&upgradedBaseModels); err != nil {
|
||||
t.Fatalf("read upgraded Kling Omni base model capabilities: %v", err)
|
||||
}
|
||||
if upgradedBaseModels != 2 {
|
||||
t.Fatalf("expected both Kling Omni base models to expose base video capabilities, got %d", upgradedBaseModels)
|
||||
}
|
||||
|
||||
serverCtx, cancelServer := context.WithCancel(ctx)
|
||||
defer cancelServer()
|
||||
server := httptest.NewServer(NewServerWithContext(serverCtx, config.Config{
|
||||
@@ -89,6 +106,54 @@ func TestKlingCompatibilitySimulationFlow(t *testing.T) {
|
||||
"displayName": model,
|
||||
}, http.StatusCreated, nil)
|
||||
}
|
||||
var upgradedPlatformModels int
|
||||
if err := db.Pool().QueryRow(ctx, `
|
||||
SELECT count(*)
|
||||
FROM platform_models
|
||||
WHERE platform_id = $1::uuid
|
||||
AND model_type @> '["video_generate","image_to_video","omni_video"]'::jsonb
|
||||
AND capabilities ? 'video_generate'
|
||||
AND capabilities ? 'image_to_video'
|
||||
AND capabilities ? 'omni_video'`, platform.ID).Scan(&upgradedPlatformModels); err != nil {
|
||||
t.Fatalf("read upgraded Kling Omni platform model capabilities: %v", err)
|
||||
}
|
||||
if upgradedPlatformModels != 2 {
|
||||
t.Fatalf("expected both Kling Omni platform models to expose base video capabilities, got %d", upgradedPlatformModels)
|
||||
}
|
||||
|
||||
assertGenericVideoGeneration := func(name string, model string, image string, expectedModelType string) {
|
||||
t.Helper()
|
||||
t.Run(name, func(t *testing.T) {
|
||||
request := map[string]any{
|
||||
"model": model,
|
||||
"prompt": "通用视频接口模拟任务",
|
||||
"duration": 5,
|
||||
"resolution": "720p",
|
||||
"runMode": "simulation",
|
||||
"simulation": true,
|
||||
"simulationDurationMs": 5,
|
||||
}
|
||||
if image != "" {
|
||||
request["image"] = image
|
||||
}
|
||||
var response struct {
|
||||
Task struct {
|
||||
Status string `json:"status"`
|
||||
ModelType string `json:"modelType"`
|
||||
ResolvedModel string `json:"resolvedModel"`
|
||||
} `json:"task"`
|
||||
}
|
||||
doJSON(t, server.URL, http.MethodPost, "/api/v1/videos/generations", apiKeyResponse.Secret, request, http.StatusAccepted, &response)
|
||||
if response.Task.Status != "succeeded" || response.Task.ModelType != expectedModelType || response.Task.ResolvedModel != model {
|
||||
t.Fatalf("generic video request without modelType should use inferred capability: %+v", response.Task)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
for _, model := range []string{klingO1Model, klingV3OmniModel} {
|
||||
assertGenericVideoGeneration(model+"-text-to-video", model, "", "video_generate")
|
||||
assertGenericVideoGeneration(model+"-image-to-video", model, "https://example.com/first.png", "image_to_video")
|
||||
}
|
||||
|
||||
createV1 := func(model string, duration int, externalID string) string {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user