Merge pull request #6071 from continuedev/pe/azure-pt2

fix: handle apiType for azure w/ proxy
This commit is contained in:
Nate Sesti 2025-06-10 19:44:01 -07:00 • committed by GitHub
commit 78da2817a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View file

@ -34,6 +34,10 @@ class ContinueProxy extends OpenAI {
constructor(options: LLMOptions) {
super(options);
this.configEnv = options.env;
// This it set to `undefined` to handle the case where we are proxying requests to Azure. We pass the correct env vars
// needed to do this in `extraBodyProperties` below, but if we don't set `apiType` to `undefined`, we end up proxying to
// `/openai/deployments/` which is invalid since that URL construction happens on the proxy.
this.apiType = undefined;
this.actualApiBase = options.apiBase;
this.apiKeyLocation = options.apiKeyLocation;
this.orgScopeId = options.orgScopeId;

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/openai-adapters",
"version": "1.0.36",
"version": "1.0.38",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -19,9 +19,6 @@ export class AzureApi extends OpenAIApi {
this.openai = new OpenAI({
apiKey: azureConfig.apiKey,
baseURL: this._getAzureBaseURL(azureConfig),
defaultQuery: azureConfig.env?.apiVersion
? { "api-version": azureConfig.env.apiVersion }
: {},
fetch: customFetch(azureConfig.requestOptions),
});
}
@ -42,11 +39,17 @@ export class AzureApi extends OpenAIApi {
if (this._isAzureOpenAI(config.env?.apiType)) {
if (!config.env?.deployment) {
throw new Error(
"Azure deployment is required if `apiType` is `azure-openai` or `azure`",
"`env.deployment` is a required configuration property for Azure OpenAI",
);
}
return `${baseURL}/openai/deployments/${config.env.deployment}`;
if (!config.env?.apiVersion) {
throw new Error(
"`env.apiVersion` is a required configuration property for Azure OpenAI",
);
}
return `${baseURL}/openai/deployments/${config.env.deployment}?api-version=${config.env.apiVersion}`;
}
return baseURL;