Browse Source

hotfix ts

lloydzhou 1 year ago
parent
commit
97aa72ec5b
3 changed files with 9 additions and 9 deletions
  1. 2 2
      app/api/anthropic/[...path]/route.ts
  2. 4 4
      app/api/common.ts
  3. 3 3
      app/utils/model.ts

+ 2 - 2
app/api/anthropic/[...path]/route.ts

@@ -146,8 +146,8 @@ async function request(req: NextRequest) {
       if (
         isModelAvailableInServer(
           serverConfig.customModels,
-          jsonBody?.model,
-          ServiceProvider.Anthropic,
+          jsonBody?.model as string,
+          ServiceProvider.Anthropic as string,
         )
       ) {
         return NextResponse.json(

+ 4 - 4
app/api/common.ts

@@ -97,13 +97,13 @@ export async function requestOpenai(req: NextRequest) {
       if (
         isModelAvailableInServer(
           serverConfig.customModels,
-          jsonBody?.model,
-          ServiceProvider.OpenAI,
+          jsonBody?.model as string,
+          ServiceProvider.OpenAI as string,
         ) ||
         isModelAvailableInServer(
           serverConfig.customModels,
-          jsonBody?.model,
-          ServiceProvider.Azure,
+          jsonBody?.model as string,
+          ServiceProvider.Azure as string,
         )
       ) {
         return NextResponse.json(

+ 3 - 3
app/utils/model.ts

@@ -119,9 +119,9 @@ export function collectModelsWithDefaultModel(
 }
 
 export function isModelAvailableInServer(
-  customModels,
-  modelName,
-  providerName,
+  customModels: string,
+  modelName: string,
+  providerName: string,
 ) {
   const fullName = `${modelName}@${providerName}`;
   const modelTable = collectModelTable(DEFAULT_MODELS, customModels);