Repository navigation
feat: support Wan2.7 i2v media mapping - #4984
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughAdds Wan2.7-i2v support to the Ali adaptor: new media schema, request normalization for image/audio inputs, model registration, upstream single-image normalization, and tests covering the new protocol plus legacy behavior. ChangesWan2.7-i2v Image-to-Video Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@relay/channel/task/ali/adaptor.go`:
- Around line 276-287: The helper firstTaskImage currently returns
InputReference before the newer direct-image fields; change its selection order
to prefer req.Image, then the first element of req.Images, and only fall back to
req.InputReference, so direct-image fields win; apply the same ordering change
to the other analogous helper used later (the one with the same logic around the
other task-image extraction) so both places derive img_url/first_frame from
Image/Images first.
In `@relay/common/relay_utils.go`:
- Around line 142-144: The code checks strings.TrimSpace(req.Image) but stores
the raw req.Image, allowing surrounding spaces to propagate; update the branch
that handles single-image compatibility so you store the trimmed value (e.g.,
use the trimmed string of req.Image when assigning to req.Images) — locate the
conditional around req.Images and req.Image in relay_utils.go and replace the
assignment to req.Images with the normalized/trimmed image string.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 32d16b1f-b3a9-456a-96a5-c57880d83d72
📒 Files selected for processing (5)
relay/channel/task/ali/adaptor.gorelay/channel/task/ali/adaptor_test.gorelay/channel/task/ali/constants.gorelay/common/relay_utils.gorelay/common/relay_utils_test.go
e1153ab to
e4cbbde
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
relay/channel/task/ali/adaptor_test.go (1)
18-121: ⚡ Quick winAdd one regression test for mixed-source precedence (
image/images+input_reference).Current cases are solid, but they don’t lock behavior when both legacy and direct image fields are sent together—the exact edge where source selection can drift.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/channel/task/ali/adaptor_test.go` around lines 18 - 121, Add a regression test named TestConvertToAliRequestMixedSourcePrecedence in adaptor_test.go that constructs a TaskAdaptor and a relaycommon.TaskSubmitReq for model "wan2.7-i2v" with both Image/Images set and Metadata containing an explicit input.media (or input_reference) entry; call adaptor.convertToAliRequest(testRelayInfo(), req) and assert no error, then assert that aliReq.Input.Media equals the metadata-provided media (not the Image/Images), aliReq.Input.ImgURL is empty, and the marshaled body contains "media" and does not contain "img_url" to lock precedence of explicit metadata over image/images.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@relay/channel/task/ali/adaptor_test.go`:
- Around line 18-121: Add a regression test named
TestConvertToAliRequestMixedSourcePrecedence in adaptor_test.go that constructs
a TaskAdaptor and a relaycommon.TaskSubmitReq for model "wan2.7-i2v" with both
Image/Images set and Metadata containing an explicit input.media (or
input_reference) entry; call adaptor.convertToAliRequest(testRelayInfo(), req)
and assert no error, then assert that aliReq.Input.Media equals the
metadata-provided media (not the Image/Images), aliReq.Input.ImgURL is empty,
and the marshaled body contains "media" and does not contain "img_url" to lock
precedence of explicit metadata over image/images.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 22828849-f2f5-4463-80b4-ed50c1ac891b
📒 Files selected for processing (5)
relay/channel/task/ali/adaptor.gorelay/channel/task/ali/adaptor_test.gorelay/channel/task/ali/constants.gorelay/common/relay_utils.gorelay/common/relay_utils_test.go
e4cbbde to
c19ecd8
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (2)
relay/common/relay_utils.go (1)
142-144:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winTrim the normalized single-image value before storing it.
Line 142 trims for validation, but Line 144 stores the raw string. This can propagate leading/trailing spaces into
req.Images.Suggested patch
- } else if len(req.Images) == 0 && strings.TrimSpace(req.Image) != "" { + } else if len(req.Images) == 0 && strings.TrimSpace(req.Image) != "" { // 兼容单图上传 - req.Images = []string{req.Image} + req.Images = []string{strings.TrimSpace(req.Image)} }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/common/relay_utils.go` around lines 142 - 144, The code validates with strings.TrimSpace(req.Image) but then stores the untrimmed value into req.Images, so update the branch that handles single-image compatibility to assign the trimmed value: compute trimmed := strings.TrimSpace(req.Image) (or reuse the trimmed value used for validation) and set req.Images = []string{trimmed} instead of using req.Image; ensure req.Image remains unchanged only if needed elsewhere or optionally overwrite req.Image with the trimmed value for consistency.relay/channel/task/ali/adaptor.go (1)
276-287:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPrefer
image/imagesoverinput_referenceinfirstTaskImage.This still picks
input_referencefirst, so when a request carries both the new direct-image fields and the legacy reference, Wan2.7 media derivation can send the wrong first frame. Because Line 348 reuses this helper, the legacyimg_urlpath inherits the same bug. Reorder the fallback toimage→images[0]→input_reference, and trim whitespace so blank values do not block later candidates.Suggested fix
func firstTaskImage(req relaycommon.TaskSubmitReq) string { - if req.InputReference != "" { - return req.InputReference - } - if req.Image != "" { + if strings.TrimSpace(req.Image) != "" { return req.Image } - if len(req.Images) > 0 { + if len(req.Images) > 0 && strings.TrimSpace(req.Images[0]) != "" { return req.Images[0] } + if strings.TrimSpace(req.InputReference) != "" { + return req.InputReference + } return "" }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/channel/task/ali/adaptor.go` around lines 276 - 287, The helper firstTaskImage currently prefers input_reference first and doesn't trim blanks; change its fallback order to prefer req.Image, then req.Images[0], then req.InputReference, and ensure you trim whitespace from each candidate so empty or whitespace-only values don't block later options; update the logic in function firstTaskImage (used elsewhere, e.g., the legacy img_url path) to check strings.TrimSpace(req.Image), iterate images checking strings.TrimSpace on each entry, and finally use strings.TrimSpace(req.InputReference) as the last resort.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@relay/channel/task/ali/adaptor.go`:
- Around line 276-287: The helper firstTaskImage currently prefers
input_reference first and doesn't trim blanks; change its fallback order to
prefer req.Image, then req.Images[0], then req.InputReference, and ensure you
trim whitespace from each candidate so empty or whitespace-only values don't
block later options; update the logic in function firstTaskImage (used
elsewhere, e.g., the legacy img_url path) to check strings.TrimSpace(req.Image),
iterate images checking strings.TrimSpace on each entry, and finally use
strings.TrimSpace(req.InputReference) as the last resort.
In `@relay/common/relay_utils.go`:
- Around line 142-144: The code validates with strings.TrimSpace(req.Image) but
then stores the untrimmed value into req.Images, so update the branch that
handles single-image compatibility to assign the trimmed value: compute trimmed
:= strings.TrimSpace(req.Image) (or reuse the trimmed value used for validation)
and set req.Images = []string{trimmed} instead of using req.Image; ensure
req.Image remains unchanged only if needed elsewhere or optionally overwrite
req.Image with the trimmed value for consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 807d1228-441b-4f1f-a65a-7b8b46fda618
📒 Files selected for processing (5)
relay/channel/task/ali/adaptor.gorelay/channel/task/ali/adaptor_test.gorelay/channel/task/ali/constants.gorelay/common/relay_utils.gorelay/common/relay_utils_test.go
✅ Files skipped from review due to trivial changes (1)
- relay/channel/task/ali/constants.go
|
@Calcium-Ion @creamlike1024 麻烦有空帮忙看一下这个 PR,谢谢。 我看了下最新 main 还没有包含 wan2.7-i2v 的 input.media 映射逻辑。这个 PR 范围比较小,只补 Ali Wan2.7 i2v 的 media mapping 和对应测试 |
|
好的 |
* feat: improve advanced custom route editor * Bump Electron lockfile dependencies * feat: bill doubao seedance-2.0 by output resolution and video input (QuantumNous#5300) * feat: support doubao seedance 2.0 safety_identifier/priority and 4k billing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video * chore: run `bun format` to automatically format the frontend code * fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题 (QuantumNous#5795) * fix(web): 修复自定义 HTML 样式被过滤及排版间距异常的问题 * fix(web): isolate custom HTML rendering --------- Co-authored-by: CaIon <[email protected]> * feat: support Wan2.7 i2v media mapping (QuantumNous#4984) * feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs * perf(web): optimize web Rsbuild and Tailwind build pipeline (QuantumNous#5786) * fix(dev): run only default frontend in dev-web - simplify make dev-web to install default dependencies and start web/default only. - keep dev-web-classic as the standalone classic entry and scope its install to classic. * chore(build): align make targets with web naming - rename frontend make targets and variables to use the web terminology consistently. - keep default and classic dev port overrides available under the updated names. * fix(web): inject app styles into isolated HTML (QuantumNous#5860) - clone loaded application style nodes into the Shadow DOM for custom HTML rendering. - keep HTML rendering isolated while restoring layout and typography that depend on app CSS. * fix: keep page state when switching tabs within the same route (QuantumNous#5796) AnimatedOutlet keyed its motion container by the full pathname, so navigating between params of the same route (e.g. the dashboard tabs under /dashboard/$section) changed the key and remounted the route component, discarding its in-memory state. The most visible symptom: the dashboard time range resets to the default every time you switch sub-tabs (Model Analytics / Flow / User Analytics). Key the transition by the matched route id instead, so param-only navigation re-renders in place while real page-to-page navigation still plays the enter animation. This also preserves state across the other $section tab pages (usage logs, models, system settings). * 支持服务优雅关闭,避免重启回复中断和面板缓存数据丢失 (QuantumNous#4258) * feat: add graceful shutdown with configurable timeout * fix: flush quota dashboard cache on graceful shutdown Persist the in-memory CacheQuotaData aggregation to the quota_data table before process exit, so a restart no longer drops up to one DataExportInterval window of dashboard data (issue QuantumNous#5679). * docs: update AGENTS.md * Make quota logging synchronous and delay startup log --------- Co-authored-by: CaIon <[email protected]> Co-authored-by: feitianbubu <[email protected]> Co-authored-by: t0ng7u <[email protected]> Co-authored-by: olwater <[email protected]> Co-authored-by: Scott <[email protected]> Co-authored-by: QuentinHsu <[email protected]> Co-authored-by: henrydontbbai <[email protected]>
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs (cherry picked from commit 52858ad)
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs (cherry picked from commit 52858ad)
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs (cherry picked from commit 52858ad)
* feat: support Wan2.7 i2v media mapping * fix: normalize wan2.7 i2v image inputs
Important
📝 变更描述 / Description
本次为 Ali 视频生成渠道补充 Wan2.7 图生视频协议适配。
Wan2.7 I2V 使用的是新的
input.media入参格式,而当前 Ali adaptor 仍主要按旧版img_url/first_frame_url/last_frame_url字段组织请求。这个改动在wan2.7-i2v场景下将通用视频请求里的image、images、input_reference映射为 DashScope 所需的input.media:type: first_framefirst_frame+last_framemetadata.input.media会被保留img_url逻辑同时补充了
wan2.7-i2v、wan2.7-t2v到 Ali task model list,并让 direct video request 路径兼容单图image字段,避免图生视频请求没有被识别为带图任务。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work