Skip to content

Commit f745f08

Browse files
committed
feat: add explicit Azure OpenAI flag and setup memory bank docs
- Add openAiUseAzure flag to force Azure OpenAI client initialization - Add "Use Azure" checkbox in API settings UI This change improves Azure OpenAI configuration flexibility by allowing users to explicitly opt-in to Azure client, regardless of the base URL pattern.
1 parent 0d6f928 commit f745f08

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

src/api/providers/openai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
1818
this.options = options
1919
// Azure API shape slightly differs from the core API shape: https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
2020
const urlHost = new URL(this.options.openAiBaseUrl ?? "").host
21-
if (urlHost === "azure.com" || urlHost.endsWith(".azure.com")) {
21+
if (urlHost === "azure.com" || urlHost.endsWith(".azure.com") || options.openAiUseAzure) {
2222
this.client = new AzureOpenAI({
2323
baseURL: this.options.openAiBaseUrl,
2424
apiKey: this.options.openAiApiKey,

src/core/webview/ClineProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type GlobalStateKey =
7878
| "openAiBaseUrl"
7979
| "openAiModelId"
8080
| "openAiCustomModelInfo"
81+
| "openAiUseAzure"
8182
| "ollamaModelId"
8283
| "ollamaBaseUrl"
8384
| "lmStudioModelId"
@@ -1210,6 +1211,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12101211
openAiApiKey,
12111212
openAiModelId,
12121213
openAiCustomModelInfo,
1214+
openAiUseAzure,
12131215
ollamaModelId,
12141216
ollamaBaseUrl,
12151217
lmStudioModelId,
@@ -1244,6 +1246,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12441246
await this.storeSecret("openAiApiKey", openAiApiKey)
12451247
await this.updateGlobalState("openAiModelId", openAiModelId)
12461248
await this.updateGlobalState("openAiCustomModelInfo", openAiCustomModelInfo)
1249+
await this.updateGlobalState("openAiUseAzure", openAiUseAzure)
12471250
await this.updateGlobalState("ollamaModelId", ollamaModelId)
12481251
await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl)
12491252
await this.updateGlobalState("lmStudioModelId", lmStudioModelId)
@@ -1861,6 +1864,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18611864
openAiApiKey,
18621865
openAiModelId,
18631866
openAiCustomModelInfo,
1867+
openAiUseAzure,
18641868
ollamaModelId,
18651869
ollamaBaseUrl,
18661870
lmStudioModelId,
@@ -1925,6 +1929,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
19251929
this.getSecret("openAiApiKey") as Promise<string | undefined>,
19261930
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
19271931
this.getGlobalState("openAiCustomModelInfo") as Promise<ModelInfo | undefined>,
1932+
this.getGlobalState("openAiUseAzure") as Promise<boolean | undefined>,
19281933
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
19291934
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
19301935
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
@@ -2006,6 +2011,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
20062011
openAiApiKey,
20072012
openAiModelId,
20082013
openAiCustomModelInfo,
2014+
openAiUseAzure,
20092015
ollamaModelId,
20102016
ollamaBaseUrl,
20112017
lmStudioModelId,

src/shared/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface ApiHandlerOptions {
3939
openAiApiKey?: string
4040
openAiModelId?: string
4141
openAiCustomModelInfo?: ModelInfo
42+
openAiUseAzure?: boolean
4243
ollamaModelId?: string
4344
ollamaBaseUrl?: string
4445
lmStudioModelId?: string

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,15 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
536536
Enable streaming
537537
</Checkbox>
538538
</div>
539+
<Checkbox
540+
checked={apiConfiguration?.openAiUseAzure ?? false}
541+
onChange={(checked: boolean) => {
542+
handleInputChange("openAiUseAzure")({
543+
target: { value: checked },
544+
})
545+
}}>
546+
Use Azure
547+
</Checkbox>
539548
<Checkbox
540549
checked={azureApiVersionSelected}
541550
onChange={(checked: boolean) => {

0 commit comments

Comments
 (0)