Skip to content

feat: vertex veo sora-compatible video output - #2102

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
Sh1n3zZ:feat-sora-vertex-adaptor
Oct 28, 2025
Merged

feat: vertex veo sora-compatible video output#2102
seefs001 merged 1 commit into
QuantumNous:mainfrom
Sh1n3zZ:feat-sora-vertex-adaptor

Conversation

@Sh1n3zZ

@Sh1n3zZ Sh1n3zZ commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

为 vertex 渠道 veo 模型添加 ConvertToOpenAIVideo 方法
支持以 OpenAI Sora 格式返回 vertex 渠道的 veo 模型生成的视频内容

Summary by CodeRabbit

  • New Features

    • Added enhanced video request processing and conversion capabilities.
  • Bug Fixes

    • Improved error reporting for video operations by refining failure reason handling.
    • Fixed response routing and timing for video-related requests to ensure proper content delivery.

@coderabbitai

coderabbitai Bot commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Two files are modified to add OpenAI video format support for Vertex AI tasks. A new ConvertToOpenAIVideo method is introduced to transform tasks into OpenAI video DTOs, and conditional logic is added to skip standard response marshalling for video-related endpoint URIs and prevent overwriting certain failure reasons.

Changes

Cohort / File(s) Summary
Video conversion method
relay/channel/task/vertex/adaptor.go
Added ConvertToOpenAIVideo(task *model.Task) method that derives task names, infers model (defaulting to "ve o-3.0-generate-001"), constructs OpenAI video DTO with task metadata, conditionally attaches data URLs for failure reasons, and marshals to JSON. Added common package import.
Response flow control
relay/relay_task.go
Modified to skip response marshalling for URIs starting with /v1/videos/ and prevent updating originTask.FailReason when ti.Url already starts with "data:".

Sequence Diagram

sequenceDiagram
    participant Client
    participant RelayTask as relay_task.go
    participant TaskAdaptor as adaptor.go
    participant Common

    Client->>RelayTask: Request to /v1/videos/...
    alt URL starts with /v1/videos/
        RelayTask->>RelayTask: Skip standard response marshalling
        RelayTask->>TaskAdaptor: ConvertToOpenAIVideo(task)
        TaskAdaptor->>TaskAdaptor: Derive task name & infer model
        TaskAdaptor->>TaskAdaptor: Build OpenAI video DTO
        TaskAdaptor->>Common: Marshal(videoDTO)
        Common-->>TaskAdaptor: []byte JSON
        TaskAdaptor-->>RelayTask: []byte, error
        RelayTask-->>Client: Video response
    else Standard request
        RelayTask->>RelayTask: Normal response flow
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The changes are localized and straightforward: a new conversion method following standard patterns, and conditional URI-based routing logic. The implementation is self-contained and requires minimal context about existing video handling.

Possibly related PRs

  • feat: vertex veo (#1450) #1659: Directly related—modifies the same adaptor.go file's Vertex AI veo task handling and video response control flow patterns.

Poem

🐰✨ A task hops into video format true,
ConvertToOpenAIVideo spins the OpenAI dew,
Skip the standard marsh for videos bright,
Data URLs dance in the URL light! 🎬

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 PR title "feat: vertex veo sora-compatible video output" directly and clearly summarizes the primary changes in the pull request. It specifically identifies the channel (vertex), the model (veo), the target format compatibility (sora-compatible), and the type of output (video). The title aligns with the PR objectives of adding a ConvertToOpenAIVideo method and supporting OpenAI Sora format output for the vertex channel's veo model. The title is concise, uses conventional commit format, and avoids generic or vague terminology.
✨ 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.

@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: 0

🧹 Nitpick comments (1)
relay/channel/task/vertex/adaptor.go (1)

322-324: Remove the redundant length check and clarify backward compatibility intent.

The observation about the redundant len(task.FailReason) > 0 check is valid—strings.HasPrefix returns false for empty strings, making this condition unnecessary.

More importantly, the codebase now prevents data URLs from being stored in FailReason (confirmed in relay_task.go lines 354-357 and controller/task_video.go lines 140-142). This means the condition on line 322 should only trigger for legacy data. If this is intentional for backward compatibility, add a comment explaining it. Otherwise, this code may be unreachable.

Apply this diff:

-	if strings.HasPrefix(task.FailReason, "data:") && len(task.FailReason) > 0 {
+	if strings.HasPrefix(task.FailReason, "data:") {
 		v.SetMetadata("url", task.FailReason)
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 032f159 and 810641a.

📒 Files selected for processing (2)
  • relay/channel/task/vertex/adaptor.go (2 hunks)
  • relay/relay_task.go (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-26T09:59:00.337Z
Learnt from: Sh1n3zZ
PR: QuantumNous/new-api#1659
File: relay/relay_task.go:285-305
Timestamp: 2025-08-26T09:59:00.337Z
Learning: In controller/task_video.go, data: URLs (containing base64 encoded video data) are prevented from being stored in task.FailReason by checking if the URL starts with "data:" before assignment. This same pattern should be applied consistently across the codebase.

Applied to files:

  • relay/relay_task.go
🧬 Code graph analysis (1)
relay/channel/task/vertex/adaptor.go (2)
dto/openai_video.go (1)
  • NewOpenAIVideo (43-47)
common/json.go (1)
  • Marshal (21-23)
🔇 Additional comments (6)
relay/channel/task/vertex/adaptor.go (4)

13-13: LGTM!

The import is necessary for common.Marshal used in the new ConvertToOpenAIVideo method.


307-314: LGTM!

The error handling for task ID decoding and model name extraction is reasonable, with appropriate fallback to a default model name that's consistent with line 91.


315-321: LGTM!

The OpenAI video DTO is correctly populated with task metadata, and the status/progress conversions are appropriate.


326-327: LGTM!

The marshaling and error handling are correct.

relay/relay_task.go (2)

385-398: Conditional response building looks correct.

The logic to skip standard response marshalling for /v1/videos/ URIs is appropriate, as these are handled separately by the OpenAI format conversion below (lines 406-422). However, note the data URL issue flagged in the previous comment also affects this response path.


354-357: Verify whether data URLs should be returned in non-OpenAI format responses or discarded entirely.

The data URL prevention logic is intentional (matching the pattern in controller/task_video.go), but it creates a real data loss issue for the non-OpenAI response path:

When ti.Url is a data URL (video content embedded in the URL):

  • It's intentionally not stored in originTask.FailReason (line 356 has an empty block)
  • But the response at line 392 returns originTask.FailReason as the url field
  • Result: The data URL is lost; clients get an empty or stale URL instead

The OpenAI format path (line 413+) bypasses this issue by reading from originTask.Data rather than FailReason.

Options:

  1. If data URLs should be returned: Use the suggested local variable approach to preserve ti.Url for the response without persisting it
  2. If data URLs should be discarded: Add explicit handling to omit the url field or return a placeholder when a data URL was received

Clarify the intended behavior before proceeding with the fix.

@seefs001
seefs001 merged commit 1c582cd into QuantumNous:main Oct 28, 2025
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 31, 2025
@Sh1n3zZ
Sh1n3zZ deleted the feat-sora-vertex-adaptor branch November 7, 2025 04:22
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ptor

feat: vertex veo sora-compatible video output
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