feat: add StreamLake adaptor and related constants - #2574
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds StreamLake channel type (57): backend constants and base URL, a new relay adaptor with request/response conversion and HTTP delegation, model and channel-name constants, and a frontend UI option entry. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant RelayAdaptor as StreamLake Adaptor
participant DoApi as DoApiRequest (shared)
participant StreamLakeAPI as StreamLake External API
rect rgb(240,248,255)
Note over Client,RelayAdaptor: Request conversion & header setup
Client->>RelayAdaptor: Incoming request (OpenAI/Gemini/others)
RelayAdaptor->>RelayAdaptor: Convert*Request(), GetRequestURL(), SetupRequestHeader()
end
rect rgb(245,255,240)
Note over RelayAdaptor,DoApi: HTTP delegation
RelayAdaptor->>DoApi: DoRequest(payload, headers)
DoApi->>StreamLakeAPI: HTTP call to StreamLake endpoint
StreamLakeAPI-->>DoApi: HTTP response
DoApi-->>RelayAdaptor: HTTP response
end
rect rgb(255,250,240)
Note over RelayAdaptor,Client: Response conversion & return
RelayAdaptor->>RelayAdaptor: DoResponse() -> Convert backend response to Relay format
RelayAdaptor-->>Client: Converted response
end
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
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2025-08-08T17:12:43.157ZApplied to files:
📚 Learning: 2025-11-07T17:46:11.086ZApplied to files:
🧬 Code graph analysis (1)relay/channel/streamlake/adaptor.go (3)
🔇 Additional comments (6)
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.
Pull request overview
This PR adds support for StreamLake as a new platform adapter, enabling the relay service to forward requests to StreamLake's API at https://www.streamlake.com/.
Key Changes:
- Added StreamLake channel type constant (57) with base URL configuration
- Created StreamLake adapter implementing OpenAI-compatible API interface
- Added frontend UI option for StreamLake channel selection
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
constant/channel.go |
Added ChannelTypeStreamLake constant (57) and its base URL endpoint to ChannelBaseURLs array |
web/src/constants/channel.constants.js |
Added StreamLake option (value 57) to the channel selection dropdown |
relay/channel/streamlake/constants.go |
Defined StreamLake-specific model list (KAT-Coder variants) and channel name |
relay/channel/streamlake/adaptor.go |
Implemented StreamLake adapter with OpenAI-compatible request/response handling and authorization setup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { | ||
| if info == nil { | ||
| return "", errors.New("replicate adaptor: relay info is nil") |
There was a problem hiding this comment.
The error message incorrectly says "replicate adaptor" but this is the StreamLake adaptor. The error message should be updated to say "streamlake adaptor" to accurately reflect the current adapter being implemented.
| return "", errors.New("replicate adaptor: relay info is nil") | |
| return "", errors.New("streamlake adaptor: relay info is nil") |
| value: 57, | ||
| color: 'blue', | ||
| label: 'StreamLake', |
There was a problem hiding this comment.
The indentation is inconsistent with the surrounding code. The array items should use 2 spaces for indentation, but this entry uses 4 spaces. This breaks the consistent formatting pattern used throughout the file.
| value: 57, | |
| color: 'blue', | |
| label: 'StreamLake', | |
| value: 57, | |
| color: 'blue', | |
| label: 'StreamLake', |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
constant/channel.gorelay/channel/streamlake/adaptor.gorelay/channel/streamlake/constants.goweb/src/constants/channel.constants.js
🧰 Additional context used
🧠 Learnings (1)
📚 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/streamlake/adaptor.go
🧬 Code graph analysis (1)
relay/channel/streamlake/adaptor.go (3)
relay/common/relay_info.go (1)
RelayInfo(82-130)constant/channel.go (2)
ChannelBaseURLs(62-121)ChannelTypeStreamLake(57-57)relay/common/relay_utils.go (1)
GetFullRequestURL(25-37)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Agent
- GitHub Check: CodeQL analysis (go)
🔇 Additional comments (10)
web/src/constants/channel.constants.js (1)
187-191: LGTM!The StreamLake channel option is correctly added with value 57, matching the backend constant
ChannelTypeStreamLake.constant/channel.go (2)
57-57: LGTM!The constant definition is correct and follows the established pattern. The value 57 matches the frontend configuration.
120-120: LGTM!The base URL is correctly added at index 57, corresponding to the new
ChannelTypeStreamLakeconstant.relay/channel/streamlake/constants.go (1)
3-9: LGTM!The constant definitions are clear and properly structured. The model list defines StreamLake-specific models, and the channel name is correctly set.
relay/channel/streamlake/adaptor.go (6)
23-41: LGTM!The stub implementations for Gemini, Claude, Audio, and Image request conversions are appropriate. Since StreamLake appears to be OpenAI-compatible (given the delegation to
openai.AdaptorinDoResponse), these methods correctly return "not implemented" or "not supported" errors.
43-44: LGTM!The empty
Initimplementation is acceptable if no initialization is required for StreamLake.
61-65: LGTM!The header setup correctly uses the standard helper and properly formats the Authorization header with the Bearer token.
67-78: LGTM!The OpenAI request handling correctly passes through requests unchanged, confirming that StreamLake uses OpenAI-compatible format. The delegation to
channel.DoApiRequestfollows the standard adaptor pattern.
80-92: LGTM!The rerank and embedding request conversions correctly pass through unchanged, and the response handling properly delegates to the OpenAI adaptor. This confirms StreamLake's OpenAI-compatible API design.
94-100: LGTM!The getter methods correctly return the constants defined in
constants.go, providing the model list and channel name to the relay framework.
| ChannelTypeDoubaoVideo = 54 | ||
| ChannelTypeSora = 55 | ||
| ChannelTypeReplicate = 56 | ||
| ChannelTypeStreamLake = 57 |
There was a problem hiding this comment.
Add missing entry to ChannelTypeNames map.
The ChannelTypeNames map (lines 123-177) is missing an entry for ChannelTypeStreamLake. This causes GetChannelTypeName(constant.ChannelTypeStreamLake) to return "Unknown" instead of the proper channel name.
🔎 Proposed fix
Add the following entry to the ChannelTypeNames map after line 176:
ChannelTypeSora: "Sora",
ChannelTypeReplicate: "Replicate",
+ ChannelTypeStreamLake: "StreamLake",
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ChannelTypeStreamLake = 57 | |
| ChannelTypeSora: "Sora", | |
| ChannelTypeReplicate: "Replicate", | |
| ChannelTypeStreamLake: "StreamLake", | |
| } |
🤖 Prompt for AI Agents
In constant/channel.go around line 57 (ChannelTypeStreamLake) and the
ChannelTypeNames map at lines ~123-177, the map lacks an entry for
ChannelTypeStreamLake causing GetChannelTypeName(constant.ChannelTypeStreamLake)
to return "Unknown"; add a map entry mapping constant.ChannelTypeStreamLake to
the proper name (e.g., "StreamLake") inside the ChannelTypeNames map (place it
after the existing entries, around line 176) so the lookup returns the correct
channel name.
There was a problem hiding this comment.
ChannelTypeNames 这个里面还没加呢
There was a problem hiding this comment.
@seefs001 是的,您说得对!ChannelTypeNames 映射中确实还缺少 ChannelTypeStreamLake 的条目。
请在 ChannelTypeNames 映射中添加以下条目(大约在第176行之后):
ChannelTypeStreamLake: "StreamLake",这样 GetChannelTypeName(constant.ChannelTypeStreamLake) 就会返回 "StreamLake" 而不是 "Unknown" 了。
|
为什么不直接使用自定义渠道,看起来这就是个纯openai chat格式的,用自定义渠道还能获得gemini/claude适配 |
Feature
增加一个新平台(StreamLake) 转发支持,官网在 https://www.streamlake.com/
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.