feat: video operations in runware - #4615
Conversation
|
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe Runware provider's image-specific types ( ChangesRunware Video Support
Sequence Diagram(s)sequenceDiagram
participant Client
participant BifrostProvider as Runware Provider
participant sendTaskArray
participant RunwareAPI as Runware API
rect rgba(70, 130, 180, 0.5)
Note over Client,RunwareAPI: VideoGeneration
Client->>BifrostProvider: VideoGeneration(BifrostVideoGenerationRequest)
BifrostProvider->>sendTaskArray: videoInference task array
sendTaskArray->>RunwareAPI: POST /inference [taskType=videoInference, async]
RunwareAPI-->>sendTaskArray: RunwareResponse{Data[0]: taskUUID, status}
sendTaskArray-->>BifrostProvider: decoded response + latency
BifrostProvider->>BifrostProvider: firstVideoResult → ToBifrostVideoGenerationResponse
BifrostProvider-->>Client: BifrostVideoGenerationResponse (taskUUID+suffix, status=queued)
end
rect rgba(34, 139, 34, 0.5)
Note over Client,RunwareAPI: VideoRetrieve (polling)
Client->>BifrostProvider: VideoRetrieve(taskUUID+suffix)
BifrostProvider->>sendTaskArray: getResponse task array (stripped UUID)
sendTaskArray->>RunwareAPI: POST /inference [taskType=getResponse]
RunwareAPI-->>sendTaskArray: RunwareResponse{Data[0]: videoURL, status}
sendTaskArray-->>BifrostProvider: decoded response
BifrostProvider-->>Client: BifrostVideoGenerationResponse (status=completed, videoURL)
end
rect rgba(178, 34, 34, 0.5)
Note over Client,RunwareAPI: VideoDownload
Client->>BifrostProvider: VideoDownload(taskUUID)
BifrostProvider->>BifrostProvider: VideoRetrieve → validate completed + videoURL
BifrostProvider->>RunwareAPI: HTTP GET videoURL
RunwareAPI-->>BifrostProvider: video bytes + Content-Type
BifrostProvider-->>Client: BifrostVideoDownloadResponse (bytes, content type)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@core/providers/runware/runware_test.go`:
- Around line 29-35: The Scenarios struct in the test configuration has
VideoGenerationModel set but all video scenario flags (VideoGeneration,
VideoRetrieve, VideoDownload) are disabled. To exercise the new Runware video
provider methods in tests, change at least the VideoGeneration flag (and ideally
VideoRetrieve as well) from false to true in the Scenarios configuration.
Alternatively, if video test coverage is intentionally deferred, add an explicit
SkipReason field explaining why these scenarios are disabled.
In `@core/providers/runware/runware.go`:
- Around line 382-427: The VideoDownload method accepts a request parameter with
a Variant field, but never uses it when selecting which video asset to download.
Update the method to use the request.Variant to select the appropriate video
from taskDetails.Videos instead of always using the first element at index 0.
Add validation to ensure the requested variant exists in the response, and
return an appropriate error if the variant is not found or if variants are
expected but none are available in the taskDetails.
In `@core/providers/runware/videos.go`:
- Around line 69-73: The `ToBifrostVideoGenerationResponse` function is
incorrectly setting the `CreatedAt` field to `time.Now().Unix()`, which causes
incorrect timestamps when the function is used for retrieve/polling operations.
Instead of synthesizing the current time, use the actual creation timestamp from
the result object (which should contain the original creation time). Replace the
`CreatedAt: time.Now().Unix()` assignment with the corresponding creation
timestamp field from the result parameter.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 85007a50-d5b7-440a-856d-3dbe0b759648
📒 Files selected for processing (6)
core/providers/runware/images.gocore/providers/runware/runware.gocore/providers/runware/runware_test.gocore/providers/runware/types.gocore/providers/runware/utils.gocore/providers/runware/videos.go
55dbf0a to
b0bc2a6
Compare
2c9c1c9 to
2697006
Compare
Merge activity
|
The base branch was changed.
2697006 to
a6be983
Compare
## Summary Implements video generation, retrieval, and download for the Runware provider, replacing the previous stub implementations that returned "unsupported operation" errors. Also consolidates the separate `RunwareImageInferenceRequest` and `RunwareImageResult` types into unified `RunwareInferenceRequest` and `RunwareResult` types that cover both image and video modalities. ## Changes - Replaced `RunwareImageInferenceRequest` with `RunwareInferenceRequest`, a single struct covering image and video task fields. `PositivePrompt`, `Width`, and `Height` are now pointer fields to support optional omission (required for video tasks where some fields may not apply). - Replaced `RunwareImageResult` with `RunwareResult`, adding video-specific fields (`VideoUUID`, `VideoURL`, `Status`). - Added `taskTypeVideoInference` and `taskTypeGetResponse` task type constants, and a `deliveryMethodAsync` constant used to queue video tasks asynchronously. - Extracted a `sendTaskArray` helper that wraps a single task in the Runware array envelope, posts it, and returns the decoded response — eliminating duplicated HTTP logic across image and video operations. - Added `videos.go` with `ToRunwareVideoGenerationRequest` (text-to-video and image-to-video via `frameImages`) and `ToBifrostVideoGenerationResponse` (maps Runware status strings to Bifrost `VideoStatus` values). - `VideoGeneration` submits a `videoInference` task asynchronously and returns the queued job ID. - `VideoRetrieve` polls a previously submitted task using a `getResponse` task type. - `VideoDownload` calls `VideoRetrieve` to confirm completion, then fetches the video bytes from the returned URL. - Added default video dimensions (`1920x1080`) separate from the image defaults (`1024x1024`), with a comment explaining why square dimensions are rejected by video models. - Updated the test config to use `runware:102@1` (FLUX Fill) for image editing and added a `klingai:kling-video@3-pro` video model entry with video scenarios disabled by default. ## Type of change - [ ] Bug fix - [x] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [x] Providers/Integrations - [ ] Plugins - [ ] UI (React) - [ ] Docs ## How to test Enable the video scenarios in `runware_test.go` by setting `VideoGeneration`, `VideoRetrieve`, and `VideoDownload` to `true`, then run with a valid Runware API key: ```sh go test ./core/providers/runware/... -v -run TestRunware ``` Expected outcomes: - `VideoGeneration` returns a response with a non-empty `ID` and a queued/in-progress status. - `VideoRetrieve` using the returned `ID` returns the task status (poll until `completed`). - `VideoDownload` returns raw video bytes with a `video/mp4` content type once the task is complete. Image generation and edit tests remain enabled and should continue to pass unchanged. ## Breaking changes - [x] Yes - [ ] No `RunwareImageInferenceRequest` and `RunwareImageResult` have been removed and replaced by `RunwareInferenceRequest` and `RunwareResult`. Any code outside this package referencing those types directly will need to be updated to use the new names. ## Related issues ## Security considerations No new auth mechanisms are introduced. The existing Bearer token flow is reused for all video endpoints. Video bytes are fetched via a direct GET to the Runware-provided URL without forwarding user credentials. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [x] I added/updated tests where appropriate - [ ] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Implements video generation, retrieval, and download for the Runware provider, replacing the previous stub implementations that returned "unsupported operation" errors. Also consolidates the separate
RunwareImageInferenceRequestandRunwareImageResulttypes into unifiedRunwareInferenceRequestandRunwareResulttypes that cover both image and video modalities.Changes
RunwareImageInferenceRequestwithRunwareInferenceRequest, a single struct covering image and video task fields.PositivePrompt,Width, andHeightare now pointer fields to support optional omission (required for video tasks where some fields may not apply).RunwareImageResultwithRunwareResult, adding video-specific fields (VideoUUID,VideoURL,Status).taskTypeVideoInferenceandtaskTypeGetResponsetask type constants, and adeliveryMethodAsyncconstant used to queue video tasks asynchronously.sendTaskArrayhelper that wraps a single task in the Runware array envelope, posts it, and returns the decoded response — eliminating duplicated HTTP logic across image and video operations.videos.gowithToRunwareVideoGenerationRequest(text-to-video and image-to-video viaframeImages) andToBifrostVideoGenerationResponse(maps Runware status strings to BifrostVideoStatusvalues).VideoGenerationsubmits avideoInferencetask asynchronously and returns the queued job ID.VideoRetrievepolls a previously submitted task using agetResponsetask type.VideoDownloadcallsVideoRetrieveto confirm completion, then fetches the video bytes from the returned URL.1920x1080) separate from the image defaults (1024x1024), with a comment explaining why square dimensions are rejected by video models.runware:102@1(FLUX Fill) for image editing and added aklingai:kling-video@3-provideo model entry with video scenarios disabled by default.Type of change
Affected areas
How to test
Enable the video scenarios in
runware_test.goby settingVideoGeneration,VideoRetrieve, andVideoDownloadtotrue, then run with a valid Runware API key:go test ./core/providers/runware/... -v -run TestRunwareExpected outcomes:
VideoGenerationreturns a response with a non-emptyIDand a queued/in-progress status.VideoRetrieveusing the returnedIDreturns the task status (poll untilcompleted).VideoDownloadreturns raw video bytes with avideo/mp4content type once the task is complete.Image generation and edit tests remain enabled and should continue to pass unchanged.
Breaking changes
RunwareImageInferenceRequestandRunwareImageResulthave been removed and replaced byRunwareInferenceRequestandRunwareResult. Any code outside this package referencing those types directly will need to be updated to use the new names.Related issues
Security considerations
No new auth mechanisms are introduced. The existing Bearer token flow is reused for all video endpoints. Video bytes are fetched via a direct GET to the Runware-provided URL without forwarding user credentials.
Checklist
docs/contributing/README.mdand followed the guidelines