Repository navigation
Conversation
WalkthroughRemoved four test-related dependencies from Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant VertexAdaptor as Vertex\nAdaptor (ConvertClaudeRequest)
participant OpenAIAdaptor as OpenAI\nAdaptor
participant OpenAIFlow as ConvertOpenAIRequest
Client->>VertexAdaptor: Send Claude-origin request (info + request)
alt RequestMode == RequestModeClaude
VertexAdaptor->>VertexAdaptor: select model via claudeModelMap\ncopyRequest(...) -> vertexClaudeReq
VertexAdaptor-->>Client: return vertexClaudeReq (vertex/Claude path)
else Other modes / non-Claude-origin
VertexAdaptor->>OpenAIAdaptor: ConvertClaudeRequest(generalize)
OpenAIAdaptor-->>VertexAdaptor: *dto.GeneralOpenAIRequest
VertexAdaptor->>OpenAIFlow: ConvertOpenAIRequest(general request)
OpenAIFlow-->>Client: final OpenAI-handled request/response
end
Note over VertexAdaptor,OpenAIAdaptor: Errors on adaptor creation or type-assertion are returned
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
go.modrelay/channel/vertex/adaptor.go
💤 Files with no reviewable changes (1)
- go.mod
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-05T17:14:17.246Z
Learnt from: neotf
Repo: QuantumNous/new-api PR: 1511
File: setting/ratio_setting/model_ratio.go:118-123
Timestamp: 2025-08-05T17:14:17.246Z
Learning: Claude models handle "-thinking" variants differently from Gemini models. For Claude models, only the base model (without "-thinking") gets an entry in defaultModelRatio map. The "-thinking" variants rely on the Claude relay handler stripping the suffix using strings.TrimSuffix(textRequest.Model, "-thinking") before looking up the ratio, so they automatically use the base model's ratio.
Applied to files:
relay/channel/vertex/adaptor.go
🔇 Additional comments (1)
relay/channel/vertex/adaptor.go (1)
93-108: LGTM! Multi-mode request routing via Claude endpoint is correctly implemented.The branching logic properly handles non-Claude model routing: when
RequestModeis not Claude, the code delegates to the OpenAI adaptor'sConvertClaudeRequestmethod and chains the result throughConvertOpenAIRequest, enabling Vertex Gemini and other models to use the/v1/messagesendpoint.The type assertion on line 108 is safe—
openai.Adaptor.ConvertClaudeRequestreturns the result ofservice.ClaudeToOpenAIRequest, which always produces a*dto.GeneralOpenAIRequest, and this type is preserved through the return chain.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/vertex/adaptor.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-05T17:14:17.246Z
Learnt from: neotf
Repo: QuantumNous/new-api PR: 1511
File: setting/ratio_setting/model_ratio.go:118-123
Timestamp: 2025-08-05T17:14:17.246Z
Learning: Claude models handle "-thinking" variants differently from Gemini models. For Claude models, only the base model (without "-thinking") gets an entry in defaultModelRatio map. The "-thinking" variants rely on the Claude relay handler stripping the suffix using strings.TrimSuffix(textRequest.Model, "-thinking") before looking up the ratio, so they automatically use the base model's ratio.
Applied to files:
relay/channel/vertex/adaptor.go
🧬 Code graph analysis (1)
relay/channel/vertex/adaptor.go (4)
relay/channel/openai/adaptor.go (1)
Adaptor(36-39)relay/channel/adapter.go (1)
Adaptor(15-32)relay/channel/claude/adaptor.go (1)
Adaptor(24-26)dto/openai_request.go (1)
GeneralOpenAIRequest(28-102)
🔇 Additional comments (1)
relay/channel/vertex/adaptor.go (1)
93-101: LGTM! Claude mode routing is correct.The short-circuit for Claude mode correctly maps the model, sets the context, and returns the Vertex-compatible Claude request. This aligns with the PR objective to handle Claude targets locally.
|
草你改代码怎么还删依赖的 |
估计本地运行时候执行了下 go mod tidy 自动修改了,我还原下 |
|
响应还是有问题 |
修复: 以下错误
a.RequestMode(在Init方法中根据模型前缀确定)来区分当前请求的目标模型类型。gemini-1.5-pro但通过/v1/messages接口调用)。openai.Adaptor的转换能力,将ClaudeRequest转换为GeneralOpenAIRequest。a.ConvertOpenAIRequest。由于ConvertOpenAIRequest内部已经实现了将 OpenAI 格式转换为 Vertex Gemini/Llama 格式的逻辑,这样就完成了链路打通。/v1/messages接口来调用 Vertex 上的图片生成模型(imagen),因为它也会通过 OpenAI 格式中转并触发ConvertImageRequest。Summary by CodeRabbit
Chores
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.