diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index d71a51f..c5e3ae9 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -18,7 +18,7 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler { this.options = options // Azure API shape slightly differs from the core API shape: https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai const urlHost = new URL(this.options.openAiBaseUrl ?? "").host - if (urlHost === "azure.com" || urlHost.endsWith(".azure.com")) { + if (urlHost === "azure.com" || urlHost.endsWith(".azure.com") || options.openAiUseAzure) { this.client = new AzureOpenAI({ baseURL: this.options.openAiBaseUrl, apiKey: this.options.openAiApiKey, diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index af4bc71..b3e5235 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -78,6 +78,7 @@ type GlobalStateKey = | "openAiBaseUrl" | "openAiModelId" | "openAiCustomModelInfo" + | "openAiUseAzure" | "ollamaModelId" | "ollamaBaseUrl" | "lmStudioModelId" @@ -1217,6 +1218,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { openAiApiKey, openAiModelId, openAiCustomModelInfo, + openAiUseAzure, ollamaModelId, ollamaBaseUrl, lmStudioModelId, @@ -1251,6 +1253,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { await this.storeSecret("openAiApiKey", openAiApiKey) await this.updateGlobalState("openAiModelId", openAiModelId) await this.updateGlobalState("openAiCustomModelInfo", openAiCustomModelInfo) + await this.updateGlobalState("openAiUseAzure", openAiUseAzure) await this.updateGlobalState("ollamaModelId", ollamaModelId) await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl) await this.updateGlobalState("lmStudioModelId", lmStudioModelId) @@ -1868,6 +1871,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { openAiApiKey, openAiModelId, openAiCustomModelInfo, + openAiUseAzure, ollamaModelId, ollamaBaseUrl, lmStudioModelId, @@ -1932,6 +1936,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { this.getSecret("openAiApiKey") as Promise, this.getGlobalState("openAiModelId") as Promise, this.getGlobalState("openAiCustomModelInfo") as Promise, + this.getGlobalState("openAiUseAzure") as Promise, this.getGlobalState("ollamaModelId") as Promise, this.getGlobalState("ollamaBaseUrl") as Promise, this.getGlobalState("lmStudioModelId") as Promise, @@ -2013,6 +2018,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { openAiApiKey, openAiModelId, openAiCustomModelInfo, + openAiUseAzure, ollamaModelId, ollamaBaseUrl, lmStudioModelId, diff --git a/src/shared/api.ts b/src/shared/api.ts index 860eb36..72d6f17 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -39,6 +39,7 @@ export interface ApiHandlerOptions { openAiApiKey?: string openAiModelId?: string openAiCustomModelInfo?: ModelInfo + openAiUseAzure?: boolean ollamaModelId?: string ollamaBaseUrl?: string lmStudioModelId?: string diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 13e7a57..9a84b07 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -536,6 +536,15 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) = Enable streaming + { + handleInputChange("openAiUseAzure")({ + target: { value: checked }, + }) + }}> + Use Azure + {