Repository navigation
feat: support doubao seedance 2.0 safety_identifier/priority and 4k billing - #5824
Conversation
WalkthroughAdds 4K resolution support to Doubao video pricing by extending the ChangesDoubao video pricing and tool payload
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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/doubao/adaptor.go`:
- Around line 55-63: The tool metadata fields are currently defined after the
anonymous Tools struct is closed, so they serialize at the top level of
requestPayload instead of inside each tool item. Move SafetyIdentifier,
Priority, Resolution, Ratio, Duration, Frames, Seed, CameraFixed, and Watermark
back into the Tools item payload definition in adaptor.go, and verify the
request shape produced by the relevant payload struct matches the upstream tool
schema.
- Line 55: The optional safety_identifier field in the Doubao adapter request
struct is using a plain string, which loses the distinction between omitted and
explicitly empty values when re-marshaled. Update the request type in adaptor.go
so SafetyIdentifier uses pointer semantics like Priority, and ensure the
upstream JSON payload preserves absence vs empty value through the existing
marshal path.
🪄 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: 20e0a36b-757b-4f41-8878-b63fa7903f32
📒 Files selected for processing (2)
relay/channel/task/doubao/adaptor.gorelay/channel/task/doubao/constants.go
| Seed *dto.IntValue `json:"seed,omitempty"` | ||
| CameraFixed *dto.BoolValue `json:"camera_fixed,omitempty"` | ||
| Watermark *dto.BoolValue `json:"watermark,omitempty"` | ||
| SafetyIdentifier string `json:"safety_identifier,omitempty"` |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Use a pointer for optional safety_identifier.
With omitempty, a plain string collapses “absent” and explicit "" into the same outbound payload. This adapter is re-marshaling client JSON upstream, so safety_identifier needs pointer semantics just like priority.
Proposed fix
- SafetyIdentifier string `json:"safety_identifier,omitempty"`
+ SafetyIdentifier *string `json:"safety_identifier,omitempty"`As per coding guidelines, “For request structs parsed from client JSON and re-marshaled to upstream providers, use pointer types for optional scalar fields with omitempty tags.”
📝 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.
| SafetyIdentifier string `json:"safety_identifier,omitempty"` | |
| SafetyIdentifier *string `json:"safety_identifier,omitempty"` |
🤖 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/doubao/adaptor.go` at line 55, The optional
safety_identifier field in the Doubao adapter request struct is using a plain
string, which loses the distinction between omitted and explicitly empty values
when re-marshaled. Update the request type in adaptor.go so SafetyIdentifier
uses pointer semantics like Priority, and ensure the upstream JSON payload
preserves absence vs empty value through the existing marshal path.
Source: Coding guidelines
| SafetyIdentifier string `json:"safety_identifier,omitempty"` | ||
| Priority *dto.IntValue `json:"priority,omitempty"` | ||
| Resolution string `json:"resolution,omitempty"` | ||
| Ratio string `json:"ratio,omitempty"` | ||
| Duration *dto.IntValue `json:"duration,omitempty"` | ||
| Frames *dto.IntValue `json:"frames,omitempty"` | ||
| Seed *dto.IntValue `json:"seed,omitempty"` | ||
| CameraFixed *dto.BoolValue `json:"camera_fixed,omitempty"` | ||
| Watermark *dto.BoolValue `json:"watermark,omitempty"` |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Move these fields back into the tools item payload.
The anonymous Tools struct is already closed on Line 54, so safety_identifier, priority, and the related video options serialize at the top level of requestPayload instead of under each tool entry. That breaks the upstream schema the PR summary describes for tool metadata.
🤖 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/doubao/adaptor.go` around lines 55 - 63, The tool metadata
fields are currently defined after the anonymous Tools struct is closed, so they
serialize at the top level of requestPayload instead of inside each tool item.
Move SafetyIdentifier, Priority, Resolution, Ratio, Duration, Frames, Seed,
CameraFixed, and Watermark back into the Tools item payload definition in
adaptor.go, and verify the request shape produced by the relevant payload struct
matches the upstream tool schema.
* 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]>
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video (cherry picked from commit e514db2)
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video (cherry picked from commit e514db2)
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video (cherry picked from commit e514db2)
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video (cherry picked from commit e514db2)
…illing (QuantumNous#5824) * feat: support safety_identifier and priority for doubao video * feat: add 4k resolution billing tier for doubao video
📝 变更描述 / Description
官方文档:
https://www.volcengine.com/docs/82379/1520757为 Doubao Seedance 2.0 系列视频模型补齐两处与官方接口对齐的改动:
requestPayload新增safety_identifier(终端用户唯一标识)与priority(队列优先级,仅 Seedance 2.0 支持)两个字段,经 metadata 透传至上游。priority采用指针类型,以区分「未传」与「显式传 0」,避免零值被omitempty丢弃。✅ 提交前检查项 / Checklist
go build ./relay/channel/task/doubao/通过。📸 运行证明 / Proof of Work
修复前,按720计费, 9元/秒


修复后: 按4k正确计费 5元/秒