-
Notifications
You must be signed in to change notification settings - Fork 11.2k
feat: add StreamLake adaptor and related constants #2574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package streamlake | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "strings" | ||
|
|
||
| "github.com/QuantumNous/new-api/constant" | ||
| "github.com/QuantumNous/new-api/dto" | ||
| "github.com/QuantumNous/new-api/relay/channel" | ||
| "github.com/QuantumNous/new-api/relay/channel/openai" | ||
| relaycommon "github.com/QuantumNous/new-api/relay/common" | ||
| "github.com/QuantumNous/new-api/types" | ||
|
|
||
| "github.com/gin-gonic/gin" | ||
| ) | ||
|
|
||
| type Adaptor struct { | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dto.GeminiChatRequest) (any, error) { | ||
| //TODO implement me | ||
| return nil, errors.New("not implemented") | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) { | ||
| //TODO implement me | ||
| return nil, errors.New("not implemented") | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error) { | ||
| //TODO implement me | ||
| return nil, errors.New("not supported") | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error) { | ||
| //TODO implement me | ||
| return nil, errors.New("not implemented") | ||
| } | ||
|
|
||
| func (a *Adaptor) Init(info *relaycommon.RelayInfo) { | ||
| } | ||
|
|
||
| func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { | ||
| if info == nil { | ||
| return "", errors.New("streamlake adaptor: relay info is nil") | ||
| } | ||
| if info.ChannelBaseUrl == "" { | ||
| info.ChannelBaseUrl = constant.ChannelBaseURLs[constant.ChannelTypeStreamLake] | ||
| } | ||
| requestPath := info.RequestURLPath | ||
| if requestPath == "" { | ||
| return info.ChannelBaseUrl, nil | ||
| } | ||
| requestPath = strings.TrimPrefix(requestPath, "/v1") | ||
| return relaycommon.GetFullRequestURL(info.ChannelBaseUrl, requestPath, info.ChannelType), nil | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error { | ||
| channel.SetupApiRequestHeader(info, c, req) | ||
| req.Set("Authorization", fmt.Sprintf("Bearer %s", info.ApiKey)) | ||
| return nil | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error) { | ||
| return request, nil | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.OpenAIResponsesRequest) (any, error) { | ||
| // TODO implement me | ||
| return nil, errors.New("not implemented") | ||
| } | ||
|
|
||
| func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error) { | ||
| return channel.DoApiRequest(a, c, info, requestBody) | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error) { | ||
| return request, nil | ||
| } | ||
|
|
||
| func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error) { | ||
| return request, nil | ||
| } | ||
|
|
||
| func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError) { | ||
| adaptor := openai.Adaptor{} | ||
| usage, err = adaptor.DoResponse(c, resp, info) | ||
| return | ||
| } | ||
|
|
||
| func (a *Adaptor) GetModelList() []string { | ||
| return ModelList | ||
| } | ||
|
|
||
| func (a *Adaptor) GetChannelName() string { | ||
| return ChannelName | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package streamlake | ||
|
|
||
| var ModelList = []string{ | ||
| "KAT-Coder-Exp-72B-1010", | ||
| "KAT-Coder-Pro-V1", | ||
| "KAT-Coder-Air-V1", | ||
| } | ||
|
|
||
| var ChannelName = "StreamLake" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -184,6 +184,11 @@ export const CHANNEL_OPTIONS = [ | |||||||||||||
| color: 'blue', | ||||||||||||||
| label: 'Replicate', | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| value: 57, | ||||||||||||||
| color: 'blue', | ||||||||||||||
| label: 'StreamLake', | ||||||||||||||
|
Comment on lines
+188
to
+190
|
||||||||||||||
| value: 57, | |
| color: 'blue', | |
| label: 'StreamLake', | |
| value: 57, | |
| color: 'blue', | |
| label: 'StreamLake', |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing entry to ChannelTypeNames map.
The
ChannelTypeNamesmap (lines 123-177) is missing an entry forChannelTypeStreamLake. This causesGetChannelTypeName(constant.ChannelTypeStreamLake)to return "Unknown" instead of the proper channel name.🔎 Proposed fix
Add the following entry to the
ChannelTypeNamesmap after line 176:ChannelTypeSora: "Sora", ChannelTypeReplicate: "Replicate", + ChannelTypeStreamLake: "StreamLake", }📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChannelTypeNames 这个里面还没加呢
There was a problem hiding this comment.
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行之后):这样
GetChannelTypeName(constant.ChannelTypeStreamLake)就会返回 "StreamLake" 而不是 "Unknown" 了。