-
Notifications
You must be signed in to change notification settings - Fork 60.1k
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
Feature/azure #4925
Feature/azure #4925
Conversation
…into feature/azure
@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 improvements in the chat functionality by enhancing how models are handled, including the addition of Changes
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: 9
Outside diff range and nitpick comments (17)
app/api/azure/[...path]/route.ts (4)
24-24
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Azure Route] params ", params); + // Use a logging library here
100-100
: Consider using a constant for theauthHeaderName
.Define
authHeaderName
as a constant for better readability and maintainability.- const authHeaderName = "api-key"; + const AUTH_HEADER_NAME = "api-key";
124-125
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Proxy] ", path); - console.log("[Base Url]", baseUrl); + // Use a logging library here
197-197
: Remove redundant check.The check for
serverConfig.openaiOrgId
is redundant as it is already checked before logging.- if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") { + if (serverConfig.openaiOrgId) {app/client/platforms/baidu.ts (4)
62-62
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Proxy Endpoint] ", baseUrl, path); + // Use a logging library here
116-116
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Request] Baidu payload: ", requestPayload); + // Use a logging library here
144-144
: Typo in comment.Fix the typo in the comment: "animaion" should be "animation".
- // start animaion + // start animation
226-226
: Improve error logging.Provide more context in the error log for better debugging.
- console.error("[Request] parse error", text, msg); + console.error("[Request] parse error", { text, msg, error: e });app/client/platforms/azure.ts (4)
57-57
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Proxy Endpoint] ", baseUrl, path); + // Use a logging library here
97-97
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Request] azure payload: ", requestPayload); + // Use a logging library here
146-146
: Typo in comment.Fix the typo in the comment: "animaion" should be "animation".
- // start animaion + // start animation
226-226
: Improve error logging.Provide more context in the error log for better debugging.
- console.error("[Request] parse error", text, msg); + console.error("[Request] parse error", { text, msg, error: e });app/client/platforms/openai.ts (5)
60-60
: Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Proxy Endpoint] ", baseUrl, path); + // Use a logging library here
Line range hint
91-91
:
Remove console logs in production.Consider using a logging library instead of
console.log
for better logging practices.- console.log("[Request] openai payload: ", requestPayload); + // Use a logging library here
Line range hint
146-146
:
Typo in comment.Fix the typo in the comment: "animaion" should be "animation".
- // start animaion + // start animation
Line range hint
226-226
:
Improve error logging.Provide more context in the error log for better debugging.
- console.error("[Request] parse error", text, msg); + console.error("[Request] parse error", { text, msg, error: e });
Line range hint
196-196
:
Consider using a utility function for date formatting.Extract the date formatting logic into a utility function for better reusability.
- const formatDate = (d: Date) => - `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d - .getDate() - .toString() - .padStart(2, "0")}`; + import { formatDate } from "@/app/utils/date";
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (22)
- app/api/auth.ts (1 hunks)
- app/api/azure/[...path]/route.ts (1 hunks)
- app/api/baidu/[...path]/route.ts (1 hunks)
- app/api/common.ts (3 hunks)
- app/api/openai/[...path]/route.ts (1 hunks)
- app/client/api.ts (3 hunks)
- app/client/platforms/azure.ts (1 hunks)
- app/client/platforms/baidu.ts (1 hunks)
- app/client/platforms/openai.ts (4 hunks)
- app/components/chat.tsx (3 hunks)
- app/components/exporter.tsx (2 hunks)
- app/components/home.tsx (2 hunks)
- app/components/model-config.tsx (1 hunks)
- app/components/ui-lib.tsx (1 hunks)
- app/config/server.ts (2 hunks)
- app/constant.ts (9 hunks)
- app/store/access.ts (4 hunks)
- app/store/chat.ts (3 hunks)
- app/store/config.ts (2 hunks)
- app/utils/hooks.ts (2 hunks)
- app/utils/model.ts (1 hunks)
- public/masks.json (1 hunks)
Files not summarized due to errors (1)
- public/masks.json: Error: Message exceeds token limit
Files skipped from review due to trivial changes (1)
- app/utils/model.ts
Additional context used
Biome
app/api/auth.ts
[error] 70-70: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
Additional comments not posted (82)
app/utils/hooks.ts (1)
3-3
: Verify the usage of the new import.Ensure that
collectModelsWithDefaultModel
is correctly defined and used in the file. The functionality should be tested to confirm it works as expected.Verification successful
Verified the usage of the new import.
The function
collectModelsWithDefaultModel
is correctly defined inapp/utils/model.ts
and is used inapp/utils/hooks.ts
.
app/utils/model.ts
: Function definition found.app/utils/hooks.ts
: Correct usage of the imported function.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition and usage of `collectModelsWithDefaultModel`. # Test: Search for the function definition. Expect: The function should be defined in the model utility file. rg --type-add 'model:*.ts' --type model 'collectModelsWithDefaultModel'Length of output: 426
app/api/openai/[...path]/route.ts (1)
7-7
: Verify the usage of the new import.Ensure that
getModels
is correctly defined and used in the file. The functionality should be tested to confirm it works as expected.Verification successful
The
getModels
function is defined and used correctly.
app/api/common.ts
: The functiongetModels
is defined.app/api/openai/[...path]/route.ts
: The functiongetModels
is imported and used.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition and usage of `getModels`. # Test: Search for the function definition. Expect: The function should be defined in the common API file. rg --type-add 'common:*.ts' --type common 'getModels'Length of output: 466
app/store/access.ts (1)
45-48
: Verify the new Baidu API configurations.Ensure that the new Baidu API configurations are correctly added and used in the file. The functionality should be tested to confirm it works as expected.
Verification successful
Verification successful: Baidu API configurations correctly added and used
The new Baidu API configurations (
baiduUrl
,baiduApiKey
,baiduSecretKey
) are correctly integrated and used throughout the codebase. They are initialized, set from environment variables, and utilized appropriately in the relevant parts of the application.
app/store/access.ts
: Initializes and ensures retrieval of configurations.app/config/server.ts
: Sets configurations using environment variables.app/client/platforms/baidu.ts
: UsesbaiduUrl
.app/api/baidu/[...path]/route.ts
: UsesbaiduUrl
,baiduApiKey
, andbaiduSecretKey
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new Baidu API configurations. # Test: Search for the usage of the new configurations. Expect: The configurations should be used in the relevant parts of the codebase. rg --type-add 'config:*.ts' --type config 'baiduUrl|baiduApiKey|baiduSecretKey'Length of output: 809
Script:
#!/bin/bash # Description: Inspect the usage of the new Baidu API configurations in the identified files. # Check the usage in app/store/access.ts echo "=== app/store/access.ts ===" rg 'baiduUrl|baiduApiKey|baiduSecretKey' app/store/access.ts # Check the usage in app/config/server.ts echo "=== app/config/server.ts ===" rg 'baiduUrl|baiduApiKey|baiduSecretKey' app/config/server.ts # Check the usage in app/client/platforms/baidu.ts echo "=== app/client/platforms/baidu.ts ===" rg 'baiduUrl|baiduApiKey|baiduSecretKey' app/client/platforms/baidu.ts # Check the usage in app/api/baidu/[...path]/route.ts echo "=== app/api/baidu/[...path]/route.ts ===" rg 'baiduUrl|baiduApiKey|baiduSecretKey' app/api/baidu/[...path]/route.tsLength of output: 1041
app/store/config.ts (2)
8-8
: Import Added:ModelProvider
The import of
ModelProvider
is necessary for the new configuration property.
62-62
: Addition ofproviderName
tomodelConfig
.The addition of
providerName
to themodelConfig
object is correctly done. Ensure that this property is used appropriately throughout the application.app/config/server.ts (2)
95-95
: Addition ofisBaidu
flag.The
isBaidu
flag is correctly added to indicate the presence of Baidu API configurations.
128-132
: Addition of Baidu API configurations.The Baidu API configurations (
baiduUrl
,baiduApiKey
,baiduSecretKey
) are correctly added. Ensure these configurations are used appropriately throughout the application.app/api/common.ts (2)
3-3
: Import Added:OpenAIListModelResponse
The import of
OpenAIListModelResponse
is necessary for the newgetModels
function.
9-19
: New Function:getModels
.The
getModels
function is correctly added to filter out GPT-4 models if disabled in the config. Ensure this function is used appropriately throughout the application.app/api/baidu/[...path]/route.ts (9)
1-1
: Import Added:getServerSideConfig
The import of
getServerSideConfig
is necessary for the configuration.
2-7
: Imports Added: Constants and UtilitiesThe imports of Baidu-specific constants and utilities are necessary for the new route handlers.
13-13
: Configuration:getServerSideConfig
The
getServerSideConfig
function is correctly called to get the server-side configuration.
15-15
: Allowed Paths SetThe
ALLOWD_PATH
set is initialized but currently empty. Ensure to populate it with allowed paths if needed.
17-56
: New Function:handle
The
handle
function is correctly added to process GET and POST requests. Ensure this function is used appropriately and handles all necessary cases.
58-59
: Route Handlers: GET and POSTThe route handlers for GET and POST requests are correctly added to use the
handle
function.
61-80
: Configuration: Runtime and Preferred RegionsThe runtime is set to "edge" and preferred regions are specified. Ensure these configurations are appropriate for the deployment environment.
82-169
: New Function:request
The
request
function is correctly added to handle requests to the Baidu API. Ensure this function handles all necessary cases and integrates well with the rest of the application.
171-189
: New Function:getAccessToken
The
getAccessToken
function is correctly added to generate an access token using API keys and secrets. Ensure this function is secure and handles all necessary cases.app/components/home.tsx (3)
30-30
: Import statement looks good.The import of
getApiClient
appears necessary for the updated functionality.
173-174
: Initialization ofapi
looks good.The
api
constant is correctly initialized usinggetApiClient
withconfig.modelConfig.providerName
.
174-174
: Asynchronous model fetching looks good.The
useEffect
hook correctly fetches models usingapi.llm.models()
and merges them into the config.app/client/api.ts (4)
12-14
: Import statements look good.The additions of
ErnieApi
andAzureApi
imports are necessary for the updated functionality.
108-113
: ClientApi constructor updates look good.The constructor correctly initializes the
llm
property based on the model provider, includingErnie
andAzure
.
171-218
: Header construction updates look good.The
getHeaders
function correctly handles different providers and constructs the appropriate headers.
223-226
: New functiongetApiClient
looks good.The function correctly returns an instance of
ClientApi
based on the provider.app/constant.ts (6)
17-18
: New constantBAIDU_BASE_URL
looks good.The constant is correctly defined as
https://aip.baidubce.com
.
31-31
: ApiPath enum updates look good.The new paths for Azure and Baidu are correctly defined.
Also applies to: 33-34
78-78
: ServiceProvider and ModelProvider enum updates look good.The new providers Baidu and Azure are correctly added to the enums.
Also applies to: 85-87
105-105
: New constants for Azure and Baidu paths look good.The constants are correctly defined for Azure and Baidu paths.
Also applies to: 114-119
169-169
: New arraybaiduModels
looks good.The array is correctly defined with the model
completions_pro
.Also applies to: 189-190
201-209
: DEFAULT_MODELS array updates look good.The models for Azure and Baidu are correctly added to the array.
Also applies to: 228-236
app/components/model-config.tsx (3)
7-7
: Import statement looks good.The import of
ModelProvider
appears necessary for the updated functionality.
14-14
: Value and Select component updates look good.The changes correctly handle the provider name and update the config.
Also applies to: 19-19, 21-25
31-31
: Option elements update looks good.The changes correctly include the provider name in the
option
values.app/api/azure/[...path]/route.ts (1)
45-45
: Handle potential errors in theauth
function.Ensure that any potential errors in
auth
are properly handled.Verification successful
Handle potential errors in the
auth
function.The
auth
function inapp/api/auth.ts
already includes error handling. It checks for conditions such as missing or incorrect access codes and the use of unauthorized API keys, returning appropriate error messages.
- File:
app/api/auth.ts
- Relevant Lines:
- Line 42-46: Checks for missing or incorrect access codes.
- Line 49-53: Checks for unauthorized API keys.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `auth` function handles potential errors correctly. # Test: Search for the `auth` function implementation. Expect: Proper error handling. ast-grep --lang typescript --pattern $'function auth($_, $_) { $$$ if ($_.error) { return $_; } $$$ }'Length of output: 115
Script:
#!/bin/bash # Locate all instances of `auth` to find its definition. rg 'auth' --type typescript # Once we identify the file containing the `auth` function, we will search within that file for proper error handling.Length of output: 62
Script:
#!/bin/bash # Locate all instances of `auth` to find its definition. rg 'auth' --type ts # Once we identify the file containing the `auth` function, we will search within that file for proper error handling.Length of output: 9031
Script:
#!/bin/bash # Extract the implementation of the `auth` function from `app/api/auth.ts` ast-grep --lang typescript --pattern 'function auth($_, $_) { $$$ }' app/api/auth.tsLength of output: 3148
app/client/platforms/baidu.ts (2)
87-88
: LGTM!The
extractMessage
function looks good to me.
252-256
: LGTM!The
usage
function looks good to me.app/client/platforms/azure.ts (2)
62-63
: LGTM!The
extractMessage
function looks good to me.
196-196
: Consider using a utility function for date formatting.Extract the date formatting logic into a utility function for better reusability.
- const formatDate = (d: Date) => - `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d - .getDate() - .toString() - .padStart(2, "0")}`; + import { formatDate } from "@/app/utils/date";Likely invalid or redundant comment.
app/client/platforms/openai.ts (1)
Line range hint
72-73
:
LGTM!The
extractMessage
function looks good to me.app/components/exporter.tsx (2)
41-41
: LGTM! Ensure Proper Usage ofgetApiClient
The import statement looks good. Ensure that
getApiClient
is correctly used throughout the file.
315-315
: LGTM! Ensure Proper Usage ofgetApiClient
The usage of
getApiClient
looks good. Ensure that theconfig.modelConfig.providerName
is correctly set and handled.app/store/chat.ts (3)
25-30
: LGTM! Ensure Proper Usage ofgetApiClient
The import statement looks good. Ensure that
getApiClient
is correctly used throughout the file.
371-371
: LGTM! Ensure Proper Usage ofgetApiClient
The usage of
getApiClient
looks good. Ensure that themodelConfig.providerName
is correctly set and handled.
548-548
: LGTM! Ensure Proper Usage ofgetApiClient
The usage of
getApiClient
looks good. Ensure that themodelConfig.providerName
is correctly set and handled.app/components/chat.tsx (4)
88-88
: Import Addition ApprovedThe addition of the
ModelProvider
import is appropriate for the subsequent usage in the file.
452-454
: Variable Addition ApprovedThe addition of the
currentProviderName
variable is appropriate and helps in managing the provider name from the model configuration.
582-592
: Model and Provider Selection Enhancement ApprovedThe changes to display the model and provider name in the
Selector
component and update the session's mask configuration are correct. Ensure that the split operation correctly parses the model and provider name strings.
597-602
: Selection Logic Addition ApprovedThe
setSeleted
function correctly handles the selection logic to ensure the selected model and provider name match the current configuration. Verify the correctness of the comparison logic.public/masks.json (33)
1-1
: Ensure JSON structure is valid.The overall structure of the JSON file appears to be valid. Ensure it follows the JSON format correctly.
2-45
: Review new role "以文搜图" in Chinese section.The context and modelConfig for the new role "以文搜图" look well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
46-70
: Review new role "文案写手" in Chinese section.The context and modelConfig for the new role "文案写手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
71-95
: Review new role "机器学习" in Chinese section.The context and modelConfig for the new role "机器学习" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
96-120
: Review new role "后勤工作" in Chinese section.The context and modelConfig for the new role "后勤工作" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
121-145
: Review new role "职业顾问" in Chinese section.The context and modelConfig for the new role "职业顾问" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
146-170
: Review new role "英专写手" in Chinese section.The context and modelConfig for the new role "英专写手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
171-195
: Review new role "语言检测器" in Chinese section.The context and modelConfig for the new role "语言检测器" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
196-220
: Review new role "小红书写手" in Chinese section.The context and modelConfig for the new role "小红书写手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
221-251
: Review new role "简历写手" in Chinese section.The context and modelConfig for the new role "简历写手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
252-276
: Review new role "心理医生" in Chinese section.The context and modelConfig for the new role "心理医生" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
277-307
: Review new role "创业点子王" in Chinese section.The context and modelConfig for the new role "创业点子王" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
308-338
: Review new role "互联网写手" in Chinese section.The context and modelConfig for the new role "互联网写手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
339-379
: Review new role "心灵导师" in Chinese section.The context and modelConfig for the new role "心灵导师" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
380-424
: Review new role "越狱模式 [Jailbreak]" in Chinese section.The context and modelConfig for the new role "越狱模式 [Jailbreak]" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
426-469
: Review new role "以文搜圖" in Traditional Chinese section.The context and modelConfig for the new role "以文搜圖" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
470-494
: Review new role "文案寫手" in Traditional Chinese section.The context and modelConfig for the new role "文案寫手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
495-519
: Review new role "機器學習" in Traditional Chinese section.The context and modelConfig for the new role "機器學習" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
520-544
: Review new role "後勤工作" in Traditional Chinese section.The context and modelConfig for the new role "後勤工作" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
545-569
: Review new role "職業顧問" in Traditional Chinese section.The context and modelConfig for the new role "職業顧問" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
570-594
: Review new role "英專寫手" in Traditional Chinese section.The context and modelConfig for the new role "英專寫手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
595-619
: Review new role "語言檢測器" in Traditional Chinese section.The context and modelConfig for the new role "語言檢測器" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
620-644
: Review new role "小紅書寫手" in Traditional Chinese section.The context and modelConfig for the new role "小紅書寫手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
645-675
: Review new role "簡歷寫手" in Traditional Chinese section.The context and modelConfig for the new role "簡歷寫手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
676-700
: Review new role "心理醫生" in Traditional Chinese section.The context and modelConfig for the new role "心理醫生" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
701-731
: Review new role "創業點子王" in Traditional Chinese section.The context and modelConfig for the new role "創業點子王" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
732-762
: Review new role "網際網路寫手" in Traditional Chinese section.The context and modelConfig for the new role "網際網路寫手" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
763-803
: Review new role "心靈導師" in Traditional Chinese section.The context and modelConfig for the new role "心靈導師" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
804-848
: Review new role "越獄模式 [Jailbreak]" in Traditional Chinese section.The context and modelConfig for the new role "越獄模式 [Jailbreak]" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
850-875
: Review new role "GitHub Copilot" in English section.The context and modelConfig for the new role "GitHub Copilot" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
876-918
: Review new role "Prompt Improvement" in English section.The context and modelConfig for the new role "Prompt Improvement" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
919-943
: Review new role "CAN" in English section.The context and modelConfig for the new role "CAN" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
944-974
: Review new role "Expert" in English section.The context and modelConfig for the new role "Expert" are well-defined and appropriate for the intended role. Ensure the date field is populated correctly.
app/components/ui-lib.tsx
Outdated
setSeleted?: (value: T) => boolean; | ||
}) { | ||
return ( | ||
<div className={styles["selector"]} onClick={() => props.onClose?.()}> | ||
<div className={styles["selector-content"]}> | ||
<List> | ||
{props.items.map((item, i) => { | ||
const selected = props.defaultSelectedValue === item.value; | ||
const selected = props?.setSeleted | ||
? props?.setSeleted?.(item.value) | ||
: props.defaultSelectedValue === item.value; |
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.
Correct Typo in Prop Name
The prop name setSeleted
contains a typo. It should be setSelected
for consistency and readability.
- setSeleted?: (value: T) => boolean;
+ setSelected?: (value: T) => boolean;
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.
setSeleted?: (value: T) => boolean; | |
}) { | |
return ( | |
<div className={styles["selector"]} onClick={() => props.onClose?.()}> | |
<div className={styles["selector-content"]}> | |
<List> | |
{props.items.map((item, i) => { | |
const selected = props.defaultSelectedValue === item.value; | |
const selected = props?.setSeleted | |
? props?.setSeleted?.(item.value) | |
: props.defaultSelectedValue === item.value; | |
setSelected?: (value: T) => boolean; | |
}) { | |
return ( | |
<div className={styles["selector"]} onClick={() => props.onClose?.()}> | |
<div className={styles["selector-content"]}> | |
<List> | |
{props.items.map((item, i) => { | |
const selected = props?.setSeleted | |
? props?.setSeleted?.(item.value) | |
: props.defaultSelectedValue === item.value; |
async function handle( | ||
req: NextRequest, | ||
{ params }: { params: { path: string[] } }, |
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.
Consider adding input validation for params
.
Ensure that params
is properly validated to prevent potential security issues.
async function handle(
req: NextRequest,
{ params }: { params: { path: string[] } },
) {
+ if (!params || !Array.isArray(params.path)) {
+ return NextResponse.json(
+ { error: true, msg: "Invalid path parameters" },
+ { status: 400 }
+ );
+ }
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.
async function handle( | |
req: NextRequest, | |
{ params }: { params: { path: string[] } }, | |
async function handle( | |
req: NextRequest, | |
{ params }: { params: { path: string[] } }, | |
) { | |
if (!params || !Array.isArray(params.path)) { | |
return NextResponse.json( | |
{ error: true, msg: "Invalid path parameters" }, | |
{ status: 400 } | |
); | |
} |
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 (2)
- app/components/chat.tsx (3 hunks)
- app/components/ui-lib.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- app/components/chat.tsx
- app/components/ui-lib.tsx
app/api/azure/[...path]/route.ts
Outdated
const jsonBody = JSON.parse(clonedBody) as { model?: string }; | ||
|
||
// not undefined and is false | ||
if (modelTable[jsonBody?.model ?? ""].available === false) { |
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.
done
@@ -169,6 +186,8 @@ const anthropicModels = [ | |||
"claude-3-5-sonnet-20240620", | |||
]; | |||
|
|||
const baiduModels = ["completions_pro"]; |
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.
百度只有一个模型?
@@ -179,6 +198,15 @@ export const DEFAULT_MODELS = [ | |||
providerType: "openai", | |||
}, | |||
})), | |||
...openaiModels.map((name) => ({ | |||
name, | |||
available: true, |
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.
Azure的默认aviable设置为false,免得初始化的时候,出现一堆重复的模型。
或许加一个判断,配置的AZURE_URL的才默认给打开
public/masks.json
Outdated
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.
get
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 (1)
- app/api/azure/[...path]/route.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- app/api/azure/[...path]/route.ts
Summary by CodeRabbit
New Features
Improvements