diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 00d59f9c0..f34554cb2 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -86,23 +86,16 @@ export class ChatGPTApi implements LLMApi { let baseUrl = ""; - const isAzure = path.includes("deployments") || accessStore.azureUrl?.includes(".models.ai.azure.com"); + const isAzure = path.includes("deployments"); if (isAzure && !accessStore.isValidAzure()) { throw Error( "incomplete azure config, please check it in your settings page", ); } - baseUrl = accessStore.azureUrl; - // baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl; if (baseUrl.length === 0) { const isApp = !!getClientConfig()?.isApp; - const isAIFoundation = accessStore.azureUrl?.includes(".models.ai.azure.com"); - if (isAIFoundation) { - baseUrl = accessStore.azureUrl; - } else { const apiPath = ApiPath.Azure; - baseUrl = accessStore.azureUrl; // const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI; // baseUrl = isApp ? OPENAI_BASE_URL : apiPath; } @@ -259,13 +252,6 @@ export class ChatGPTApi implements LLMApi { try { let chatPath = ""; 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 const { models: configModels, customModels: configCustomModels } = useAppConfig.getState(); @@ -284,16 +270,15 @@ export class ChatGPTApi implements LLMApi { model.name === modelConfig.model && model?.provider?.providerName === ServiceProvider.Azure, ); - /* chatPath = this.path( + chatPath = this.path( (isDalle3 ? Azure.ImagePath : Azure.ChatPath)( (model?.displayName ?? model?.name) as string, 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) { let index = -1;