diff --git a/app/api/azure/[...path]/route.ts b/app/api/azure/[...path]/route.ts index 26fcf9c1a..397c695ac 100644 --- a/app/api/azure/[...path]/route.ts +++ b/app/api/azure/[...path]/route.ts @@ -25,7 +25,7 @@ async function handle( } try { - return await requestOpenai(req, (await req.text()) as any); + return await requestOpenai(req); } catch (e) { console.error("[Azure] ", e); return res.json(prettyObject(e)); diff --git a/app/api/common.ts b/app/api/common.ts index ee8f7ecc1..44b5509cf 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -19,9 +19,9 @@ const serverConfig = getServerSideConfig(); export async function requestOpenai( req: NextRequest, - cloneBody: any, + // cloneBody: any, // isAzure: boolean, - current_model?: string, + // current_model?: string, ) { const controller = new AbortController(); @@ -120,7 +120,7 @@ export async function requestOpenai( }), }, method: req.method, - body: cloneBody, + body: req.body, // to fix #2485: https://stackoverflow.com/questions/55920957/cloudflare-worker-typeerror-one-time-use-body redirect: "manual", // @ts-ignore @@ -128,8 +128,8 @@ export async function requestOpenai( signal: controller.signal, }; - // #1815 try to refuse some model request - if (current_model) { + // #1815 try to refuse gpt4 request + if (serverConfig.customModels && req.body) { try { const clonedBody = await req.text(); fetchOptions.body = clonedBody; @@ -152,7 +152,7 @@ export async function requestOpenai( return NextResponse.json( { error: true, - message: `you are not allowed to use ${current_model} model`, + message: `you are not allowed to use ${jsonBody?.model} model`, }, { status: 403, @@ -160,7 +160,7 @@ export async function requestOpenai( ); } } catch (e) { - console.error("[OpenAI] gpt model filter", e); + console.error("[OpenAI] gpt4 filter", e); } } diff --git a/app/api/openai/[...path]/route.ts b/app/api/openai/[...path]/route.ts index bf279a818..5c7cb925d 100644 --- a/app/api/openai/[...path]/route.ts +++ b/app/api/openai/[...path]/route.ts @@ -87,9 +87,9 @@ async function handle( try { const response = await requestOpenai( req, - cloneBody, + // cloneBody, // isAzure, - jsonBody?.model ?? "", + // jsonBody?.model ?? "", ); // list models