From 147fc9a35a39187babb2b5aae156d47949547423 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Tue, 9 Jul 2024 15:10:23 +0800 Subject: [PATCH] fix ts type error --- app/api/baidu/[...path]/route.ts | 4 ++-- app/api/common.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/api/baidu/[...path]/route.ts b/app/api/baidu/[...path]/route.ts index 5444ba4fe..94c9963c7 100644 --- a/app/api/baidu/[...path]/route.ts +++ b/app/api/baidu/[...path]/route.ts @@ -102,8 +102,8 @@ async function request(req: NextRequest) { ); const { access_token } = await getAccessToken( - serverConfig.baiduApiKey, - serverConfig.baiduSecretKey, + serverConfig.baiduApiKey as string, + serverConfig.baiduSecretKey as string, ); const fetchUrl = `${baseUrl}${path}?access_token=${access_token}`; diff --git a/app/api/common.ts b/app/api/common.ts index 5223646d2..1ffac7fce 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -70,7 +70,7 @@ export async function requestOpenai(req: NextRequest) { // Forward compatibility: // if display_name(deployment_name) not set, and '{deploy-id}' in AZURE_URL // then using default '{deploy-id}' - if (serverConfig.customModels) { + if (serverConfig.customModels && serverConfig.azureUrl) { const modelName = path.split("/")[1]; let realDeployName = ""; serverConfig.customModels @@ -80,7 +80,9 @@ export async function requestOpenai(req: NextRequest) { const [fullName, displayName] = m.split("="); const [_, providerName] = fullName.split("@"); if (providerName === "azure" && !displayName) { - const [_, deployId] = serverConfig.azureUrl.split("deployments/"); + const [_, deployId] = (serverConfig?.azureUrl ?? "").split( + "deployments/", + ); if (deployId) { realDeployName = deployId; }