feat(gateway): sync Seedance 2.0 capabilities

This commit is contained in:
2026-06-30 21:20:09 +08:00
parent 24eb68cc09
commit 797edeedf4
4 changed files with 526 additions and 1 deletions
+31 -1
View File
@@ -1660,6 +1660,7 @@ func TestVolcesVideoBodyAllowsOnlyTaskPayloadFields(t *testing.T) {
"cameraFixed": false,
"watermark": true,
"seed": -1,
"tools": []any{map[string]any{"type": "web_search"}},
"task_id": "local-task-id",
"runMode": "simulation",
"fps": 24,
@@ -1707,7 +1708,7 @@ func TestVolcesVideoBodyAllowsOnlyTaskPayloadFields(t *testing.T) {
allowedTopLevel := map[string]bool{
"model": true, "content": true, "callback_url": true, "return_last_frame": true, "execution_expires_after": true,
"generate_audio": true, "draft": true, "resolution": true, "ratio": true, "duration": true,
"seed": true, "camera_fixed": true, "watermark": true,
"seed": true, "camera_fixed": true, "watermark": true, "tools": true,
}
for key := range body {
if !allowedTopLevel[key] {
@@ -1728,6 +1729,10 @@ func TestVolcesVideoBodyAllowsOnlyTaskPayloadFields(t *testing.T) {
body["watermark"] != true {
t.Fatalf("unexpected direct video fields: %+v", body)
}
tools, ok := body["tools"].([]any)
if !ok || len(tools) != 1 {
t.Fatalf("expected web search tools to pass through, got %+v", body["tools"])
}
content, ok := body["content"].([]map[string]any)
if !ok || len(content) != 5 {
@@ -1782,6 +1787,31 @@ func TestVolcesVideoBodyPrefersFramesOverDuration(t *testing.T) {
}
}
func TestVolcesVideoBodyBuildsWebSearchToolsFromFlag(t *testing.T) {
body := volcesVideoBody(Request{
Kind: "videos.generations",
ModelType: "video_generate",
Model: "豆包Seedance-2.0",
Body: map[string]any{
"model": "豆包Seedance-2.0",
"prompt": "查找最新城市夜景素材再生成视频",
"enable_web_search": true,
},
Candidate: store.RuntimeModelCandidate{
ProviderModelName: "doubao-seedance-2-0-260128",
},
})
tools, ok := body["tools"].([]any)
if !ok || len(tools) != 1 {
t.Fatalf("expected generated web search tools, got %+v", body["tools"])
}
tool, ok := tools[0].(map[string]any)
if !ok || tool["type"] != "web_search" {
t.Fatalf("unexpected generated web search tool: %+v", tools[0])
}
}
func TestVolcesClientVideoResumePollsExistingTaskID(t *testing.T) {
var submitCalled bool
var pollPath string
+10
View File
@@ -336,6 +336,16 @@ func addVolcesVideoTaskParams(out map[string]any, body map[string]any) {
copyVolcesBoolParam(out, "return_last_frame", body, "return_last_frame", "returnLastFrame")
copyVolcesIntParam(out, "execution_expires_after", body, "execution_expires_after", "executionExpiresAfter")
copyVolcesBoolParam(out, "generate_audio", body, "generate_audio", "generateAudio", "audio")
if tools, ok := body["tools"]; ok {
out["tools"] = tools
} else {
for _, key := range []string{"enable_web_search", "enableWebSearch"} {
if value, ok := volcesBoolFromAny(body[key]); ok && value {
out["tools"] = []any{map[string]any{"type": "web_search"}}
break
}
}
}
copyVolcesBoolParam(out, "draft", body, "draft")
copyVolcesStringParam(out, "resolution", body, "resolution", "size")
copyVolcesStringParam(out, "ratio", body, "ratio", "aspect_ratio", "aspectRatio")