Elffuss BraidHub

kikocis/continue public

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

fix: handle apiType for azure w/ proxy
Changesetf6d482c84614189f6e49e038f1f0be48c4992f274d16ff874fd3143cc04d745f
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-06-10 19:44 -07:00
CommitterGitHub <noreply@github.com> · 2025-06-10 19:44 -07:00
Parents48a36c7cc06f, 55346f1d1574

Browse the files at this changeset

3 files changed

modified core/llm/llms/stubs/ContinueProxy.ts +4 −0
@@ -34,6 +34,10 @@
3434 constructor(options: LLMOptions) {
3535 super(options);
3636 this.configEnv = options.env;
37+ // This it set to `undefined` to handle the case where we are proxying requests to Azure. We pass the correct env vars
38+ // needed to do this in `extraBodyProperties` below, but if we don't set `apiType` to `undefined`, we end up proxying to
39+ // `/openai/deployments/` which is invalid since that URL construction happens on the proxy.
40+ this.apiType = undefined;
3741 this.actualApiBase = options.apiBase;
3842 this.apiKeyLocation = options.apiKeyLocation;
3943 this.orgScopeId = options.orgScopeId;
modified packages/openai-adapters/package.json +1 −1
@@ -1,6 +1,6 @@
11 {
22 "name": "@continuedev/openai-adapters",
3- "version": "1.0.36",
3+ "version": "1.0.38",
44 "description": "",
55 "main": "dist/index.js",
66 "types": "dist/index.d.ts",
modified packages/openai-adapters/src/apis/Azure.ts +8 −5
@@ -19,9 +19,6 @@
1919 this.openai = new OpenAI({
2020 apiKey: azureConfig.apiKey,
2121 baseURL: this._getAzureBaseURL(azureConfig),
22- defaultQuery: azureConfig.env?.apiVersion
23- ? { "api-version": azureConfig.env.apiVersion }
24- : {},
2522 fetch: customFetch(azureConfig.requestOptions),
2623 });
2724 }
@@ -42,11 +39,17 @@
4239 if (this._isAzureOpenAI(config.env?.apiType)) {
4340 if (!config.env?.deployment) {
4441 throw new Error(
45- "Azure deployment is required if `apiType` is `azure-openai` or `azure`",
42+ "`env.deployment` is a required configuration property for Azure OpenAI",
4643 );
4744 }
4845
49- return `${baseURL}/openai/deployments/${config.env.deployment}`;
46+ if (!config.env?.apiVersion) {
47+ throw new Error(
48+ "`env.apiVersion` is a required configuration property for Azure OpenAI",
49+ );
50+ }
51+
52+ return `${baseURL}/openai/deployments/${config.env.deployment}?api-version=${config.env.apiVersion}`;
5053 }
5154
5255 return baseURL;