mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-03 00:26:40 +08:00
merge 暂存
This commit is contained in:
parent
af741e4dbf
commit
cf8f587a56
@ -25,7 +25,7 @@ async function handle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await requestOpenai(req, (await req.text()) as any);
|
return await requestOpenai(req);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[Azure] ", e);
|
console.error("[Azure] ", e);
|
||||||
return res.json(prettyObject(e));
|
return res.json(prettyObject(e));
|
||||||
|
@ -19,9 +19,9 @@ const serverConfig = getServerSideConfig();
|
|||||||
|
|
||||||
export async function requestOpenai(
|
export async function requestOpenai(
|
||||||
req: NextRequest,
|
req: NextRequest,
|
||||||
cloneBody: any,
|
// cloneBody: any,
|
||||||
// isAzure: boolean,
|
// isAzure: boolean,
|
||||||
current_model?: string,
|
// current_model?: string,
|
||||||
) {
|
) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ export async function requestOpenai(
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
method: req.method,
|
method: req.method,
|
||||||
body: cloneBody,
|
body: req.body,
|
||||||
// to fix #2485: https://stackoverflow.com/questions/55920957/cloudflare-worker-typeerror-one-time-use-body
|
// to fix #2485: https://stackoverflow.com/questions/55920957/cloudflare-worker-typeerror-one-time-use-body
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -128,8 +128,8 @@ export async function requestOpenai(
|
|||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
};
|
};
|
||||||
|
|
||||||
// #1815 try to refuse some model request
|
// #1815 try to refuse gpt4 request
|
||||||
if (current_model) {
|
if (serverConfig.customModels && req.body) {
|
||||||
try {
|
try {
|
||||||
const clonedBody = await req.text();
|
const clonedBody = await req.text();
|
||||||
fetchOptions.body = clonedBody;
|
fetchOptions.body = clonedBody;
|
||||||
@ -152,7 +152,7 @@ export async function requestOpenai(
|
|||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
error: true,
|
error: true,
|
||||||
message: `you are not allowed to use ${current_model} model`,
|
message: `you are not allowed to use ${jsonBody?.model} model`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: 403,
|
status: 403,
|
||||||
@ -160,7 +160,7 @@ export async function requestOpenai(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[OpenAI] gpt model filter", e);
|
console.error("[OpenAI] gpt4 filter", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ async function handle(
|
|||||||
try {
|
try {
|
||||||
const response = await requestOpenai(
|
const response = await requestOpenai(
|
||||||
req,
|
req,
|
||||||
cloneBody,
|
// cloneBody,
|
||||||
// isAzure,
|
// isAzure,
|
||||||
jsonBody?.model ?? "",
|
// jsonBody?.model ?? "",
|
||||||
);
|
);
|
||||||
|
|
||||||
// list models
|
// list models
|
||||||
|
Loading…
Reference in New Issue
Block a user