Skip to content

Revert "Gemini Veo3.1[AI Studio]增加图生视频支持" - #2337

Merged
Calcium-Ion merged 1 commit into
mainfrom
revert-2315-pr/gemini-veo3.1-i2v
Nov 30, 2025
Merged

Revert "Gemini Veo3.1[AI Studio]增加图生视频支持"#2337
Calcium-Ion merged 1 commit into
mainfrom
revert-2315-pr/gemini-veo3.1-i2v

Conversation

@seefs001

@seefs001 seefs001 commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator

Reverts #2315

Summary by CodeRabbit

  • Refactor
    • Restructured Gemini video generation request handling for improved consistency
    • Enhanced result processing with better status and progress tracking for video generation tasks
    • Simplified video URL extraction from generation responses

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The PR refactors the Gemini video adaptor by renaming types with a Gemini prefix, restructuring payload and request shapes, replacing legacy type definitions, updating validation action constants, and simplifying result parsing to unconditionally set success status and progress.

Changes

Cohort / File(s) Summary
Gemini Video Adaptor Refactoring
relay/channel/task/gemini/adaptor.go
Renamed VideoGenerationConfig to GeminiVideoGenerationConfig; added GeminiVideoPayload and GeminiVideoRequest types; removed public VideoPayload, VideoRequest, and Image types. Updated ValidateRequestAndSetAction to use TaskActionTextGenerate. Modified BuildRequestBody to construct GeminiVideoPayload with GeminiVideoRequest instances. Simplified ParseTaskResult to always set success status and 100% progress, extracting video URL from GenerateVideoResponse.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review type renames and ensure all usages throughout the file are updated consistently
  • Verify ValidateRequestAndSetAction logic change from TaskActionGenerate to TaskActionTextGenerate
  • Confirm ParseTaskResult simplification correctly handles all success and error cases without conditional logic
  • Cross-check that removed public types (VideoPayload, VideoRequest, Image) have no external callers in the broader codebase

Possibly related PRs

Suggested reviewers

  • creamlike1024

Poem

🐰 Whiskers twitching with delight
Types renamed in morning light,
Gemini payloads now take flight,
Video URLs shine so bright! 🎬✨
Legacy shapes fade from sight!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: reverting a previous commit that added Gemini Veo3.1 image-to-video support, which aligns with the raw summary showing removal of video generation types and restructuring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-2315-pr/gemini-veo3.1-i2v

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.

@Calcium-Ion
Calcium-Ion merged commit 6c82531 into main Nov 30, 2025
1 check was pending

@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 (3)
relay/channel/task/gemini/adaptor.go (3)

31-50: Gemini-specific config/payload types look good; consider tightening value domains

The Gemini-prefixed config and payload types align with the documented shape and keep the adaptor clearly vendor‑scoped. If you want to harden this further, you could:

  • Introduce typed constants/enums for AspectRatio and PersonGeneration to avoid invalid strings.
  • Potentially use an integer type for DurationSeconds given allowed discrete values (4, 6, 8), and validate inputs accordingly.

These are optional robustness improvements; the current definitions are functionally fine.


139-155: Metadata → GeminiVideoGenerationConfig mapping is reasonable; watch for unexpected metadata shapes

Building the body as GeminiVideoPayload with Instances[] and then JSON‑round‑tripping req.Metadata into GeminiVideoGenerationConfig is a pragmatic way to let clients control Gemini parameters without tightly coupling the DTOs.

Two minor considerations:

  • If Metadata can ever contain non‑JSON‑serializable values (e.g., maps with non‑string keys), the marshal/unmarshal step will fail at runtime; if that’s possible, you may want an upfront type check or clearer error message.
  • If only a small, known subset of metadata keys is supported, a future refactor could map those fields explicitly and reject unknown keys for stricter validation.

Functionally this is fine as is.


250-263: Success handling and URI extraction look correct; ensure other video fields are truly unused

The simplified success path (Done + no ErrorSUCCESS, Progress = 100%) matches Google’s long‑running operation semantics and is straightforward.

Using GenerateVideoResponse.GeneratedSamples[0].Video.URI to populate RemoteUrl is also a good fit and, combined with the internal /v1/videos/{taskID}/content URL, avoids persisting large base64 payloads in the task record, which is consistent with the redaction approach mentioned in redactVideoResponseBody. Based on learnings, this is aligned with not storing raw video bytes.

One thing to confirm: operationResponse.Response.Videos, BytesBase64Encoded, or Video are now ignored. If any existing Gemini models in GetModelList() still return data only via those fields, you may lose access to the actual video content even though the task is marked SUCCESS. If that’s not intended, consider a fallback that derives RemoteUrl (or equivalent) from those legacy fields.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d0827c and ded463e.

