mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
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.
This commit is contained in:
@@ -18,7 +18,7 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
|
|||||||
this.options = options
|
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
|
// 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
|
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({
|
this.client = new AzureOpenAI({
|
||||||
baseURL: this.options.openAiBaseUrl,
|
baseURL: this.options.openAiBaseUrl,
|
||||||
apiKey: this.options.openAiApiKey,
|
apiKey: this.options.openAiApiKey,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ type GlobalStateKey =
|
|||||||
| "openAiBaseUrl"
|
| "openAiBaseUrl"
|
||||||
| "openAiModelId"
|
| "openAiModelId"
|
||||||
| "openAiCustomModelInfo"
|
| "openAiCustomModelInfo"
|
||||||
|
| "openAiUseAzure"
|
||||||
| "ollamaModelId"
|
| "ollamaModelId"
|
||||||
| "ollamaBaseUrl"
|
| "ollamaBaseUrl"
|
||||||
| "lmStudioModelId"
|
| "lmStudioModelId"
|
||||||
@@ -1210,6 +1211,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
openAiApiKey,
|
openAiApiKey,
|
||||||
openAiModelId,
|
openAiModelId,
|
||||||
openAiCustomModelInfo,
|
openAiCustomModelInfo,
|
||||||
|
openAiUseAzure,
|
||||||
ollamaModelId,
|
ollamaModelId,
|
||||||
ollamaBaseUrl,
|
ollamaBaseUrl,
|
||||||
lmStudioModelId,
|
lmStudioModelId,
|
||||||
@@ -1244,6 +1246,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.storeSecret("openAiApiKey", openAiApiKey)
|
await this.storeSecret("openAiApiKey", openAiApiKey)
|
||||||
await this.updateGlobalState("openAiModelId", openAiModelId)
|
await this.updateGlobalState("openAiModelId", openAiModelId)
|
||||||
await this.updateGlobalState("openAiCustomModelInfo", openAiCustomModelInfo)
|
await this.updateGlobalState("openAiCustomModelInfo", openAiCustomModelInfo)
|
||||||
|
await this.updateGlobalState("openAiUseAzure", openAiUseAzure)
|
||||||
await this.updateGlobalState("ollamaModelId", ollamaModelId)
|
await this.updateGlobalState("ollamaModelId", ollamaModelId)
|
||||||
await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl)
|
await this.updateGlobalState("ollamaBaseUrl", ollamaBaseUrl)
|
||||||
await this.updateGlobalState("lmStudioModelId", lmStudioModelId)
|
await this.updateGlobalState("lmStudioModelId", lmStudioModelId)
|
||||||
@@ -1861,6 +1864,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
openAiApiKey,
|
openAiApiKey,
|
||||||
openAiModelId,
|
openAiModelId,
|
||||||
openAiCustomModelInfo,
|
openAiCustomModelInfo,
|
||||||
|
openAiUseAzure,
|
||||||
ollamaModelId,
|
ollamaModelId,
|
||||||
ollamaBaseUrl,
|
ollamaBaseUrl,
|
||||||
lmStudioModelId,
|
lmStudioModelId,
|
||||||
@@ -1925,6 +1929,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
this.getSecret("openAiApiKey") as Promise<string | undefined>,
|
this.getSecret("openAiApiKey") as Promise<string | undefined>,
|
||||||
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
|
this.getGlobalState("openAiModelId") as Promise<string | undefined>,
|
||||||
this.getGlobalState("openAiCustomModelInfo") as Promise<ModelInfo | undefined>,
|
this.getGlobalState("openAiCustomModelInfo") as Promise<ModelInfo | undefined>,
|
||||||
|
this.getGlobalState("openAiUseAzure") as Promise<boolean | undefined>,
|
||||||
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
|
this.getGlobalState("ollamaModelId") as Promise<string | undefined>,
|
||||||
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
|
this.getGlobalState("ollamaBaseUrl") as Promise<string | undefined>,
|
||||||
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
|
this.getGlobalState("lmStudioModelId") as Promise<string | undefined>,
|
||||||
@@ -2006,6 +2011,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
openAiApiKey,
|
openAiApiKey,
|
||||||
openAiModelId,
|
openAiModelId,
|
||||||
openAiCustomModelInfo,
|
openAiCustomModelInfo,
|
||||||
|
openAiUseAzure,
|
||||||
ollamaModelId,
|
ollamaModelId,
|
||||||
ollamaBaseUrl,
|
ollamaBaseUrl,
|
||||||
lmStudioModelId,
|
lmStudioModelId,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export interface ApiHandlerOptions {
|
|||||||
openAiApiKey?: string
|
openAiApiKey?: string
|
||||||
openAiModelId?: string
|
openAiModelId?: string
|
||||||
openAiCustomModelInfo?: ModelInfo
|
openAiCustomModelInfo?: ModelInfo
|
||||||
|
openAiUseAzure?: boolean
|
||||||
ollamaModelId?: string
|
ollamaModelId?: string
|
||||||
ollamaBaseUrl?: string
|
ollamaBaseUrl?: string
|
||||||
lmStudioModelId?: string
|
lmStudioModelId?: string
|
||||||
|
|||||||
@@ -536,6 +536,15 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
|
|||||||
Enable streaming
|
Enable streaming
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
<Checkbox
|
||||||
|
checked={apiConfiguration?.openAiUseAzure ?? false}
|
||||||
|
onChange={(checked: boolean) => {
|
||||||
|
handleInputChange("openAiUseAzure")({
|
||||||
|
target: { value: checked },
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
Use Azure
|
||||||
|
</Checkbox>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={azureApiVersionSelected}
|
checked={azureApiVersionSelected}
|
||||||
onChange={(checked: boolean) => {
|
onChange={(checked: boolean) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user