Skip to content

Commit

Permalink
仅对chat模型进行模型可用性检验,避免tts功能受影响
Browse files Browse the repository at this point in the history
  • Loading branch information
QAbot-zh authored Dec 29, 2024
1 parent 24ff78e commit da9963d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/api/common.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit da9963d

Please sign in to comment.