|
|
@ -42,15 +42,19 @@ export async function requestOpenai(req: NextRequest) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cache: "no-store",
|
|
|
|
cache: "no-store",
|
|
|
|
method: req.method,
|
|
|
|
method: req.method,
|
|
|
|
body: req.clone().body,
|
|
|
|
body: req.body,
|
|
|
|
signal: controller.signal,
|
|
|
|
signal: controller.signal,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// #1815 try to refuse gpt4 request
|
|
|
|
// #1815 try to refuse gpt4 request
|
|
|
|
if (DISABLE_GPT4) {
|
|
|
|
if (DISABLE_GPT4 && req.body) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const clonedBody = await req.clone().json();
|
|
|
|
const clonedBody = await req.text();
|
|
|
|
if ((clonedBody?.model ?? "").includes("gpt-4")) {
|
|
|
|
fetchOptions.body = clonedBody;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const jsonBody = JSON.parse(clonedBody);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((jsonBody?.model ?? "").includes("gpt-4")) {
|
|
|
|
return NextResponse.json(
|
|
|
|
return NextResponse.json(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
error: true,
|
|
|
|
error: true,
|
|
|
|