-
Notifications
You must be signed in to change notification settings - Fork 59.3k
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
feat: qwen #4942
feat: qwen #4942
Conversation
@Dogtiti is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe changes introduce new authentication and request proxying functions for Alibaba and ByteDance services, integrating them into existing APIs. This includes new class implementations for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Settings
participant Auth
participant AlibabaService
participant ByteDanceService
participant QwenApi as QwenApi
participant DoubaoApi as DoubaoApi
User->>Settings: Access Settings
Settings->>User: Display new provider options
User->>Settings: Select Alibaba/ByteDance provider
Settings->>Auth: Authenticate user request
Auth->>Settings: Return API key
Settings->>User: Save API key
User->>QwenApi: Make chat request
QwenApi->>AlibabaService: Forward request
AlibabaService-->>QwenApi: Return result
QwenApi->>User: Display result
User->>DoubaoApi: Make chat request
DoubaoApi->>ByteDanceService: Forward request
ByteDanceService-->>DoubaoApi: Return result
DoubaoApi->>User: Display result
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- app/api/alibaba/[...path]/route.ts (1 hunks)
- app/api/auth.ts (1 hunks)
- app/client/api.ts (3 hunks)
- app/client/platforms/alibaba.ts (1 hunks)
- app/client/platforms/openai.ts (1 hunks)
- app/config/server.ts (3 hunks)
- app/constant.ts (6 hunks)
- app/store/access.ts (3 hunks)
Additional context used
Biome
app/api/auth.ts
[error] 79-79: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
Additional comments not posted (21)
app/api/auth.ts (1)
Line range hint
1-78
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
auth
handle theModelProvider.Qwen
case correctly.Verification successful
Function usage verified!
The
auth
function is correctly handling theModelProvider.Qwen
case in theapp/api/alibaba/[...path]/route.ts
file.
app/api/alibaba/[...path]/route.ts
:
- The
auth
function is called withModelProvider.Qwen
, and the result is appropriately handled.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `auth` handle the `ModelProvider.Qwen` case correctly. # Test: Search for the function usage. Expect: Function calls handle the `ModelProvider.Qwen` case. rg --type js --type ts $'auth'Length of output: 8722
Script:
#!/bin/bash # Description: Verify the usage of the `auth` function in app/api/alibaba/[...path]/route.ts for handling ModelProvider.Qwen case # Extract lines where `auth` function is called in the relevant file rg 'auth\(.*ModelProvider\.Qwen' app/api/alibaba/[...path]/route.ts -C 5Length of output: 331
Tools
Biome
[error] 79-79: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
app/store/access.ts (2)
50-53
: LGTM!The new Alibaba-related configurations are consistent with the existing pattern.
90-92
: LGTM!The new method
isValidAlibaba
is consistent with the existing pattern.app/config/server.ts (2)
38-41
: LGTM!The new environment variables for Alibaba integration are consistent with the existing pattern.
Line range hint
99-135
:
LGTM!The new logic for Alibaba-specific checks and configurations is consistent with the existing pattern.
app/client/api.ts (2)
109-111
: LGTM! Support forModelProvider.Qwen
added.The new case for
ModelProvider.Qwen
is correctly implemented.
228-229
: LGTM! Support forServiceProvider.Alibaba
added.The new case for
ServiceProvider.Alibaba
is correctly implemented.app/constant.ts (6)
17-18
: LGTM! New constantALIBABA_BASE_URL
added.The new constant
ALIBABA_BASE_URL
is correctly defined.
34-34
: LGTM! New enum valueAlibaba
added toApiPath
.The new enum value
Alibaba
is correctly defined.
78-78
: LGTM! New enum valueAlibaba
added toServiceProvider
.The new enum value
Alibaba
is correctly defined.
85-85
: LGTM! New enum valueQwen
added toModelProvider
.The new enum value
Qwen
is correctly defined.
186-194
: LGTM! New arrayalibabaModes
added.The new array
alibabaModes
is correctly defined.
233-241
: LGTM! Updates toDEFAULT_MODELS
array for Alibaba models added.The updates to the
DEFAULT_MODELS
array are correctly implemented.app/client/platforms/alibaba.ts (7)
26-33
: LGTM! New interfaceOpenAIListModelResponse
added.The new interface
OpenAIListModelResponse
is correctly defined.
35-47
: LGTM! New interfaceRequestPayload
added.The new interface
RequestPayload
is correctly defined.
49-76
: LGTM! Newpath
method inQwenApi
class added.The new
path
method is correctly implemented.
78-80
: LGTM! NewextractMessage
method inQwenApi
class added.The new
extractMessage
method is correctly implemented.
82-248
: LGTM! Newchat
method inQwenApi
class added.The new
chat
method is correctly implemented.
249-253
: LGTM! Newusage
method inQwenApi
class added.The new
usage
method is correctly implemented.
256-258
: LGTM! Newmodels
method inQwenApi
class added.The new
models
method is correctly implemented.app/client/platforms/openai.ts (1)
45-45
: LGTM!RequestPayload
interface is now exported.The
RequestPayload
interface is correctly exported.
app/client/platforms/alibaba.ts
Outdated
} | ||
|
||
extractMessage(res: any) { | ||
return res.choices?.at(0)?.message?.content ?? ""; |
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.
结构应该有一些区别,这里需要再检查一下
app/client/platforms/alibaba.ts
Outdated
} | ||
|
||
async chat(options: ChatOptions) { | ||
const visionModel = isVisionModel(options.config.model); |
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.
这里不用检查
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- README.md (2 hunks)
- README_CN.md (2 hunks)
- app/api/alibaba/[...path]/route.ts (1 hunks)
- app/api/auth.ts (1 hunks)
- app/api/bytedance/[...path]/route.ts (1 hunks)
- app/client/api.ts (5 hunks)
- app/client/platforms/alibaba.ts (1 hunks)
- app/client/platforms/bytedance.ts (1 hunks)
- app/components/chat.tsx (4 hunks)
- app/config/server.ts (3 hunks)
- app/constant.ts (6 hunks)
- app/store/access.ts (3 hunks)
- app/utils/model.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- README.md
Files skipped from review as they are similar to previous changes (6)
- app/api/alibaba/[...path]/route.ts
- app/client/api.ts
- app/client/platforms/alibaba.ts
- app/config/server.ts
- app/constant.ts
- app/store/access.ts
Additional context used
Biome
app/api/auth.ts
[error] 85-85: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
Additional comments not posted (16)
app/api/auth.ts (1)
82-84
: Remove the redundant case clause.The case for
ModelProvider.Qwen
is redundant due to the default clause.- case ModelProvider.Qwen: - systemApiKey = serverConfig.alibabaApiKey; - break;Likely invalid or redundant comment.
app/utils/model.ts (1)
Line range hint
42-66
:
LGTM! Verify the logic for the provider "bytedance".The changes to initialize
displayName
as alet
and the logic to swapname
anddisplayName
for the provider "bytedance" look good.However, ensure that the logic for the provider "bytedance" is correct and consistent with the rest of the codebase.
app/api/bytedance/[...path]/route.ts (2)
15-39
: LGTM! Verify the handling of ByteDance requests.The changes to add the
params
parameter and handle ByteDance requests look good.However, ensure that the handling of ByteDance requests is correct and consistent with the rest of the codebase.
65-153
: LGTM! Verify the handling of HTTP requests and custom models.The changes to add the
request
function to handle HTTP requests and custom models look good.However, ensure that the handling of HTTP requests and custom models is correct and consistent with the rest of the codebase.
README_CN.md (2)
142-148
: LGTM! Verify the new configuration parameters for ByteDance APIs.The changes to add new configuration parameters
BYTEDANCE_API_KEY
andBYTEDANCE_URL
for ByteDance APIs look good.However, ensure that the new configuration parameters are correct and consistent with the rest of the documentation.
183-185
: LGTM! Verify the new configuration parameters for ByteDance models.The changes to add new configuration parameters for ByteDance models in the
CUSTOM_MODELS
section look good.However, ensure that the new configuration parameters are correct and consistent with the rest of the documentation.
app/client/platforms/bytedance.ts (7)
26-33
: LGTM!The
OpenAIListModelResponse
interface is well-defined and correctly structured.
35-47
: LGTM!The
RequestPayload
interface is well-defined and correctly structured.
50-74
: LGTM!The
path
method is well-structured and correctly constructs the full URL.
76-78
: LGTM!The
extractMessage
method is well-structured and correctly extracts the message content from the response.
80-242
: LGTM! But verify the animation logic.The
chat
method is well-structured and correctly handles the chat interaction.However, ensure that the use of
requestAnimationFrame
for animating response text is appropriate and performs as expected.
244-248
: LGTM!The
usage
method is well-structured and correctly returns the usage object.
251-253
: LGTM!The
models
method is well-structured and correctly returns an empty array of models.app/components/chat.tsx (3)
Line range hint
470-619
: LGTM!The
ChatActions
function is well-structured and correctly handles various chat actions. The changes for handling the current model name and updating the session's model configuration are appropriate.
Line range hint
1-1032
: LGTM! But verify the changes related to the current model name and session's model configuration.The
_Chat
function is well-structured and correctly handles rendering the chat interface, user input, and chat session management.However, ensure that the changes related to handling the current model name and updating the session's model configuration are appropriate and perform as expected.
Line range hint
1034-1037
: LGTM!The
Chat
function is well-structured and correctly renders the chat component based on the current session index.
app/components/settings.tsx
Outdated
<ListItem | ||
title={Locale.Settings.Access.Alibaba.Endpoint.Title} | ||
subTitle={ | ||
Locale.Settings.Access.Anthropic.Endpoint.SubTitle + |
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.
Alibaba
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- README.md (2 hunks)
- README_CN.md (2 hunks)
- app/components/settings.tsx (2 hunks)
- app/locales/cn.ts (1 hunks)
- app/locales/en.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- README.md
- README_CN.md
Additional comments not posted (7)
app/locales/cn.ts (2)
366-376
: Add localization keys for ByteDance API settings.The added localization keys for ByteDance API settings seem correct and consistent with the existing structure.
377-387
: Add localization keys for Alibaba API settings.The added localization keys for Alibaba API settings seem correct and consistent with the existing structure.
app/locales/en.ts (2)
353-363
: Add localization keys for ByteDance API settings.The added localization keys for ByteDance API settings seem correct and consistent with the existing structure.
364-374
: Add localization keys for Alibaba API settings.The added localization keys for Alibaba API settings seem correct and consistent with the existing structure.
app/components/settings.tsx (3)
57-58
: Add imports for ByteDance and Alibaba constants.The added imports for ByteDance and Alibaba constants are necessary for the new settings blocks.
1255-1298
: Add conditional rendering block for ByteDance settings.The conditional rendering block for ByteDance settings correctly integrates with the existing settings structure and provides the necessary functionality.
1300-1342
: Add conditional rendering block for Alibaba settings.The conditional rendering block for Alibaba settings correctly integrates with the existing settings structure and provides the necessary functionality.
Summary by CodeRabbit
New Features
Localization
Documentation
README.md
andREADME_CN.md
with configuration options for Alibaba and ByteDance APIs.