mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-22 21:50:16 +09:00
fix: fix bug 124
This commit is contained in:
parent
af60f46ba2
commit
445e05c63f
@ -60,6 +60,12 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
path = makeAzurePath(path, serverConfig.azureApiVersion);
|
path = makeAzurePath(path, serverConfig.azureApiVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clonedBody = await req.text();
|
||||||
|
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
||||||
|
if (serverConfig.isAzure) {
|
||||||
|
baseUrl = `${baseUrl}/${jsonBody.model}`;
|
||||||
|
}
|
||||||
|
const fetchUrl = `${baseUrl}/${path}`;
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -70,22 +76,16 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
method: req.method,
|
method: req.method,
|
||||||
body: req.body,
|
body: clonedBody,
|
||||||
// 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
|
||||||
duplex: "half",
|
duplex: "half",
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
};
|
};
|
||||||
const clonedBody = await req.text();
|
|
||||||
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
|
||||||
if (serverConfig.isAzure) {
|
|
||||||
baseUrl = `${baseUrl}/${jsonBody.model}`;
|
|
||||||
}
|
|
||||||
const fetchUrl = `${baseUrl}/${path}`;
|
|
||||||
|
|
||||||
// #1815 try to refuse gpt4 request
|
// #1815 try to refuse gpt4 request
|
||||||
if (serverConfig.customModels && req.body) {
|
if (serverConfig.customModels && clonedBody) {
|
||||||
try {
|
try {
|
||||||
const modelTable = collectModelTable(
|
const modelTable = collectModelTable(
|
||||||
DEFAULT_MODELS,
|
DEFAULT_MODELS,
|
||||||
|
Loading…
Reference in New Issue
Block a user