From 036e19618b86600e4e9c5ad6e6ee5a98e55e15f1 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 10 Jun 2025 16:41:12 -0700 Subject: [PATCH 1/2] fix: handle apiType for azure w/ proxy --- core/llm/llms/stubs/ContinueProxy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index 3506dcb32..b49d00548 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -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; From 4355618079808bdfc3240022e79a0a9dd8457b02 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 10 Jun 2025 18:57:33 -0700 Subject: [PATCH 2/2] fix: make `env.apiVersion` required for azure openai --- packages/openai-adapters/package.json | 2 +- packages/openai-adapters/src/apis/Azure.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index 08c1581b6..2b5043cfb 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -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", diff --git a/packages/openai-adapters/src/apis/Azure.ts b/packages/openai-adapters/src/apis/Azure.ts index 57f48c3e0..bf9a5ae4d 100644 --- a/packages/openai-adapters/src/apis/Azure.ts +++ b/packages/openai-adapters/src/apis/Azure.ts @@ -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;