ChatGPT-Next-Web(Azure)切换模型问题

250 阅读1分钟

问题描述

  1. Azure模型gpt4与gpt4o模型无法切换。

gpt4模型:不知道cnlunar项目。 image.png

gpt4o模型:指导cnlunar项目。 image.png

解决问题方案:

在app/common.ts文件中。

image.png

const clonedBody = await req.text();
const fetchOptions: RequestInit = {
  headers: {
    "Content-Type": "application/json",
    "Cache-Control": "no-store",
    "model": JSON.parse(clonedBody).model,
    [authHeaderName]: authValue,
    ...(serverConfig.openaiOrgId && {
      "OpenAI-Organization": serverConfig.openaiOrgId,
    }),
  },
  method: req.method,
  body: req.body,
  // to fix #2485: https://stackoverflow.com/questions/55920957/cloudflare-worker-typeerror-one-time-use-body
  redirect: "manual",
  // @ts-ignore
  duplex: "half",
  signal: controller.signal,
};
fetchOptions.body = clonedBody;
if (serverConfig.customModels && clonedBody) {

解决问题的过程:

发现Azure官网的restful api请求采用的是请求头header中加入model模型进行切换的,更多信息请去Azure官网查看。