Repository navigation
feat: 添加 openrouter-enterprise 支持 - #1897
Conversation
WalkthroughAdds detection and parsing for OpenRouter enterprise-wrapped responses in the OpenAI relay handler, a new OpenRouter enterprise DTO, a channel settings flag Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Handler as OpenaiHandler
participant Upstream as OpenRouter API
Client->>Handler: Request (channel=OpenRouter)
Handler->>Upstream: Forward upstream request
Upstream-->>Handler: HTTP response (body)
alt Enterprise wrapper path
note over Handler #D6EAF8: Attempt enterprise unwrap
Handler->>Handler: Unmarshal into OpenRouterEnterpriseResponse
alt enterpriseResponse.Success == true
Handler->>Handler: Replace responseBody with enterpriseResponse.Data
Handler->>Handler: Unmarshal Data into simpleResponse
Handler-->>Client: Return parsed simpleResponse
else enterpriseResponse.Success == false
Handler->>Handler: Log error and return OpenAI error
Handler-->>Client: Error
end
else Non-enterprise / fallback
Handler->>Handler: Unmarshal directly into simpleResponse (existing flow)
Handler-->>Client: Return parsed simpleResponse
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit 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: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
relay/channel/openai/relay-openai.go(2 hunks)relay/channel/openrouter/dto.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
relay/channel/openai/relay-openai.go (3)
constant/channel.go (1)
ChannelTypeOpenRouter(24-24)relay/channel/openrouter/dto.go (1)
OpenRouterEnterpriseResponse(13-16)common/json.go (1)
Unmarshal(8-10)
…router-enterprise # Conflicts: # relay/channel/openai/relay-openai.go
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
dto/channel_settings.go(1 hunks)relay/channel/api_request.go(1 hunks)relay/channel/openai/relay-openai.go(2 hunks)web/src/components/table/channels/modals/EditChannelModal.jsx(7 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.
Applied to files:
web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (3)
relay/channel/api_request.go (1)
logger/logger.go (1)
LogError(63-65)
relay/channel/openai/relay-openai.go (6)
constant/channel.go (1)
ChannelTypeOpenRouter(24-24)dto/channel_settings.go (1)
ChannelOtherSettings(19-23)relay/channel/openrouter/dto.go (1)
OpenRouterEnterpriseResponse(13-16)common/json.go (1)
Unmarshal(8-10)types/error.go (2)
NewOpenAIError(215-238)ErrorCodeBadResponseBody(68-68)logger/logger.go (1)
LogError(63-65)
web/src/components/table/channels/modals/EditChannelModal.jsx (1)
web/src/components/table/channels/modals/EditTagModal.jsx (2)
inputs(73-73)handleInputChange(77-129)
…prise feat: 添加 openrouter-enterprise 支持
…iate-rebate feat: 新增邀请返利功能,并支持后台配置返利比例
…prise feat: 添加 openrouter-enterprise 支持
…prise feat: 添加 openrouter-enterprise 支持
response:
Summary by CodeRabbit
New Features
Bug Fixes
Chores