📒 Files selected for processing (1)
  • relay/channel/task/gemini/adaptor.go (4 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: RedwindA
Repo: QuantumNous/new-api PR: 1537
File: relay/gemini_handler.go:330-342
Timestamp: 2025-08-08T17:12:43.157Z
Learning: In the new-api repository, the `GeminiEmbeddingHandler` function in `relay/gemini_handler.go` is designed specifically for native Gemini embedding requests and therefore does not require the `ConvertGeminiRequest` step that is used in the chat handler. The embedding requests are already in the native Gemini format and don't need conversion.
📚 Learning: 2025-08-08T17:12:43.157Z
Learnt from: RedwindA
Repo: QuantumNous/new-api PR: 1537
File: relay/gemini_handler.go:330-342
Timestamp: 2025-08-08T17:12:43.157Z
Learning: In the new-api repository, the `GeminiEmbeddingHandler` function in `relay/gemini_handler.go` is designed specifically for native Gemini embedding requests and therefore does not require the `ConvertGeminiRequest` step that is used in the chat handler. The embedding requests are already in the native Gemini format and don't need conversion.

Applied to files:

  • relay/channel/task/gemini/adaptor.go
📚 Learning: 2025-06-21T03:37:41.726Z
Learnt from: 9Ninety
Repo: QuantumNous/new-api PR: 1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.

Applied to files:

  • relay/channel/task/gemini/adaptor.go
📚 Learning: 2025-08-26T09:59:00.337Z
Learnt from: Sh1n3zZ
Repo: QuantumNous/new-api PR: 1659
File: relay/relay_task.go:285-305
Timestamp: 2025-08-26T09:59:00.337Z
Learning: In controller/task_video.go, the redactVideoResponseBody function sanitizes video task responses by removing bytesBase64Encoded fields and truncating base64 strings to 256 characters to prevent large binary data from being stored in task.Data.

Applied to files:

  • relay/channel/task/gemini/adaptor.go
🧬 Code graph analysis (1)
relay/channel/task/gemini/adaptor.go (4)
relay/common/relay_utils.go (1)
  • ValidateBasicTaskRequest (207-231)
constant/task.go (1)
  • TaskActionTextGenerate (15-15)
model/task.go (1)
  • TaskStatusSuccess (38-38)
setting/system_setting/system_setting_old.go (1)
  • ServerAddress (3-3)
🔇 Additional comments (1)
relay/channel/task/gemini/adaptor.go (1)

101-105: Confirm that using TaskActionTextGenerate is intentional for video tasks

ValidateRequestAndSetAction now always uses TaskActionTextGenerate when calling ValidateBasicTaskRequest. That works for parsing and basic validation, but if there is (or will be) a more specific action for video (e.g., for routing, metrics, or UI filtering), you may want to switch to that instead to avoid misclassifying these tasks at a higher layer.

Please double‑check that textGenerate is indeed the desired action identifier for this adaptor.

@Calcium-Ion
Calcium-Ion deleted the revert-2315-pr/gemini-veo3.1-i2v branch January 29, 2026 17:10
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…emini-veo3.1-i2v

Revert "Gemini Veo3.1[AI Studio]增加图生视频支持"
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
Claude Code can send one assistant turn with multiple tool_use blocks followed by a user turn containing matching tool_result blocks. The OpenAI /v1/messages compatibility path trimmed continuation input to the last user turn plus adjacent tool outputs, which could leave a function_call_output without its earlier function_call when previous_response_id was attached.

This keeps all function_call items needed by retained function_call_output entries so the upstream Responses API can resolve every call_id.

Constraint: Applies only to the OpenAI /v1/messages -> Responses compatibility continuation path.

Rejected: Disable previous_response_id for all tool outputs | loses continuation and cache benefits for valid turns.

Confidence: high

Scope-risk: narrow

Directive: Do not trim function_call_output entries without preserving their matching function_call call_id context.

Tested: go test ./internal/service -run 'TestForwardAsAnthropic_(PreviousResponseIDKeepsMultiToolCallContext|AttachesPreviousResponseIDForCompatContinuation|OAuthPreservesClaudeCodeToolCallID)' -count=1

Tested: go test ./internal/service -run 'TestForwardAsAnthropic|TestApplyAnthropicCompatFullReplayGuard|TestOpenAICompat|Test.*ToolContinuation' -count=1

Tested: go test ./internal/pkg/apicompat -count=1

Related: QuantumNous#2337
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