Skip to content

feat: add StreamLake adaptor and related constants - #2574

Closed
zhaolion wants to merge 1 commit into
QuantumNous:mainfrom
CherryInternal:main
Closed

feat: add StreamLake adaptor and related constants#2574
zhaolion wants to merge 1 commit into
QuantumNous:mainfrom
CherryInternal:main

Conversation

@zhaolion

@zhaolion zhaolion commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Feature

增加一个新平台(StreamLake) 转发支持,官网在 https://www.streamlake.com/

Summary by CodeRabbit

  • New Features
    • Added StreamLake as a new channel option (appears in channel selector) with three available models: KAT-Coder-Exp-72B-1010, KAT-Coder-Pro-V1, KAT-Coder-Air-V1.
    • UI updated to show StreamLake with a distinct color label for easy identification.

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

Copilot AI review requested due to automatic review settings January 4, 2026 09:35
@coderabbitai

coderabbitai Bot commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Adds 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

Cohort / File(s) Summary
Backend Channel Constants
constant/channel.go
Added ChannelTypeStreamLake = 57 and corresponding entry in ChannelBaseURLs: "https://wanqing.streamlakeapi.com/api/gateway/v1/endpoints". ChannelTypeNames not updated here.
StreamLake Relay Channel
relay/channel/streamlake/adaptor.go, relay/channel/streamlake/constants.go
New Adaptor type with methods for Init, URL construction, header setup, request conversions (Gemini, Claude, OpenAI, audio, image, rerank, embedding), DoRequest (delegates to shared DoApiRequest), and DoResponse (delegates to OpenAI adaptor wrapper). Added ModelList and ChannelName = "StreamLake".
Frontend UI Constants
web/src/constants/channel.constants.js
Inserted new CHANNEL_OPTIONS entry: { value: 57, color: 'blue', label: 'StreamLake' }.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • seefs001

Poem

🐰 A lake of streams, code hopping light,
Channel fifty-seven joins the night,
Adaptor hums and endpoints gleam,
Models dance within the stream,
Blue on the UI — what a 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: adding StreamLake adaptor and related constants across backend and frontend files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4af192 and 0a21a7b.

📒 Files selected for processing (4)
  • constant/channel.go
  • relay/channel/streamlake/adaptor.go
  • relay/channel/streamlake/constants.go
  • web/src/constants/channel.constants.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • constant/channel.go
  • web/src/constants/channel.constants.js
🧰 Additional context used
🧠 Learnings (2)
📚 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
📚 Learning: 2025-11-07T17:46:11.086Z
Learnt from: Sh1n3zZ
Repo: QuantumNous/new-api PR: 2190
File: relay/channel/replicate/adaptor.go:207-209
Timestamp: 2025-11-07T17:46:11.086Z
Learning: In relay/channel/replicate/adaptor.go, the code uses Replicate's synchronous endpoint with the `Prefer: wait` header. With this header, the endpoint waits until the prediction completes and only returns when status is "succeeded" or a terminal failure state. It never returns with "starting" or "processing" statuses, so checking for only "succeeded" status is the correct implementation.

Applied to files:

  • relay/channel/streamlake/adaptor.go
🧬 Code graph analysis (1)
relay/channel/streamlake/adaptor.go (3)
constant/channel.go (2)
  • ChannelBaseURLs (62-121)
  • ChannelTypeStreamLake (57-57)
relay/common/relay_utils.go (1)
  • GetFullRequestURL (25-37)
relay/channel/api_request.go (1)
  • SetupApiRequestHeader (27-39)
🔇 Additional comments (6)
relay/channel/streamlake/constants.go (1)

1-9: LGTM! Clean constant definitions.

The model list and channel name constants are well-defined and follow Go conventions. The exported variables are appropriately accessible to the adaptor implementation.

relay/channel/streamlake/adaptor.go (5)

1-21: LGTM! Proper imports and struct definition.

The package imports are appropriate and include the OpenAI adaptor for response delegation. The empty Adaptor struct is a standard pattern for stateless interface implementations.


23-44: Appropriate placeholders for non-OpenAI formats.

The unimplemented conversion methods return clear error messages. Since StreamLake follows the OpenAI chat format (as noted in PR comments), these methods may remain unimplemented. The empty Init method is acceptable if no initialization is required.


46-59: Correct URL construction with appropriate path normalization.

The URL construction logic properly strips the /v1 prefix from the request path (line 57) to prevent duplication, since the base URL already contains /v1/endpoints. The error message fix from the previous review has been applied correctly.


61-92: Clean OpenAI-compatible implementation.

The adaptor correctly implements an OpenAI pass-through pattern:

  • Request conversion methods return requests as-is (lines 68, 81, 85), confirming StreamLake accepts OpenAI format
  • Response handling delegates to the OpenAI adaptor (line 90), ensuring consistent response processing
  • Authorization header setup follows the standard Bearer token pattern (line 63)

This implementation appropriately treats StreamLake as an OpenAI-compatible endpoint, which aligns with the PR comment noting it follows "pure OpenAI chat format."


94-100: LGTM! Proper accessor methods.

The GetModelList and GetChannelName methods correctly return the package-level constants, providing the necessary metadata for the channel registration.


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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread relay/channel/streamlake/adaptor.go Outdated

func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
if info == nil {
return "", errors.New("replicate adaptor: relay info is nil")

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return "", errors.New("replicate adaptor: relay info is nil")
return "", errors.New("streamlake adaptor: relay info is nil")

Copilot uses AI. Check for mistakes.
Comment on lines +188 to +190
value: 57,
color: 'blue',
label: 'StreamLake',

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
value: 57,
color: 'blue',
label: 'StreamLake',
value: 57,
color: 'blue',
label: 'StreamLake',

Copilot uses AI. Check for mistakes.

@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: 2

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 443b058 and f4af192.

📒 Files selected for processing (4)
  • constant/channel.go
  • relay/channel/streamlake/adaptor.go
  • relay/channel/streamlake/constants.go
  • web/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 ChannelTypeStreamLake constant.

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.Adaptor in DoResponse), these methods correctly return "not implemented" or "not supported" errors.


43-44: LGTM!

The empty Init implementation 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.DoApiRequest follows 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.

Comment thread constant/channel.go
ChannelTypeDoubaoVideo = 54
ChannelTypeSora = 55
ChannelTypeReplicate = 56
ChannelTypeStreamLake = 57

@coderabbitai coderabbitai Bot Jan 4, 2026

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.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChannelTypeNames 这个里面还没加呢

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.

@seefs001 是的,您说得对!ChannelTypeNames 映射中确实还缺少 ChannelTypeStreamLake 的条目。

请在 ChannelTypeNames 映射中添加以下条目(大约在第176行之后):

ChannelTypeStreamLake:     "StreamLake",

这样 GetChannelTypeName(constant.ChannelTypeStreamLake) 就会返回 "StreamLake" 而不是 "Unknown" 了。

Comment thread relay/channel/streamlake/adaptor.go
@RedwindA

RedwindA commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

为什么不直接使用自定义渠道,看起来这就是个纯openai chat格式的,用自定义渠道还能获得gemini/claude适配

@Calcium-Ion Calcium-Ion closed this Jan 4, 2026
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.

5 participants