From da9963d4eee9be855279d427ba3b751472bbea23 Mon Sep 17 00:00:00 2001 From: "Q.A.zh" <40236765+QAbot-zh@users.noreply.github.com> Date: Sun, 29 Dec 2024 09:10:37 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BB=85=E5=AF=B9chat=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=A8=A1=E5=9E=8B=E5=8F=AF=E7=94=A8=E6=80=A7?= =?UTF-8?q?=E6=A3=80=E9=AA=8C=EF=BC=8C=E9=81=BF=E5=85=8Dtts=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=97=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/common.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index dbbebe744..fe2f24a76 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -1,6 +1,6 @@ import { NextRequest, NextResponse } from "next/server"; import { getServerSideConfig } from "../config/server"; -import { OPENAI_BASE_URL, ServiceProvider } from "../constant"; +import { OPENAI_BASE_URL, ServiceProvider, OpenaiPath } from "../constant"; import { cloudflareAIGatewayUrl } from "../utils/cloudflare"; import { getModelProvider, isModelNotavailableInServer } from "../utils/model"; @@ -26,8 +26,8 @@ export async function requestOpenai(req: NextRequest) { authValue = req.headers.get("Authorization") ?? ""; authHeaderName = "Authorization"; } - let path = `${req.nextUrl.pathname}`.replaceAll("/api/openai/", ""); + let isChatRequest = path.includes(OpenaiPath.ChatPath); let baseUrl = (isAzure ? serverConfig.azureUrl : serverConfig.baseUrl) || OPENAI_BASE_URL; @@ -117,7 +117,7 @@ export async function requestOpenai(req: NextRequest) { const jsonBody = JSON.parse(clonedBody) as { model?: string }; // not undefined and is false - if ( + if ( isChatRequest && isModelNotavailableInServer( serverConfig.customModels, jsonBody?.model as string,