feat: support doubao image video model#577
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Doubao (Volc/Ark) adaptor support for image generation and video generation/v1 videos APIs, including async usage fetching so the proxy can meter video jobs after completion.
Changes:
- Add Doubao image generations request normalization and response/stream conversion with usage accounting.
- Add Doubao video job submit/status/content handlers, including multipart support and store caching for job/generation IDs.
- Implement Doubao async-usage fetcher for video jobs and extend adaptor routing/support + tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/relay/adaptor/doubao/video.go | Implements Doubao video request conversion, task submit/status/content handlers, and store caching for jobs/generations. |
| core/relay/adaptor/doubao/video_helpers.go | Adds parsing/normalization helpers for Doubao video request fields (ints/bools/nested url/id, ratio derivation). |
| core/relay/adaptor/doubao/image.go | Implements Doubao image generations conversion + response/stream handlers and usage mapping. |
| core/relay/adaptor/doubao/async_usage.go | Adds async usage fetcher for Doubao video tasks (poll task status and map usage/context). |
| core/relay/adaptor/doubao/main.go | Wires new Doubao image/video modes into URL routing, request conversion, and response handling. |
| core/relay/adaptor/doubao/main_test.go | Extends tests to cover new modes/URLs, image normalization/usage/streaming, video conversion/store saving, and async usage fetching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| job.Width, job.Height = doubaoVideoDimensions(response.Resolution, response.Ratio) | ||
|
|
||
| if status == relaymodel.VideoGenerationJobStatusSucceeded || | ||
| status == relaymodel.VideoGenerationJobStatus("failed") { |
Comment on lines
+159
to
+166
| Resolution: firstNonEmptyString( | ||
| stringFromAny(raw["resolution"]), | ||
| stringFromAny(raw["size"]), | ||
| ), | ||
| Ratio: firstNonEmptyString( | ||
| stringFromAny(raw["ratio"]), | ||
| ratioFromSize(stringFromAny(raw["size"])), | ||
| ), |
Comment on lines
+195
to
+210
| func parseDoubaoMultipartVideoRequest(req *http.Request) (doubaoVideoRequest, error) { | ||
| if err := common.ParseMultipartFormWithLimit(req); err != nil { | ||
| return doubaoVideoRequest{}, fmt.Errorf("parse multipart form: %w", err) | ||
| } | ||
|
|
||
| request := doubaoVideoRequest{ | ||
| CallbackURL: req.PostFormValue("callback_url"), | ||
| ServiceTier: req.PostFormValue("service_tier"), | ||
| SafetyIdentifier: req.PostFormValue("safety_identifier"), | ||
| Resolution: firstNonEmptyString( | ||
| req.PostFormValue("resolution"), | ||
| req.PostFormValue("size"), | ||
| ), | ||
| Ratio: firstNonEmptyString( | ||
| req.PostFormValue("ratio"), | ||
| ratioFromSize(req.PostFormValue("size")), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.