-
Notifications
You must be signed in to change notification settings - Fork 60.6k
feat: qwen #4942
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
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
authhandle theModelProvider.Qwencase correctly.Verification successful
Function usage verified!
The
authfunction is correctly handling theModelProvider.Qwencase in theapp/api/alibaba/[...path]/route.tsfile.
app/api/alibaba/[...path]/route.ts:
- The
authfunction 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
isValidAlibabais 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.Qwenadded.The new case for
ModelProvider.Qwenis correctly implemented.
228-229: LGTM! Support forServiceProvider.Alibabaadded.The new case for
ServiceProvider.Alibabais correctly implemented.app/constant.ts (6)
17-18: LGTM! New constantALIBABA_BASE_URLadded.The new constant
ALIBABA_BASE_URLis correctly defined.
34-34: LGTM! New enum valueAlibabaadded toApiPath.The new enum value
Alibabais correctly defined.
78-78: LGTM! New enum valueAlibabaadded toServiceProvider.The new enum value
Alibabais correctly defined.
85-85: LGTM! New enum valueQwenadded toModelProvider.The new enum value
Qwenis correctly defined.
186-194: LGTM! New arrayalibabaModesadded.The new array
alibabaModesis correctly defined.
233-241: LGTM! Updates toDEFAULT_MODELSarray for Alibaba models added.The updates to the
DEFAULT_MODELSarray are correctly implemented.app/client/platforms/alibaba.ts (7)
26-33: LGTM! New interfaceOpenAIListModelResponseadded.The new interface
OpenAIListModelResponseis correctly defined.
35-47: LGTM! New interfaceRequestPayloadadded.The new interface
RequestPayloadis correctly defined.
49-76: LGTM! Newpathmethod inQwenApiclass added.The new
pathmethod is correctly implemented.
78-80: LGTM! NewextractMessagemethod inQwenApiclass added.The new
extractMessagemethod is correctly implemented.
82-248: LGTM! Newchatmethod inQwenApiclass added.The new
chatmethod is correctly implemented.
249-253: LGTM! Newusagemethod inQwenApiclass added.The new
usagemethod is correctly implemented.
256-258: LGTM! Newmodelsmethod inQwenApiclass added.The new
modelsmethod is correctly implemented.app/client/platforms/openai.ts (1)
45-45: LGTM!RequestPayloadinterface is now exported.The
RequestPayloadinterface 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.Qwenis 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
displayNameas aletand the logic to swapnameanddisplayNamefor 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
paramsparameter 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
requestfunction 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_KEYandBYTEDANCE_URLfor 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_MODELSsection 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
OpenAIListModelResponseinterface is well-defined and correctly structured.
35-47: LGTM!The
RequestPayloadinterface is well-defined and correctly structured.
50-74: LGTM!The
pathmethod is well-structured and correctly constructs the full URL.
76-78: LGTM!The
extractMessagemethod is well-structured and correctly extracts the message content from the response.
80-242: LGTM! But verify the animation logic.The
chatmethod is well-structured and correctly handles the chat interaction.However, ensure that the use of
requestAnimationFramefor animating response text is appropriate and performs as expected.
244-248: LGTM!The
usagemethod is well-structured and correctly returns the usage object.
251-253: LGTM!The
modelsmethod is well-structured and correctly returns an empty array of models.app/components/chat.tsx (3)
Line range hint
470-619: LGTM!The
ChatActionsfunction 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
_Chatfunction 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
Chatfunction 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.mdandREADME_CN.mdwith configuration options for Alibaba and ByteDance APIs.