mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 21:56:38 +08:00
Update openai.ts
This commit is contained in:
parent
1c4970b5bc
commit
7594379e54
@ -86,20 +86,22 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
|
|
||||||
let baseUrl = "";
|
let baseUrl = "";
|
||||||
|
|
||||||
const isAzure = path.includes("deployments");
|
const isAzure = path.includes("deployments");
|
||||||
|
if (accessStore.useCustomConfig) {
|
||||||
if (isAzure && !accessStore.isValidAzure()) {
|
if (isAzure && !accessStore.isValidAzure()) {
|
||||||
throw Error(
|
throw Error(
|
||||||
"incomplete azure config, please check it in your settings page",
|
"incomplete azure config, please check it in your settings page",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const apiPath = ApiPath.Azure;
|
const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
|
||||||
// const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
|
baseUrl = isApp ? OPENAI_BASE_URL : apiPath;
|
||||||
// baseUrl = isApp ? OPENAI_BASE_URL : apiPath;
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
||||||
@ -270,15 +272,16 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
model.name === modelConfig.model &&
|
model.name === modelConfig.model &&
|
||||||
model?.provider?.providerName === ServiceProvider.Azure,
|
model?.provider?.providerName === ServiceProvider.Azure,
|
||||||
);
|
);
|
||||||
chatPath = this.path(
|
chatPath = this.path(
|
||||||
(isDalle3 ? Azure.ImagePath : Azure.ChatPath)(
|
(isDalle3 ? Azure.ImagePath : Azure.ChatPath)(
|
||||||
(model?.displayName ?? model?.name) as string,
|
(model?.displayName ?? model?.name) as string,
|
||||||
useCustomConfig ? useAccessStore.getState().azureApiVersion : "",
|
useCustomConfig ? useAccessStore.getState().azureApiVersion : "",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
if (!modelConfig.providerName === ServiceProvider.Azure) {
|
chatPath = this.path(
|
||||||
throw Error("ModelConfig is not the same as Azure);
|
isDalle3 ? OpenaiPath.ImagePath : OpenaiPath.ChatPath,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (shouldStream) {
|
if (shouldStream) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user