Skip to content

修复viduq2不支持参考生视频的问题 - #2204

Merged
creamlike1024 merged 2 commits into
QuantumNous:mainfrom
feitianbubu:pr/vidu-q2-reference
Nov 10, 2025
Merged

修复viduq2不支持参考生视频的问题#2204
creamlike1024 merged 2 commits into
QuantumNous:mainfrom
feitianbubu:pr/vidu-q2-reference

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Nov 10, 2025

Copy link
Copy Markdown
Member
  1. 修复viduq2参考图生视频报not supported问题
viduq2的文生视频和图生视频分为viduq2-turbo和viduq2-pro
但参考图生视频只能传viduq2否则报not supported错误
官方文档: https://platform.vidu.cn/docs/reference-to-video
  1. viduq2参考生视频支持1-7张图, 增加参数action=referenceGenerate,指定vidu使用参考生视频
    请求示例:
curl http://localhost:3000/v1/videos \
  --request POST \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=转个圈' \
  --form 'image=https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimages_1.png' \
  --form 'model=viduq2-pro' \
  --form 'action=referenceGenerate'
image image

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for "viduq2" video generation model.
  • Refactor

    • Improved task validation and request handling workflow for better reliability.

@coderabbitai

coderabbitai Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor task request validation and action determination in the Vidu task adaptor by introducing a shared utility function to extract task requests from context. Action logic now derives FirstTailGenerate or ReferenceGenerate based on image count and model selection, with explicit viduq2 support added to the model list.

Changes

Cohort / File(s) Summary
Vidu task adaptor
relay/channel/task/vidu/adaptor.go
Reworked ValidateRequestAndSetAction to extract and validate task request with Vidu-specific action derivation logic; updated BuildRequestBody signature to accept info *relaycommon.RelayInfo instead of unused parameter and apply model override for ReferenceGenerate with viduq2; expanded GetModelList to include "viduq2" model; removed context-based action propagation in DoRequest
Common relay utilities
relay/common/relay_utils.go
Added new exported helper GetTaskRequest(c *gin.Context) to retrieve TaskSubmitReq from Gin context; removed inline action adjustment logic based on image count and channel type from ValidateBasicTaskRequest

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Signature change in BuildRequestBody: Verify all call sites are correctly updated to pass the RelayInfo parameter
  • Action determination logic: Cross-verify the new image-count-based action mapping (FirstTailGenerate vs. ReferenceGenerate) aligns with intended Vidu API behavior
  • Model override logic: Ensure the viduq2 model forcing for ReferenceGenerate does not have unintended side effects
  • Context extraction: Confirm GetTaskRequest helper error handling matches expected error scenarios

Possibly related PRs

Suggested reviewers

  • seefs001
  • creamlike1024

Poem

🐰 With actions now derived from images so bright,
And Vidu's viduq2 gleaming in sight,
The task adaptor refactors with care,
Shared utilities float through the air,
Request validation flows everywhere! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title in Chinese translates to 'Fix viduq2 reference image to video not supported issue' and directly corresponds to the main change: enabling reference-image-to-video support for viduq2 by refactoring action derivation logic and adding explicit action parameter handling.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@feitianbubu feitianbubu changed the title 修复viduq2参考图生视频报not supported问题 修复viduq2不支持参考生视频的问题 Nov 10, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d56e162 and 1a8d89c.

📒 Files selected for processing (2)
  • relay/channel/task/vidu/adaptor.go (4 hunks)
  • relay/common/relay_utils.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
relay/common/relay_utils.go (1)
relay/common/relay_info.go (1)
  • TaskSubmitReq (488-499)
relay/channel/task/vidu/adaptor.go (5)
relay/common/relay_utils.go (3)
  • ValidateBasicTaskRequest (204-228)
  • GetTaskRequest (62-72)
  • HasImage (21-23)
constant/task.go (4)
  • TaskActionGenerate (14-14)
  • TaskActionTextGenerate (15-15)
  • TaskActionFirstTailGenerate (16-16)
  • TaskActionReferenceGenerate (17-17)
