mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Merge pull request #516 from samhvw8/feat/use-azure-openai
feat: add explicit Azure OpenAI flag
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<string | undefined>,
|
||||
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
|
||||
this.getGlobalState("openAiCustomModelInfo") as Promise<ModelInfo | undefined>,
|
||||
this.getGlobalState("openAiUseAzure") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
|
||||
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
|
||||
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
|
||||
@@ -2013,6 +2018,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
openAiApiKey,
|
||||
openAiModelId,
|
||||
openAiCustomModelInfo,
|
||||
openAiUseAzure,
|
||||
ollamaModelId,
|
||||
ollamaBaseUrl,
|
||||
lmStudioModelId,
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface ApiHandlerOptions {
|
||||
openAiApiKey?: string
|
||||
openAiModelId?: string
|
||||
openAiCustomModelInfo?: ModelInfo
|
||||
openAiUseAzure?: boolean
|
||||
ollamaModelId?: string
|
||||
ollamaBaseUrl?: string
|
||||
lmStudioModelId?: string
|
||||
|
||||
@@ -536,6 +536,15 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
||||
Enable streaming
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Checkbox
|
||||
checked={apiConfiguration?.openAiUseAzure ?? false}
|
||||
onChange={(checked: boolean) => {
|
||||
handleInputChange("openAiUseAzure")({
|
||||
target: { value: checked },
|
||||
})
|
||||
}}>
|
||||
Use Azure
|
||||
</Checkbox>
|
||||
<Checkbox
|
||||
checked={azureApiVersionSelected}
|
||||
onChange={(checked: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user