This commit is contained in:
Hk-Gosuto 2024-02-08 14:23:50 +08:00
parent 9212773d88
commit 64453bb15d
1 changed files with 7 additions and 3 deletions

View File

@ -65,10 +65,14 @@ export async function requestOpenai(req: NextRequest) {
path = makeAzurePath(path, serverConfig.azureApiVersion); path = makeAzurePath(path, serverConfig.azureApiVersion);
} }
const clonedBody = await req.text(); let jsonBody;
const jsonBody = JSON.parse(clonedBody) as { model?: string }; let clonedBody;
if (req.method !== "GET" && req.method !== "HEAD") {
clonedBody = await req.text();
jsonBody = JSON.parse(clonedBody) as { model?: string };
}
if (serverConfig.isAzure) { if (serverConfig.isAzure) {
baseUrl = `${baseUrl}/${jsonBody.model}`; baseUrl = `${baseUrl}/${jsonBody?.model}`;
} }
const fetchUrl = `${baseUrl}/${path}`; const fetchUrl = `${baseUrl}/${path}`;
const fetchOptions: RequestInit = { const fetchOptions: RequestInit = {