service/error.go (1)
  • TaskErrorWrapper (140-157)
constant/channel.go (1)
  • ChannelTypeVidu (52-52)
relay/channel/adapter.go (1)
  • TaskAdaptor (34-53)

Comment on lines +94 to +108
if meatAction, ok := req.Metadata["action"]; ok {
action, _ = meatAction.(string)
} else if req.HasImage() {
action = constant.TaskActionGenerate
if info.ChannelType == constant.ChannelTypeVidu {
// vidu 增加 首尾帧生视频和参考图生视频
if len(req.Images) == 2 {
action = constant.TaskActionFirstTailGenerate
} else if len(req.Images) > 2 {
action = constant.TaskActionReferenceGenerate
}
}
}
info.Action = action
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid blank metadata action overriding the fallback
Line 95 assigns action, _ = meatAction.(string), so whenever a request includes an action field that is empty or not a string (typical for HTML forms sending action=), the type assertion zeroes out the variable. Because the branch short-circuits the else if req.HasImage() fallback, info.Action becomes "", BuildRequestURL falls through to /text2video, and image-based requests fail. Previously we always defaulted to generate, so this regresses basic flows. Please only overwrite the default when the metadata value is a non-empty string, and keep the image-derived fallback otherwise.

-	action := constant.TaskActionTextGenerate
-	if meatAction, ok := req.Metadata["action"]; ok {
-		action, _ = meatAction.(string)
-	} else if req.HasImage() {
+	action := constant.TaskActionTextGenerate
+	if meatAction, ok := req.Metadata["action"]; ok {
+		if s, ok := meatAction.(string); ok && s != "" {
+			action = s
+		}
+	}
+	if action == constant.TaskActionTextGenerate && req.HasImage() {
 		action = constant.TaskActionGenerate
 		if info.ChannelType == constant.ChannelTypeVidu {
 			// vidu 增加 首尾帧生视频和参考图生视频
 			if len(req.Images) == 2 {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if meatAction, ok := req.Metadata["action"]; ok {
action, _ = meatAction.(string)
} else if req.HasImage() {
action = constant.TaskActionGenerate
if info.ChannelType == constant.ChannelTypeVidu {
// vidu 增加 首尾帧生视频和参考图生视频
if len(req.Images) == 2 {
action = constant.TaskActionFirstTailGenerate
} else if len(req.Images) > 2 {
action = constant.TaskActionReferenceGenerate
}
}
}
info.Action = action
return nil
action := constant.TaskActionTextGenerate
if meatAction, ok := req.Metadata["action"]; ok {
if s, ok := meatAction.(string); ok && s != "" {
action = s
}
}
if action == constant.TaskActionTextGenerate && req.HasImage() {
action = constant.TaskActionGenerate
if info.ChannelType == constant.ChannelTypeVidu {
// vidu 增加 首尾帧生视频和参考图生视频
if len(req.Images) == 2 {
action = constant.TaskActionFirstTailGenerate
} else if len(req.Images) > 2 {
action = constant.TaskActionReferenceGenerate
}
}
}
info.Action = action
return nil
🤖 Prompt for AI Agents
In relay/channel/task/vidu/adaptor.go around lines 94 to 108, the code
unconditionally assigns action from req.Metadata["action"] even when it's a
non-string or an empty string, which overrides the image-derived fallback;
change the logic so you only set action when the metadata key exists AND the
value is a non-empty string (i.e., type-assert to string, check len>0),
otherwise fall through to the req.HasImage() branch (preserving the previous
default of generate and the special vidu image-length handling) and then assign
info.Action.

@creamlike1024
creamlike1024 merged commit bdd5eca into QuantumNous:main Nov 10, 2025
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ence

修复viduq2不支持参考生视频的问题
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
feat: 完善了 OpenAI的GPT模型在 Claude Code 上的工具兼容性和缓存命中率
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants