Skip to content

Commit 343d3fa

Browse files
authored
Merge pull request #516 from samhvw8/feat/use-azure-openai
feat: add explicit Azure OpenAI flag
2 parents 1555a4f + f745f08 commit 343d3fa

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"
@@ -1217,6 +1218,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12171218
openAiApiKey,
12181219
openAiModelId,
12191220
openAiCustomModelInfo,
1221+
openAiUseAzure,
12201222
ollamaModelId,
12211223
ollamaBaseUrl,
12221224
lmStudioModelId,
@@ -1251,6 +1253,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12511253
await this.storeSecret("openAiApiKey", openAiApiKey)
12521254
await this.updateGlobalState("openAiModelId", openAiModelId)
12531255
await this.updateGlobalState("openAiCustomModelInfo", openAiCustomModelInfo)
1256+
await this.updateGlobalState("openAiUseAzure", openAiUseAzure)
12541257
await this.updateGlobalState("ollamaModelId", ollamaModelId)
12551258
await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl)
12561259
await this.updateGlobalState("lmStudioModelId", lmStudioModelId)
@@ -1868,6 +1871,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
18681871
openAiApiKey,
18691872
openAiModelId,
18701873
openAiCustomModelInfo,
1874+
openAiUseAzure,
18711875
ollamaModelId,
18721876
ollamaBaseUrl,
18731877
lmStudioModelId,
@@ -1932,6 +1936,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
19321936
this.getSecret("openAiApiKey") as Promise<string | undefined>,
19331937
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
19341938
this.getGlobalState("openAiCustomModelInfo") as Promise<ModelInfo | undefined>,
1939+
this.getGlobalState("openAiUseAzure") as Promise<boolean | undefined>,
19351940
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
19361941
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
19371942
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
@@ -2013,6 +2018,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
20132018
openAiApiKey,
20142019
openAiModelId,
20152020
openAiCustomModelInfo,
2021+
openAiUseAzure,
20162022
ollamaModelId,
20172023
ollamaBaseUrl,
20182024
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)