mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 13:46:37 +08:00
Update openai.ts
This commit is contained in:
parent
49dd5d5854
commit
1c15eb7dc9
@ -86,23 +86,16 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
|
|
||||||
let baseUrl = "";
|
let baseUrl = "";
|
||||||
|
|
||||||
const isAzure = path.includes("deployments") || accessStore.azureUrl?.includes(".models.ai.azure.com");
|
const isAzure = path.includes("deployments");
|
||||||
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 = accessStore.azureUrl;
|
|
||||||
// baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
|
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const isAIFoundation = accessStore.azureUrl?.includes(".models.ai.azure.com");
|
|
||||||
if (isAIFoundation) {
|
|
||||||
baseUrl = accessStore.azureUrl;
|
|
||||||
} else {
|
|
||||||
const apiPath = ApiPath.Azure;
|
const apiPath = ApiPath.Azure;
|
||||||
baseUrl = accessStore.azureUrl;
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -259,13 +252,6 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
try {
|
try {
|
||||||
let chatPath = "";
|
let chatPath = "";
|
||||||
if (modelConfig.providerName === ServiceProvider.Azure) {
|
if (modelConfig.providerName === ServiceProvider.Azure) {
|
||||||
const isAIFoundation = useAccessStore.getState().azureUrl?.includes(".models.ai.azure.com");
|
|
||||||
const azureUrl = useAccessStore.getState().azureUrl;
|
|
||||||
if (!azureUrl) {
|
|
||||||
throw new Error("Azure URL is not configured");
|
|
||||||
}
|
|
||||||
const sanitizedAzureUrl = azureUrl.replace(/\/+$/, "");
|
|
||||||
chatPath = cloudflareAIGatewayUrl(`${sanitizedAzureUrl}/chat/completions`);
|
|
||||||
// find model, and get displayName as deployName
|
// find model, and get displayName as deployName
|
||||||
const { models: configModels, customModels: configCustomModels } =
|
const { models: configModels, customModels: configCustomModels } =
|
||||||
useAppConfig.getState();
|
useAppConfig.getState();
|
||||||
@ -284,16 +270,15 @@ 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 {
|
|
||||||
chatPath = this.path(
|
|
||||||
isDalle3 ? OpenaiPath.ImagePath : OpenaiPath.ChatPath,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if (!modelConfig.providerName === ServiceProvider.Azure) {
|
||||||
|
throw Error("ModelConfig is not the same as Azure);
|
||||||
}
|
}
|
||||||
if (shouldStream) {
|
if (shouldStream) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user