Revert "Gemini Veo3.1[AI Studio]增加图生视频支持" - #2337
Conversation
WalkthroughThe 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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: 0
🧹 Nitpick comments (3)
relay/channel/task/gemini/adaptor.go (3)
31-50: Gemini-specific config/payload types look good; consider tightening value domainsThe 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
AspectRatioandPersonGenerationto avoid invalid strings.- Potentially use an integer type for
DurationSecondsgiven allowed discrete values (4, 6, 8), and validate inputs accordingly.These are optional robustness improvements; the current definitions are functionally fine.
139-155: Metadata →GeminiVideoGenerationConfigmapping is reasonable; watch for unexpected metadata shapesBuilding the body as
GeminiVideoPayloadwithInstances[]and then JSON‑round‑trippingreq.MetadataintoGeminiVideoGenerationConfigis a pragmatic way to let clients control Gemini parameters without tightly coupling the DTOs.Two minor considerations:
- If
Metadatacan 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 unusedThe simplified success path (
Done+ noError→SUCCESS,Progress= 100%) matches Google’s long‑running operation semantics and is straightforward.Using
GenerateVideoResponse.GeneratedSamples[0].Video.URIto populateRemoteUrlis also a good fit and, combined with the internal/v1/videos/{taskID}/contentURL, avoids persisting large base64 payloads in the task record, which is consistent with the redaction approach mentioned inredactVideoResponseBody. Based on learnings, this is aligned with not storing raw video bytes.One thing to confirm:
operationResponse.Response.Videos,BytesBase64Encoded, orVideoare now ignored. If any existing Gemini models inGetModelList()still return data only via those fields, you may lose access to the actual video content even though the task is markedSUCCESS. If that’s not intended, consider a fallback that derivesRemoteUrl(or equivalent) from those legacy fields.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 usingTaskActionTextGenerateis intentional for video tasks
ValidateRequestAndSetActionnow always usesTaskActionTextGeneratewhen callingValidateBasicTaskRequest. 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
textGenerateis indeed the desired action identifier for this adaptor.
…emini-veo3.1-i2v Revert "Gemini Veo3.1[AI Studio]增加图生视频支持"
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
Reverts #2315
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.