mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: maintain exact API behavior while extracting version from URL
- Extract API version from URL for both Azure OpenAI and Azure AI Inference - Keep original URL unchanged to maintain backward compatibility - API version is still sent in both URL and parameter as before - Only the user experience changes (no need to specify version twice)
This commit is contained in:
parent
d53df67dd6
commit
252530c270
1 changed files with 4 additions and 5 deletions
|
|
@ -13,7 +13,7 @@ import {
|
|||
import type { ApiHandlerOptions } from "../../shared/api"
|
||||
|
||||
import { XmlMatcher } from "../../utils/xml-matcher"
|
||||
import { extractApiVersionFromUrl, isAzureOpenAiUrl, removeApiVersionFromUrl } from "../../utils/azure-url-parser"
|
||||
import { extractApiVersionFromUrl } from "../../utils/azure-url-parser"
|
||||
|
||||
import { convertToOpenAiMessages } from "../transform/openai-format"
|
||||
import { convertToR1Format } from "../transform/r1-format"
|
||||
|
|
@ -46,12 +46,11 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
let effectiveApiVersion = this.options.azureApiVersion
|
||||
let baseURL = originalBaseURL
|
||||
|
||||
if (isAzureOpenAi && !effectiveApiVersion) {
|
||||
// Extract version for both Azure OpenAI and Azure AI Inference
|
||||
if ((isAzureOpenAi || isAzureAiInference) && !effectiveApiVersion) {
|
||||
const extractedVersion = extractApiVersionFromUrl(originalBaseURL)
|
||||
if (extractedVersion) {
|
||||
effectiveApiVersion = extractedVersion
|
||||
// For AzureOpenAI client, remove api-version from baseURL since it's passed separately
|
||||
baseURL = removeApiVersionFromUrl(originalBaseURL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +71,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
// Azure API shape slightly differs from the core API shape:
|
||||
// https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai
|
||||
this.client = new AzureOpenAI({
|
||||
baseURL,
|
||||
baseURL: originalBaseURL, // Use original URL to maintain exact same behavior
|
||||
apiKey,
|
||||
apiVersion: effectiveApiVersion || azureOpenAiDefaultApiVersion,
|
||||
defaultHeaders: headers,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue