From f6b33e76b00314898f28a95538dbb85d657fadbf Mon Sep 17 00:00:00 2001 From: qiuliw Date: Sun, 20 Sep 2026 15:49:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(plugins):=20DashScope=20Wan3=20-=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20wan3.0=20=E5=8E=9F=E7=94=9F=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=8D=8F=E8=AE=AE=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对齐 dashscope-wan-video 风格,支持 media type+url、originPath 与 UNKNOWN 失败映射;序列化 providerOptions 供声明式校验引用。 --- .../protocol/dashscope_wan3_video_test.go | 76 +++ backend/internal/protocol/manifest.go | 6 +- docs/content/docs/progress/pending-test.mdx | 5 + .../dashscope-wan3-video.yingce-plugin | Bin 0 -> 10001 bytes .../dashscope-wan3-video/README.md | 5 + .../dashscope-wan3-video/docs/interface.md | 513 ++++++++++++++++++ .../dashscope-wan3-video/manifest.json | 415 ++++++++++++++ plugin-packages/generate-catalog.mjs | 46 ++ 8 files changed, 1065 insertions(+), 1 deletion(-) create mode 100644 backend/internal/protocol/dashscope_wan3_video_test.go create mode 100644 plugin-packages/dashscope-wan3-video.yingce-plugin create mode 100644 plugin-packages/dashscope-wan3-video/README.md create mode 100644 plugin-packages/dashscope-wan3-video/docs/interface.md create mode 100644 plugin-packages/dashscope-wan3-video/manifest.json diff --git a/backend/internal/protocol/dashscope_wan3_video_test.go b/backend/internal/protocol/dashscope_wan3_video_test.go new file mode 100644 index 000000000..7331ce97c --- /dev/null +++ b/backend/internal/protocol/dashscope_wan3_video_test.go @@ -0,0 +1,76 @@ +package protocol + +import ( + "context" + "testing" +) + +func TestDashscopeWan3VideoCreateAndLifecycle(t *testing.T) { + adapter := officialPackageAdapter(t, "dashscope-wan3-video.yingce-plugin", "dashscope-wan3-video") + create, err := adapter.BuildCreate(context.Background(), RequestContext{Request: GenerationRequest{ + Model: "wan3.0-video-prime", Prompt: "一只猫在海边奔跑", Duration: 6, AspectRatio: "16:9", Resolution: "1080P", + GenerateAudio: true, Watermark: true, + Inputs: []MediaReference{ + {URL: "https://cdn.example/audio.mp3", Kind: "audio", Role: "reference_audio", Order: 3}, + {URL: "https://cdn.example/image.png", Kind: "image", Role: "reference_image", Order: 1}, + {URL: "https://cdn.example/video.mp4", Kind: "video", Role: "reference_video", Order: 2}, + }, + ProviderOptions: map[string]map[string]any{"dashscope-wan3-video": {"seed": 42, "prompt_extend": false}}, + }}) + if err != nil { + t.Fatal(err) + } + if create.Method != "POST" || create.Path != "/api/v1/services/aigc/video-generation/video-synthesis" || !create.OriginPath || create.Headers["X-DashScope-Async"] != "enable" { + t.Fatalf("create = %#v", create) + } + body := manifestTestBody(t, create) + input, _ := body["input"].(map[string]any) + media, _ := input["media"].([]any) + if input["prompt"] != "一只猫在海边奔跑" || len(media) != 3 { + t.Fatalf("input = %#v", input) + } + first, _ := media[0].(map[string]any) + if first["type"] != "reference_image" || first["url"] != "https://cdn.example/image.png" { + t.Fatalf("media[0] = %#v", first) + } + parameters, _ := body["parameters"].(map[string]any) + if parameters["resolution"] != "1080P" || parameters["ratio"] != "16:9" || parameters["duration"] != float64(6) || parameters["audio"] != true || parameters["seed"] != float64(42) || parameters["prompt_extend"] != false { + t.Fatalf("parameters = %#v", parameters) + } + + keyframes, err := adapter.BuildCreate(context.Background(), RequestContext{Request: GenerationRequest{ + Model: "wan3.0-video", Prompt: "首尾帧", + Images: []MediaReference{ + {URL: "https://cdn.example/last.png", Role: "last_frame", Order: 2}, + {URL: "https://cdn.example/first.png", Role: "first_frame", Order: 1}, + }, + }}) + if err != nil { + t.Fatal(err) + } + keyMedia, _ := manifestTestBody(t, keyframes)["input"].(map[string]any)["media"].([]any) + if len(keyMedia) != 2 || keyMedia[0].(map[string]any)["type"] != "first_frame" || keyMedia[1].(map[string]any)["type"] != "last_frame" { + t.Fatalf("keyframes = %#v", keyMedia) + } + + if _, err := adapter.BuildCreate(context.Background(), RequestContext{Request: GenerationRequest{Model: "wan2.2-kf2v-flash", Prompt: "x"}}); err == nil { + t.Fatal("unsupported model accepted") + } + + created, err := adapter.ParseCreate(context.Background(), []byte(`{"output":{"task_id":"wan3-task-1","task_status":"PENDING"}}`)) + if err != nil || created.TaskID != "wan3-task-1" || created.Status != StatusPending { + t.Fatalf("create result = %#v err=%v", created, err) + } + poll, err := adapter.BuildPoll(context.Background(), PollContext{TaskID: created.TaskID}) + if err != nil || poll.Path != "/api/v1/tasks/wan3-task-1" || !poll.OriginPath { + t.Fatalf("poll = %#v err=%v", poll, err) + } + succeeded, err := adapter.ParsePoll(context.Background(), PollContext{TaskID: created.TaskID}, []byte(`{"output":{"task_id":"wan3-task-1","task_status":"SUCCEEDED","video_url":"https://dashscope-result.example/wan3.mp4"},"usage":{"video_count":1}}`)) + if err != nil || succeeded.Status != StatusSucceeded || len(succeeded.Result.Videos) != 1 || !succeeded.Result.Videos[0].Ephemeral { + t.Fatalf("success = %#v err=%v", succeeded, err) + } + unknown, err := adapter.ParsePoll(context.Background(), PollContext{TaskID: created.TaskID}, []byte(`{"output":{"task_id":"wan3-task-1","task_status":"UNKNOWN"}}`)) + if err != nil || unknown.Status != StatusFailed { + t.Fatalf("unknown = %#v err=%v", unknown, err) + } +} diff --git a/backend/internal/protocol/manifest.go b/backend/internal/protocol/manifest.go index 317094648..8de42a031 100644 --- a/backend/internal/protocol/manifest.go +++ b/backend/internal/protocol/manifest.go @@ -1088,6 +1088,10 @@ func manifestRequestValues(request GenerationRequest) map[string]any { output.GenerateAudio = output.GenerateAudio || request.GenerateAudio output.Watermark = output.Watermark || request.Watermark outputValue, _ := requestAsManifestValue(output) + providerOptionsValue, _ := requestAsManifestValue(request.ProviderOptions) + if providerOptionsValue == nil { + providerOptionsValue = map[string]any{} + } return map[string]any{ "capability": request.Capability, @@ -1108,7 +1112,7 @@ func manifestRequestValues(request GenerationRequest) map[string]any { "watermark": request.Watermark, "operation": request.Operation, "output": outputValue, - "providerOptions": request.ProviderOptions, + "providerOptions": providerOptionsValue, "extra": request.Extra, } } diff --git a/docs/content/docs/progress/pending-test.mdx b/docs/content/docs/progress/pending-test.mdx index 02aef2084..88fc98488 100644 --- a/docs/content/docs/progress/pending-test.mdx +++ b/docs/content/docs/progress/pending-test.mdx @@ -5,6 +5,11 @@ description: 当前项目已实现功能的手工验证清单与未确认边界 # 待测试 +## DashScope Wan 3.0 视频协议插件 + +- [x] 管理端模型测试:`wan3.0-video` / `dashscope-wan3-video` 真实上游通过。 +- [ ] 画布文生视频与首尾帧完成并落盘。 + ## 系统模型同页渠道与模型管理 - [x] 样式细化:渠道列表改为留白分组与中性选中描边,数量与启停状态分别呈现;模型头部说明成本口径,规格与成本分行,操作列固定在右侧,超过三个规格可展开查看。 diff --git a/plugin-packages/dashscope-wan3-video.yingce-plugin b/plugin-packages/dashscope-wan3-video.yingce-plugin new file mode 100644 index 0000000000000000000000000000000000000000..043dc9993e0214c6298d1961592aee1e402aa928 GIT binary patch literal 10001 zcmZ{Kb8sd=^JZ+laW=`u*2Xs9*tTukwry^bjcq#{+qTWyudeE@e&5yA)KfiOGtWOg zQ#0LNkGvE(1Ud)^2n@&%UltuO{+8y`f8O0c!2W}xsGx|9D7}rblBzwBb{a-@nn6MZ zMs8B+*AlZl%!D*>>Uhty&iC|w^*r|~=goTf?Re8Fx8};X-FCRaf;;c&sYku#O5?kj zqN9a(optv$aCih!MvmfvSFh`9?5g`%>4^V4{l;50N=OK9=D;w1to<;;W4PUf(CCqx z`F<`*$pzj~a-R7f6+QQHc;>4%k?kcK!KG$yR)BE|O%%=M9^B*ON z(NPBaI!Sr=)tQI-rsva141x95*4#hm9&9cX4c#Sj?^r$RTjeM@iFw*pc^PVnn#rl@ z*}v1WP%8t7iecyAK;-{NJc1Q6vy6~IKnTP^Kmh;ZVQgpQ#9(3TY~pBYU}W+yE|<7g zPH5tH9lk@kiFRf{(pRw(#Y2CFkwZgD`^1hy?Ilg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oA`2(!7t*M<=)cQTE`T(O|5b(B=#4SS@vHkNPUOdk$gDol%=t4>dSj5e>zd39vzum9azrDjgD?x~e^s zWP`#q(>w{qn;{Jy2kg(x@T|y`Hw}a+C5>z^B^Z?yKvb9(K?F&S1+42$0 zg9R5j_I+%{AsPF-G()-e2B@a!PCF+*Dp^D%iN>&0g7tfUB zsJDWjB0&0Dp|OvJM~?lpyOpeto%foN@^k75=0<+eMV}$Ni-{-RLNgUWM??X8{&II&TOgfx>H^s42hLkBnt&%RR| zI1al>U%%+dOM!y@1pohQ$^JEKK|ueZG2lP5|D!DXZ`yxLuKu(6f74L@ng2(C_22aW f?hpT8dLhbxb&KVtAff)V4E}G_{j-wf|MC78msJrO literal 0 HcmV?d00001 diff --git a/plugin-packages/dashscope-wan3-video/README.md b/plugin-packages/dashscope-wan3-video/README.md new file mode 100644 index 000000000..b51f6a720 --- /dev/null +++ b/plugin-packages/dashscope-wan3-video/README.md @@ -0,0 +1,5 @@ +# DashScope Wan 3.0 Video + +该目录是独立官方协议插件源码。后端从生成的 `dashscope-wan3-video.yingce-plugin` 包加载,不依赖系统内置 `host:` 适配器。 + +完整接口见 [docs/interface.md](docs/interface.md)。 diff --git a/plugin-packages/dashscope-wan3-video/docs/interface.md b/plugin-packages/dashscope-wan3-video/docs/interface.md new file mode 100644 index 000000000..d9d49358a --- /dev/null +++ b/plugin-packages/dashscope-wan3-video/docs/interface.md @@ -0,0 +1,513 @@ +# DashScope Wan 3.0 Video 接口字段 + +## 协议身份 + +- 插件 ID:`dashscope-wan3-video`。 +- Provider ID:`dashscope-wan3-video`。 +- 能力:`video`。 +- 默认 Base URL:`https://dashscope.aliyuncs.com`。 +- 鉴权驱动:`bearer`。 +- 创建:`POST /api/v1/services/aigc/video-generation/video-synthesis`。 +- 查询:`GET /api/v1/tasks/{{taskId}}`。 + +## 配置字段 + +| 字段 | 类型 | 必填 | 含义 | +| --- | --- | --- | --- | +| `apiKey` | secret | 是 | API Key | + +## 统一字段映射 + +| 统一字段 | 类型 | 必填 | 上游映射 | 说明 | +| --- | --- | --- | --- | --- | +| `model` | string | 是 | `model` | 视频模型 ID。 | +| `prompt` | string | 是 | `prompt/content/input` | 视频提示词。 | +| `images` | media[] | 否 | `first/last/reference image` | 显式 role 图片输入。 | +| `videos` | media[] | 否 | `reference video` | 参考视频。 | +| `audios` | media[] | 否 | `reference audio/voice` | 参考音频或音色。 | +| `duration` | integer | 否 | `duration/seconds` | 时长秒数。 | +| `aspectRatio` | string | 否 | `ratio/aspect_ratio/size` | 画幅比例或尺寸。 | +| `resolution` | string | 否 | `resolution` | 分辨率档位。 | +| `generateAudio` | boolean | 否 | `generate_audio` | 是否生成音频。 | +| `watermark` | boolean | 否 | `watermark` | 水印开关。 | +| `providerOptions` | object | 否 | `provider-specific fields` | 插件命名空间内的厂商扩展字段。 | + +## 上游请求模板逐字段清单 + +下表由插件请求模板生成,覆盖 body、query、headers 和 multipart 文件声明中的每个字段。 + +| 上游位置 | 值或转换表达式 | +| --- | --- | +| `create.method` | `"POST"` | +| `create.path` | `"/api/v1/services/aigc/video-generation/video-synthesis"` | +| `create.contentType` | `"application/json"` | +| `create.body.model` | `{"$ref":"request.model"}` | +| `create.body.input.prompt` | `{"$omitEmpty":{"$ref":"request.prompt"}}` | +| `create.body.input.media` | `{"$omitEmpty":{"$coalesce":[{"$ref":"request.providerOptions.dashscope-wan3-video.media"},{"$map":{"from":{"$sortByOrder":{"$ref":"request.inputs"}},"as":"media","in":{"type":{"$coalesce":[{"$ref":"media.role"},{"$if":{"condition":{"$eq":[{"$ref":"media.kind"},"image"]},"then":"reference_image","else":{"$if":{"condition":{"$eq":[{"$ref":"media.kind"},"video"]},"then":"reference_video","else":{"$if":{"condition":{"$eq":[{"$ref":"media.kind"},"audio"]},"then":"reference_audio","else":{"$ref":"media.kind"}}}}}}}]},"url":{"$ref":"media.value"}}}}]}}` | +| `create.body.parameters.resolution` | `{"$omitEmpty":{"$ref":"request.resolution"}}` | +| `create.body.parameters.ratio` | `{"$omitEmpty":{"$ref":"request.aspectRatio"}}` | +| `create.body.parameters.duration` | `{"$omitEmpty":{"$ref":"request.duration"}}` | +| `create.body.parameters.audio` | `{"$coalesce":[{"$ref":"request.providerOptions.dashscope-wan3-video.audio"},{"$ref":"request.generateAudio"}]}` | +| `create.body.parameters.seed` | `{"$omitEmpty":{"$ref":"request.providerOptions.dashscope-wan3-video.seed"}}` | +| `create.body.parameters.prompt_extend` | `{"$coalesce":[{"$ref":"request.providerOptions.dashscope-wan3-video.prompt_extend"},true]}` | +| `create.body.parameters.watermark` | `{"$ref":"request.watermark"}` | +| `create.headers.X-DashScope-Async` | `"enable"` | +| `poll.method` | `"GET"` | +| `poll.path` | `"/api/v1/tasks/{{taskId}}"` | +| `poll.contentType` | `"application/json"` | + +## Provider 扩展键 + +- `providerOptions.dashscope-wan3-video.audio` +- `providerOptions.dashscope-wan3-video.media` +- `providerOptions.dashscope-wan3-video.prompt_extend` +- `providerOptions.dashscope-wan3-video.seed` + +动态模型或工作流允许使用文档声明的完整 `parameters/input/extra_body` 对象;该对象是协议本身的开放 schema,不会被宿主裁剪。 + +## 响应映射逐字段清单 + +| 映射位置 | 上游路径或转换表达式 | +| --- | --- | +| `response.taskId` | `{"$coalesce":[{"$ref":"response.output.task_id"},{"$ref":"response.task_id"},{"$ref":"taskId"}]}` | +| `response.status` | `{"$if":{"condition":{"$eq":[{"$lower":{"$ref":"response.output.task_status"}},"unknown"]},"then":"failed","else":{"$coalesce":[{"$ref":"response.output.task_status"},{"$ref":"response.status"},"pending"]}}}` | +| `response.message` | `{"$coalesce":[{"$ref":"response.error.message"},{"$ref":"response.message"},{"$ref":"response.fail_reason"}]}` | +| `response.videos` | `{"$ref":"response.output.video_url"}` | +| `response.errorPaths[0]` | `"code"` | +| `response.errorPaths[1]` | `"output.code"` | +| `response.resultEphemeral` | `true` | +| `response.usage` | `{"$ref":"response.usage"}` | +| `response.messagePaths[0]` | `"message"` | +| `response.messagePaths[1]` | `"output.message"` | + +## 响应与错误 + +插件把上游 task/status/text/media/usage 映射为统一结果。临时媒体 URL 标记为 ephemeral,由宿主立即下载持久化。HTTP 错误、业务 code 和 error object 保持失败语义,不包装成成功。 + +## 兼容边界 + +Wan 3.0 原生异步视频。模型仅 wan3.0-video-prime / wan3.0-video;input.media 为 type+url;UNKNOWN 视为失败。文档:https://docs.bailian.console.aliyun.com/zh/model-studio/wan3-video-generation-api-reference。 + + +## Manifest 完整接口定义 + +以下 JSON 与插件包内实际 `manifest.json` 逐字段一致,覆盖插件身份、权限、配置、鉴权、参数、校验、创建、Agent、查询、取消、结果下载、响应和 Agent 响应映射。`documentation` 字段的值就是当前完整文档;为避免文档在自身内部无限递归,JSON 中仅用等义占位文本表示正文。 + +```json +{ + "apiVersion": "yingce.plugin/v2", + "id": "dashscope-wan3-video", + "name": "DashScope Wan 3.0 Video", + "version": "2.0.0", + "author": "Alibaba Cloud / 影策", + "description": "DashScope Wan 3.0 Video 独立请求协议插件。", + "documentation": "<当前插件的完整 documentation,由 README.md 与 docs/interface.md 拼接而成;为避免 JSON 递归,此处不重复展开正文。>", + "permissions": [ + "generation.run", + "media.read" + ], + "configuration": { + "fields": [ + { + "name": "apiKey", + "type": "secret", + "label": "API Key", + "required": true + } + ] + }, + "contributes": { + "providers": [ + { + "id": "dashscope-wan3-video", + "label": "DashScope Wan 3.0 Video", + "capabilities": [ + "video" + ], + "scopes": [ + "admin.system-channel", + "user.custom-channel", + "canvas", + "creation", + "agent" + ], + "baseUrl": "https://dashscope.aliyuncs.com", + "requiresPublicMediaUrls": true, + "auth": { + "type": "bearer", + "field": "apiKey" + }, + "parameters": [ + { + "name": "model", + "type": "string", + "required": true, + "mapping": "model", + "description": "视频模型 ID。" + }, + { + "name": "prompt", + "type": "string", + "required": true, + "mapping": "prompt/content/input", + "description": "视频提示词。" + }, + { + "name": "images", + "type": "media[]", + "required": false, + "mapping": "first/last/reference image", + "description": "显式 role 图片输入。" + }, + { + "name": "videos", + "type": "media[]", + "required": false, + "mapping": "reference video", + "description": "参考视频。" + }, + { + "name": "audios", + "type": "media[]", + "required": false, + "mapping": "reference audio/voice", + "description": "参考音频或音色。" + }, + { + "name": "duration", + "type": "integer", + "required": false, + "mapping": "duration/seconds", + "description": "时长秒数。" + }, + { + "name": "aspectRatio", + "type": "string", + "required": false, + "mapping": "ratio/aspect_ratio/size", + "description": "画幅比例或尺寸。" + }, + { + "name": "resolution", + "type": "string", + "required": false, + "mapping": "resolution", + "description": "分辨率档位。" + }, + { + "name": "generateAudio", + "type": "boolean", + "required": false, + "mapping": "generate_audio", + "description": "是否生成音频。" + }, + { + "name": "watermark", + "type": "boolean", + "required": false, + "mapping": "watermark", + "description": "水印开关。" + }, + { + "name": "providerOptions", + "type": "object", + "required": false, + "mapping": "provider-specific fields", + "description": "插件命名空间内的厂商扩展字段。" + } + ], + "validations": [ + { + "assert": { + "$in": [ + { + "$lower": { + "$ref": "request.model" + } + }, + [ + "wan3.0-video-prime", + "wan3.0-video" + ] + ] + }, + "message": "Wan 3.0 Video 仅支持 wan3.0-video-prime 或 wan3.0-video" + }, + { + "assert": { + "$lte": [ + { + "$len": { + "$filter": { + "from": { + "$sortByOrder": { + "$ref": "request.images" + } + }, + "as": "media", + "where": { + "$in": [ + { + "$ref": "media.role" + }, + [ + "first_frame" + ] + ] + } + } + } + }, + 1 + ] + }, + "message": "Wan 3.0 Video 最多只能有一个 first_frame" + }, + { + "assert": { + "$lte": [ + { + "$len": { + "$filter": { + "from": { + "$sortByOrder": { + "$ref": "request.images" + } + }, + "as": "media", + "where": { + "$in": [ + { + "$ref": "media.role" + }, + [ + "last_frame" + ] + ] + } + } + } + }, + 1 + ] + }, + "message": "Wan 3.0 Video 最多只能有一个 last_frame" + } + ], + "create": { + "method": "POST", + "path": "/api/v1/services/aigc/video-generation/video-synthesis", + "contentType": "application/json", + "body": { + "model": { + "$ref": "request.model" + }, + "input": { + "prompt": { + "$omitEmpty": { + "$ref": "request.prompt" + } + }, + "media": { + "$omitEmpty": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.media" + }, + { + "$map": { + "from": { + "$sortByOrder": { + "$ref": "request.inputs" + } + }, + "as": "media", + "in": { + "type": { + "$coalesce": [ + { + "$ref": "media.role" + }, + { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "image" + ] + }, + "then": "reference_image", + "else": { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "video" + ] + }, + "then": "reference_video", + "else": { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "audio" + ] + }, + "then": "reference_audio", + "else": { + "$ref": "media.kind" + } + } + } + } + } + } + } + ] + }, + "url": { + "$ref": "media.value" + } + } + } + } + ] + } + } + }, + "parameters": { + "resolution": { + "$omitEmpty": { + "$ref": "request.resolution" + } + }, + "ratio": { + "$omitEmpty": { + "$ref": "request.aspectRatio" + } + }, + "duration": { + "$omitEmpty": { + "$ref": "request.duration" + } + }, + "audio": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.audio" + }, + { + "$ref": "request.generateAudio" + } + ] + }, + "seed": { + "$omitEmpty": { + "$ref": "request.providerOptions.dashscope-wan3-video.seed" + } + }, + "prompt_extend": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.prompt_extend" + }, + true + ] + }, + "watermark": { + "$ref": "request.watermark" + } + } + }, + "headers": { + "X-DashScope-Async": "enable" + }, + "originPath": true + }, + "poll": { + "method": "GET", + "path": "/api/v1/tasks/{{taskId}}", + "originPath": true + }, + "response": { + "taskId": { + "$coalesce": [ + { + "$ref": "response.output.task_id" + }, + { + "$ref": "response.task_id" + }, + { + "$ref": "taskId" + } + ] + }, + "status": { + "$if": { + "condition": { + "$eq": [ + { + "$lower": { + "$ref": "response.output.task_status" + } + }, + "unknown" + ] + }, + "then": "failed", + "else": { + "$coalesce": [ + { + "$ref": "response.output.task_status" + }, + { + "$ref": "response.status" + }, + "pending" + ] + } + } + }, + "message": { + "$coalesce": [ + { + "$ref": "response.error.message" + }, + { + "$ref": "response.message" + }, + { + "$ref": "response.fail_reason" + } + ] + }, + "videos": { + "$ref": "response.output.video_url" + }, + "errorPaths": [ + "code", + "output.code" + ], + "resultEphemeral": true, + "usage": { + "$ref": "response.usage" + }, + "messagePaths": [ + "message", + "output.message" + ] + } + } + ] + } +} +``` + diff --git a/plugin-packages/dashscope-wan3-video/manifest.json b/plugin-packages/dashscope-wan3-video/manifest.json new file mode 100644 index 000000000..e5b67d0bc --- /dev/null +++ b/plugin-packages/dashscope-wan3-video/manifest.json @@ -0,0 +1,415 @@ +{ + "apiVersion": "yingce.plugin/v2", + "id": "dashscope-wan3-video", + "name": "DashScope Wan 3.0 Video", + "version": "2.0.0", + "author": "Alibaba Cloud / 影策", + "description": "DashScope Wan 3.0 Video 独立请求协议插件。", + "documentation": "# DashScope Wan 3.0 Video\n\n该目录是独立官方协议插件源码。后端从生成的 `dashscope-wan3-video.yingce-plugin` 包加载,不依赖系统内置 `host:` 适配器。\n\n完整接口见 [docs/interface.md](docs/interface.md)。\n\n---\n\n# DashScope Wan 3.0 Video 接口字段\n\n## 协议身份\n\n- 插件 ID:`dashscope-wan3-video`。\n- Provider ID:`dashscope-wan3-video`。\n- 能力:`video`。\n- 默认 Base URL:`https://dashscope.aliyuncs.com`。\n- 鉴权驱动:`bearer`。\n- 创建:`POST /api/v1/services/aigc/video-generation/video-synthesis`。\n- 查询:`GET /api/v1/tasks/{{taskId}}`。\n\n## 配置字段\n\n| 字段 | 类型 | 必填 | 含义 |\n| --- | --- | --- | --- |\n| `apiKey` | secret | 是 | API Key |\n\n## 统一字段映射\n\n| 统一字段 | 类型 | 必填 | 上游映射 | 说明 |\n| --- | --- | --- | --- | --- |\n| `model` | string | 是 | `model` | 视频模型 ID。 |\n| `prompt` | string | 是 | `prompt/content/input` | 视频提示词。 |\n| `images` | media[] | 否 | `first/last/reference image` | 显式 role 图片输入。 |\n| `videos` | media[] | 否 | `reference video` | 参考视频。 |\n| `audios` | media[] | 否 | `reference audio/voice` | 参考音频或音色。 |\n| `duration` | integer | 否 | `duration/seconds` | 时长秒数。 |\n| `aspectRatio` | string | 否 | `ratio/aspect_ratio/size` | 画幅比例或尺寸。 |\n| `resolution` | string | 否 | `resolution` | 分辨率档位。 |\n| `generateAudio` | boolean | 否 | `generate_audio` | 是否生成音频。 |\n| `watermark` | boolean | 否 | `watermark` | 水印开关。 |\n| `providerOptions` | object | 否 | `provider-specific fields` | 插件命名空间内的厂商扩展字段。 |\n\n## 上游请求模板逐字段清单\n\n下表由插件请求模板生成,覆盖 body、query、headers 和 multipart 文件声明中的每个字段。\n\n| 上游位置 | 值或转换表达式 |\n| --- | --- |\n| `create.method` | `\"POST\"` |\n| `create.path` | `\"/api/v1/services/aigc/video-generation/video-synthesis\"` |\n| `create.contentType` | `\"application/json\"` |\n| `create.body.model` | `{\"$ref\":\"request.model\"}` |\n| `create.body.input.prompt` | `{\"$omitEmpty\":{\"$ref\":\"request.prompt\"}}` |\n| `create.body.input.media` | `{\"$omitEmpty\":{\"$coalesce\":[{\"$ref\":\"request.providerOptions.dashscope-wan3-video.media\"},{\"$map\":{\"from\":{\"$sortByOrder\":{\"$ref\":\"request.inputs\"}},\"as\":\"media\",\"in\":{\"type\":{\"$coalesce\":[{\"$ref\":\"media.role\"},{\"$if\":{\"condition\":{\"$eq\":[{\"$ref\":\"media.kind\"},\"image\"]},\"then\":\"reference_image\",\"else\":{\"$if\":{\"condition\":{\"$eq\":[{\"$ref\":\"media.kind\"},\"video\"]},\"then\":\"reference_video\",\"else\":{\"$if\":{\"condition\":{\"$eq\":[{\"$ref\":\"media.kind\"},\"audio\"]},\"then\":\"reference_audio\",\"else\":{\"$ref\":\"media.kind\"}}}}}}}]},\"url\":{\"$ref\":\"media.value\"}}}}]}}` |\n| `create.body.parameters.resolution` | `{\"$omitEmpty\":{\"$ref\":\"request.resolution\"}}` |\n| `create.body.parameters.ratio` | `{\"$omitEmpty\":{\"$ref\":\"request.aspectRatio\"}}` |\n| `create.body.parameters.duration` | `{\"$omitEmpty\":{\"$ref\":\"request.duration\"}}` |\n| `create.body.parameters.audio` | `{\"$coalesce\":[{\"$ref\":\"request.providerOptions.dashscope-wan3-video.audio\"},{\"$ref\":\"request.generateAudio\"}]}` |\n| `create.body.parameters.seed` | `{\"$omitEmpty\":{\"$ref\":\"request.providerOptions.dashscope-wan3-video.seed\"}}` |\n| `create.body.parameters.prompt_extend` | `{\"$coalesce\":[{\"$ref\":\"request.providerOptions.dashscope-wan3-video.prompt_extend\"},true]}` |\n| `create.body.parameters.watermark` | `{\"$ref\":\"request.watermark\"}` |\n| `create.headers.X-DashScope-Async` | `\"enable\"` |\n| `poll.method` | `\"GET\"` |\n| `poll.path` | `\"/api/v1/tasks/{{taskId}}\"` |\n| `poll.contentType` | `\"application/json\"` |\n\n## Provider 扩展键\n\n- `providerOptions.dashscope-wan3-video.audio`\n- `providerOptions.dashscope-wan3-video.media`\n- `providerOptions.dashscope-wan3-video.prompt_extend`\n- `providerOptions.dashscope-wan3-video.seed`\n\n动态模型或工作流允许使用文档声明的完整 `parameters/input/extra_body` 对象;该对象是协议本身的开放 schema,不会被宿主裁剪。\n\n## 响应映射逐字段清单\n\n| 映射位置 | 上游路径或转换表达式 |\n| --- | --- |\n| `response.taskId` | `{\"$coalesce\":[{\"$ref\":\"response.output.task_id\"},{\"$ref\":\"response.task_id\"},{\"$ref\":\"taskId\"}]}` |\n| `response.status` | `{\"$if\":{\"condition\":{\"$eq\":[{\"$lower\":{\"$ref\":\"response.output.task_status\"}},\"unknown\"]},\"then\":\"failed\",\"else\":{\"$coalesce\":[{\"$ref\":\"response.output.task_status\"},{\"$ref\":\"response.status\"},\"pending\"]}}}` |\n| `response.message` | `{\"$coalesce\":[{\"$ref\":\"response.error.message\"},{\"$ref\":\"response.message\"},{\"$ref\":\"response.fail_reason\"}]}` |\n| `response.videos` | `{\"$ref\":\"response.output.video_url\"}` |\n| `response.errorPaths[0]` | `\"code\"` |\n| `response.errorPaths[1]` | `\"output.code\"` |\n| `response.resultEphemeral` | `true` |\n| `response.usage` | `{\"$ref\":\"response.usage\"}` |\n| `response.messagePaths[0]` | `\"message\"` |\n| `response.messagePaths[1]` | `\"output.message\"` |\n\n## 响应与错误\n\n插件把上游 task/status/text/media/usage 映射为统一结果。临时媒体 URL 标记为 ephemeral,由宿主立即下载持久化。HTTP 错误、业务 code 和 error object 保持失败语义,不包装成成功。\n\n## 兼容边界\n\nWan 3.0 原生异步视频。模型仅 wan3.0-video-prime / wan3.0-video;input.media 为 type+url;UNKNOWN 视为失败。文档:https://docs.bailian.console.aliyun.com/zh/model-studio/wan3-video-generation-api-reference。\n\n\n## Manifest 完整接口定义\n\n以下 JSON 与插件包内实际 `manifest.json` 逐字段一致,覆盖插件身份、权限、配置、鉴权、参数、校验、创建、Agent、查询、取消、结果下载、响应和 Agent 响应映射。`documentation` 字段的值就是当前完整文档;为避免文档在自身内部无限递归,JSON 中仅用等义占位文本表示正文。\n\n```json\n{\n \"apiVersion\": \"yingce.plugin/v2\",\n \"id\": \"dashscope-wan3-video\",\n \"name\": \"DashScope Wan 3.0 Video\",\n \"version\": \"2.0.0\",\n \"author\": \"Alibaba Cloud / 影策\",\n \"description\": \"DashScope Wan 3.0 Video 独立请求协议插件。\",\n \"documentation\": \"<当前插件的完整 documentation,由 README.md 与 docs/interface.md 拼接而成;为避免 JSON 递归,此处不重复展开正文。>\",\n \"permissions\": [\n \"generation.run\",\n \"media.read\"\n ],\n \"configuration\": {\n \"fields\": [\n {\n \"name\": \"apiKey\",\n \"type\": \"secret\",\n \"label\": \"API Key\",\n \"required\": true\n }\n ]\n },\n \"contributes\": {\n \"providers\": [\n {\n \"id\": \"dashscope-wan3-video\",\n \"label\": \"DashScope Wan 3.0 Video\",\n \"capabilities\": [\n \"video\"\n ],\n \"scopes\": [\n \"admin.system-channel\",\n \"user.custom-channel\",\n \"canvas\",\n \"creation\",\n \"agent\"\n ],\n \"baseUrl\": \"https://dashscope.aliyuncs.com\",\n \"requiresPublicMediaUrls\": true,\n \"auth\": {\n \"type\": \"bearer\",\n \"field\": \"apiKey\"\n },\n \"parameters\": [\n {\n \"name\": \"model\",\n \"type\": \"string\",\n \"required\": true,\n \"mapping\": \"model\",\n \"description\": \"视频模型 ID。\"\n },\n {\n \"name\": \"prompt\",\n \"type\": \"string\",\n \"required\": true,\n \"mapping\": \"prompt/content/input\",\n \"description\": \"视频提示词。\"\n },\n {\n \"name\": \"images\",\n \"type\": \"media[]\",\n \"required\": false,\n \"mapping\": \"first/last/reference image\",\n \"description\": \"显式 role 图片输入。\"\n },\n {\n \"name\": \"videos\",\n \"type\": \"media[]\",\n \"required\": false,\n \"mapping\": \"reference video\",\n \"description\": \"参考视频。\"\n },\n {\n \"name\": \"audios\",\n \"type\": \"media[]\",\n \"required\": false,\n \"mapping\": \"reference audio/voice\",\n \"description\": \"参考音频或音色。\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"integer\",\n \"required\": false,\n \"mapping\": \"duration/seconds\",\n \"description\": \"时长秒数。\"\n },\n {\n \"name\": \"aspectRatio\",\n \"type\": \"string\",\n \"required\": false,\n \"mapping\": \"ratio/aspect_ratio/size\",\n \"description\": \"画幅比例或尺寸。\"\n },\n {\n \"name\": \"resolution\",\n \"type\": \"string\",\n \"required\": false,\n \"mapping\": \"resolution\",\n \"description\": \"分辨率档位。\"\n },\n {\n \"name\": \"generateAudio\",\n \"type\": \"boolean\",\n \"required\": false,\n \"mapping\": \"generate_audio\",\n \"description\": \"是否生成音频。\"\n },\n {\n \"name\": \"watermark\",\n \"type\": \"boolean\",\n \"required\": false,\n \"mapping\": \"watermark\",\n \"description\": \"水印开关。\"\n },\n {\n \"name\": \"providerOptions\",\n \"type\": \"object\",\n \"required\": false,\n \"mapping\": \"provider-specific fields\",\n \"description\": \"插件命名空间内的厂商扩展字段。\"\n }\n ],\n \"validations\": [\n {\n \"assert\": {\n \"$in\": [\n {\n \"$lower\": {\n \"$ref\": \"request.model\"\n }\n },\n [\n \"wan3.0-video-prime\",\n \"wan3.0-video\"\n ]\n ]\n },\n \"message\": \"Wan 3.0 Video 仅支持 wan3.0-video-prime 或 wan3.0-video\"\n },\n {\n \"assert\": {\n \"$lte\": [\n {\n \"$len\": {\n \"$filter\": {\n \"from\": {\n \"$sortByOrder\": {\n \"$ref\": \"request.images\"\n }\n },\n \"as\": \"media\",\n \"where\": {\n \"$in\": [\n {\n \"$ref\": \"media.role\"\n },\n [\n \"first_frame\"\n ]\n ]\n }\n }\n }\n },\n 1\n ]\n },\n \"message\": \"Wan 3.0 Video 最多只能有一个 first_frame\"\n },\n {\n \"assert\": {\n \"$lte\": [\n {\n \"$len\": {\n \"$filter\": {\n \"from\": {\n \"$sortByOrder\": {\n \"$ref\": \"request.images\"\n }\n },\n \"as\": \"media\",\n \"where\": {\n \"$in\": [\n {\n \"$ref\": \"media.role\"\n },\n [\n \"last_frame\"\n ]\n ]\n }\n }\n }\n },\n 1\n ]\n },\n \"message\": \"Wan 3.0 Video 最多只能有一个 last_frame\"\n }\n ],\n \"create\": {\n \"method\": \"POST\",\n \"path\": \"/api/v1/services/aigc/video-generation/video-synthesis\",\n \"contentType\": \"application/json\",\n \"body\": {\n \"model\": {\n \"$ref\": \"request.model\"\n },\n \"input\": {\n \"prompt\": {\n \"$omitEmpty\": {\n \"$ref\": \"request.prompt\"\n }\n },\n \"media\": {\n \"$omitEmpty\": {\n \"$coalesce\": [\n {\n \"$ref\": \"request.providerOptions.dashscope-wan3-video.media\"\n },\n {\n \"$map\": {\n \"from\": {\n \"$sortByOrder\": {\n \"$ref\": \"request.inputs\"\n }\n },\n \"as\": \"media\",\n \"in\": {\n \"type\": {\n \"$coalesce\": [\n {\n \"$ref\": \"media.role\"\n },\n {\n \"$if\": {\n \"condition\": {\n \"$eq\": [\n {\n \"$ref\": \"media.kind\"\n },\n \"image\"\n ]\n },\n \"then\": \"reference_image\",\n \"else\": {\n \"$if\": {\n \"condition\": {\n \"$eq\": [\n {\n \"$ref\": \"media.kind\"\n },\n \"video\"\n ]\n },\n \"then\": \"reference_video\",\n \"else\": {\n \"$if\": {\n \"condition\": {\n \"$eq\": [\n {\n \"$ref\": \"media.kind\"\n },\n \"audio\"\n ]\n },\n \"then\": \"reference_audio\",\n \"else\": {\n \"$ref\": \"media.kind\"\n }\n }\n }\n }\n }\n }\n }\n ]\n },\n \"url\": {\n \"$ref\": \"media.value\"\n }\n }\n }\n }\n ]\n }\n }\n },\n \"parameters\": {\n \"resolution\": {\n \"$omitEmpty\": {\n \"$ref\": \"request.resolution\"\n }\n },\n \"ratio\": {\n \"$omitEmpty\": {\n \"$ref\": \"request.aspectRatio\"\n }\n },\n \"duration\": {\n \"$omitEmpty\": {\n \"$ref\": \"request.duration\"\n }\n },\n \"audio\": {\n \"$coalesce\": [\n {\n \"$ref\": \"request.providerOptions.dashscope-wan3-video.audio\"\n },\n {\n \"$ref\": \"request.generateAudio\"\n }\n ]\n },\n \"seed\": {\n \"$omitEmpty\": {\n \"$ref\": \"request.providerOptions.dashscope-wan3-video.seed\"\n }\n },\n \"prompt_extend\": {\n \"$coalesce\": [\n {\n \"$ref\": \"request.providerOptions.dashscope-wan3-video.prompt_extend\"\n },\n true\n ]\n },\n \"watermark\": {\n \"$ref\": \"request.watermark\"\n }\n }\n },\n \"headers\": {\n \"X-DashScope-Async\": \"enable\"\n },\n \"originPath\": true\n },\n \"poll\": {\n \"method\": \"GET\",\n \"path\": \"/api/v1/tasks/{{taskId}}\",\n \"originPath\": true\n },\n \"response\": {\n \"taskId\": {\n \"$coalesce\": [\n {\n \"$ref\": \"response.output.task_id\"\n },\n {\n \"$ref\": \"response.task_id\"\n },\n {\n \"$ref\": \"taskId\"\n }\n ]\n },\n \"status\": {\n \"$if\": {\n \"condition\": {\n \"$eq\": [\n {\n \"$lower\": {\n \"$ref\": \"response.output.task_status\"\n }\n },\n \"unknown\"\n ]\n },\n \"then\": \"failed\",\n \"else\": {\n \"$coalesce\": [\n {\n \"$ref\": \"response.output.task_status\"\n },\n {\n \"$ref\": \"response.status\"\n },\n \"pending\"\n ]\n }\n }\n },\n \"message\": {\n \"$coalesce\": [\n {\n \"$ref\": \"response.error.message\"\n },\n {\n \"$ref\": \"response.message\"\n },\n {\n \"$ref\": \"response.fail_reason\"\n }\n ]\n },\n \"videos\": {\n \"$ref\": \"response.output.video_url\"\n },\n \"errorPaths\": [\n \"code\",\n \"output.code\"\n ],\n \"resultEphemeral\": true,\n \"usage\": {\n \"$ref\": \"response.usage\"\n },\n \"messagePaths\": [\n \"message\",\n \"output.message\"\n ]\n }\n }\n ]\n }\n}\n```\n\n", + "permissions": [ + "generation.run", + "media.read" + ], + "configuration": { + "fields": [ + { + "name": "apiKey", + "type": "secret", + "label": "API Key", + "required": true + } + ] + }, + "contributes": { + "providers": [ + { + "id": "dashscope-wan3-video", + "label": "DashScope Wan 3.0 Video", + "capabilities": [ + "video" + ], + "scopes": [ + "admin.system-channel", + "user.custom-channel", + "canvas", + "creation", + "agent" + ], + "baseUrl": "https://dashscope.aliyuncs.com", + "requiresPublicMediaUrls": true, + "auth": { + "type": "bearer", + "field": "apiKey" + }, + "parameters": [ + { + "name": "model", + "type": "string", + "required": true, + "mapping": "model", + "description": "视频模型 ID。" + }, + { + "name": "prompt", + "type": "string", + "required": true, + "mapping": "prompt/content/input", + "description": "视频提示词。" + }, + { + "name": "images", + "type": "media[]", + "required": false, + "mapping": "first/last/reference image", + "description": "显式 role 图片输入。" + }, + { + "name": "videos", + "type": "media[]", + "required": false, + "mapping": "reference video", + "description": "参考视频。" + }, + { + "name": "audios", + "type": "media[]", + "required": false, + "mapping": "reference audio/voice", + "description": "参考音频或音色。" + }, + { + "name": "duration", + "type": "integer", + "required": false, + "mapping": "duration/seconds", + "description": "时长秒数。" + }, + { + "name": "aspectRatio", + "type": "string", + "required": false, + "mapping": "ratio/aspect_ratio/size", + "description": "画幅比例或尺寸。" + }, + { + "name": "resolution", + "type": "string", + "required": false, + "mapping": "resolution", + "description": "分辨率档位。" + }, + { + "name": "generateAudio", + "type": "boolean", + "required": false, + "mapping": "generate_audio", + "description": "是否生成音频。" + }, + { + "name": "watermark", + "type": "boolean", + "required": false, + "mapping": "watermark", + "description": "水印开关。" + }, + { + "name": "providerOptions", + "type": "object", + "required": false, + "mapping": "provider-specific fields", + "description": "插件命名空间内的厂商扩展字段。" + } + ], + "validations": [ + { + "assert": { + "$in": [ + { + "$lower": { + "$ref": "request.model" + } + }, + [ + "wan3.0-video-prime", + "wan3.0-video" + ] + ] + }, + "message": "Wan 3.0 Video 仅支持 wan3.0-video-prime 或 wan3.0-video" + }, + { + "assert": { + "$lte": [ + { + "$len": { + "$filter": { + "from": { + "$sortByOrder": { + "$ref": "request.images" + } + }, + "as": "media", + "where": { + "$in": [ + { + "$ref": "media.role" + }, + [ + "first_frame" + ] + ] + } + } + } + }, + 1 + ] + }, + "message": "Wan 3.0 Video 最多只能有一个 first_frame" + }, + { + "assert": { + "$lte": [ + { + "$len": { + "$filter": { + "from": { + "$sortByOrder": { + "$ref": "request.images" + } + }, + "as": "media", + "where": { + "$in": [ + { + "$ref": "media.role" + }, + [ + "last_frame" + ] + ] + } + } + } + }, + 1 + ] + }, + "message": "Wan 3.0 Video 最多只能有一个 last_frame" + } + ], + "create": { + "method": "POST", + "path": "/api/v1/services/aigc/video-generation/video-synthesis", + "contentType": "application/json", + "body": { + "model": { + "$ref": "request.model" + }, + "input": { + "prompt": { + "$omitEmpty": { + "$ref": "request.prompt" + } + }, + "media": { + "$omitEmpty": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.media" + }, + { + "$map": { + "from": { + "$sortByOrder": { + "$ref": "request.inputs" + } + }, + "as": "media", + "in": { + "type": { + "$coalesce": [ + { + "$ref": "media.role" + }, + { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "image" + ] + }, + "then": "reference_image", + "else": { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "video" + ] + }, + "then": "reference_video", + "else": { + "$if": { + "condition": { + "$eq": [ + { + "$ref": "media.kind" + }, + "audio" + ] + }, + "then": "reference_audio", + "else": { + "$ref": "media.kind" + } + } + } + } + } + } + } + ] + }, + "url": { + "$ref": "media.value" + } + } + } + } + ] + } + } + }, + "parameters": { + "resolution": { + "$omitEmpty": { + "$ref": "request.resolution" + } + }, + "ratio": { + "$omitEmpty": { + "$ref": "request.aspectRatio" + } + }, + "duration": { + "$omitEmpty": { + "$ref": "request.duration" + } + }, + "audio": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.audio" + }, + { + "$ref": "request.generateAudio" + } + ] + }, + "seed": { + "$omitEmpty": { + "$ref": "request.providerOptions.dashscope-wan3-video.seed" + } + }, + "prompt_extend": { + "$coalesce": [ + { + "$ref": "request.providerOptions.dashscope-wan3-video.prompt_extend" + }, + true + ] + }, + "watermark": { + "$ref": "request.watermark" + } + } + }, + "headers": { + "X-DashScope-Async": "enable" + }, + "originPath": true + }, + "poll": { + "method": "GET", + "path": "/api/v1/tasks/{{taskId}}", + "originPath": true + }, + "response": { + "taskId": { + "$coalesce": [ + { + "$ref": "response.output.task_id" + }, + { + "$ref": "response.task_id" + }, + { + "$ref": "taskId" + } + ] + }, + "status": { + "$if": { + "condition": { + "$eq": [ + { + "$lower": { + "$ref": "response.output.task_status" + } + }, + "unknown" + ] + }, + "then": "failed", + "else": { + "$coalesce": [ + { + "$ref": "response.output.task_status" + }, + { + "$ref": "response.status" + }, + "pending" + ] + } + } + }, + "message": { + "$coalesce": [ + { + "$ref": "response.error.message" + }, + { + "$ref": "response.message" + }, + { + "$ref": "response.fail_reason" + } + ] + }, + "videos": { + "$ref": "response.output.video_url" + }, + "errorPaths": [ + "code", + "output.code" + ], + "resultEphemeral": true, + "usage": { + "$ref": "response.usage" + }, + "messagePaths": [ + "message", + "output.message" + ] + } + } + ] + } +} diff --git a/plugin-packages/generate-catalog.mjs b/plugin-packages/generate-catalog.mjs index 8d7838f3c..ef8fa0b8e 100644 --- a/plugin-packages/generate-catalog.mjs +++ b/plugin-packages/generate-catalog.mjs @@ -908,6 +908,52 @@ add({ response: { status: "succeeded", images: coalesce(ref("response.data"), ref("response.images")), errorPaths: ["error.code"], messagePaths: ["error.message", "message"] } }); +const wan3MediaType = coalesce( + ref("media.role"), + conditional(eq(ref("media.kind"), "image"), "reference_image", conditional( + eq(ref("media.kind"), "video"), "reference_video", conditional( + eq(ref("media.kind"), "audio"), "reference_audio", ref("media.kind") + ) + )) +); + +add({ + id: "dashscope-wan3-video", providerId: "dashscope-wan3-video", name: "DashScope Wan 3.0 Video", vendor: "Alibaba Cloud", capability: "video", + baseUrl: "https://dashscope.aliyuncs.com", auth: bearer, params: videoParams, requiresPublicMediaUrls: true, + notes: `Wan 3.0 原生异步视频。模型仅 wan3.0-video-prime / wan3.0-video;input.media 为 type+url;UNKNOWN 视为失败。文档:https://docs.bailian.console.aliyun.com/zh/model-studio/wan3-video-generation-api-reference。`, + validations: [ + { assert: { $in: [lower(ref("request.model")), ["wan3.0-video-prime", "wan3.0-video"]] }, message: "Wan 3.0 Video 仅支持 wan3.0-video-prime 或 wan3.0-video" }, + { assert: { $lte: [len(mediaWithRoles("request.images", ["first_frame"])), 1] }, message: "Wan 3.0 Video 最多只能有一个 first_frame" }, + { assert: { $lte: [len(mediaWithRoles("request.images", ["last_frame"])), 1] }, message: "Wan 3.0 Video 最多只能有一个 last_frame" } + ], + create: jsonCreate("/api/v1/services/aigc/video-generation/video-synthesis", { + model: ref("request.model"), + input: { + prompt: omit(ref("request.prompt")), + media: omit(coalesce( + ref("request.providerOptions.dashscope-wan3-video.media"), + map(sorted(ref("request.inputs")), "media", { type: wan3MediaType, url: ref("media.value") }) + )) + }, + parameters: { + resolution: omit(ref("request.resolution")), + ratio: omit(ref("request.aspectRatio")), + duration: omit(ref("request.duration")), + audio: coalesce(ref("request.providerOptions.dashscope-wan3-video.audio"), ref("request.generateAudio")), + seed: omit(ref("request.providerOptions.dashscope-wan3-video.seed")), + prompt_extend: coalesce(ref("request.providerOptions.dashscope-wan3-video.prompt_extend"), true), + watermark: ref("request.watermark") + } + }, { headers: { "X-DashScope-Async": "enable" }, originPath: true }), + poll: { method: "GET", path: "/api/v1/tasks/{{taskId}}", originPath: true }, + response: asyncResponse("video", { + taskId: coalesce(ref("response.output.task_id"), ref("response.task_id"), ref("taskId")), + status: conditional(eq(lower(ref("response.output.task_status")), "unknown"), "failed", coalesce(ref("response.output.task_status"), ref("response.status"), "pending")), + videos: ref("response.output.video_url"), + usage: ref("response.usage"), errorPaths: ["code", "output.code"], messagePaths: ["message", "output.message"] + }) +}); + add({ id: "dashscope-wan-video", providerId: "dashscope-wan-video", name: "DashScope Wan Video", vendor: "Alibaba Cloud", capability: "video", baseUrl: "https://dashscope.aliyuncs.com", auth: bearer, params: videoParams, requiresPublicMediaUrls: true,