mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 08:06:38 +08:00
merge 暂存
This commit is contained in:
parent
af741e4dbf
commit
cf8f587a56
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ async function handle(
|
||||
try {
|
||||
const response = await requestOpenai(
|
||||
req,
|
||||
cloneBody,
|
||||
// cloneBody,
|
||||
// isAzure,
|
||||
jsonBody?.model ?? "",
|
||||
// jsonBody?.model ?? "",
|
||||
);
|
||||
|
||||
// list models
|
||||
|
Loading…
Reference in New Issue
Block a user