Elffuss BraidHub

kikocis/continue public

test: azure pathname
Changeset753639944bc473a4c07fc6b05809fc0bac1df22dfc72cab4f0aa0e359bae719e
AuthorTomasz Stefaniak <tomasz.p.stefaniak@gmail.com> · 2025-06-25 15:44 -07:00
CommitterTomasz Stefaniak <tomasz.p.stefaniak@gmail.com> · 2025-06-25 15:44 -07:00
Parents9e5ceba2cbc7

Browse the files at this changeset

1 file changed

modified packages/openai-adapters/src/test/main.test.ts +76 −0
@@ -173,4 +173,80 @@
173173 "https://api.example.com",
174174 );
175175 });
176+
177+ it("should configure Azure OpenAI client with root URL and trailing slash", () => {
178+ const azure = constructLlmApi({
179+ provider: "azure",
180+ apiKey: "sk-xxx",
181+ apiBase: "https://test-azure-openai.azure.com/",
182+ env: {
183+ deployment: "gpt-4.1",
184+ apiType: "azure-openai",
185+ apiVersion: "2023-05-15",
186+ },
187+ });
188+
189+ // The Azure client modifies the baseURL to include the deployment
190+ expect((azure as OpenAIApi).openai.baseURL).toBe(
191+ "https://test-azure-openai.azure.com/openai/deployments/gpt-4.1",
192+ );
193+ expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
194+ });
195+
196+ it("should configure Azure OpenAI client with path and trailing slash", () => {
197+ const azure = constructLlmApi({
198+ provider: "azure",
199+ apiKey: "sk-xxx",
200+ apiBase: "https://test-azure-openai.azure.com/v1/",
201+ env: {
202+ deployment: "gpt-4.1",
203+ apiType: "azure-openai",
204+ apiVersion: "2023-05-15",
205+ },
206+ });
207+
208+ // The Azure client modifies the baseURL to include the deployment
209+ expect((azure as OpenAIApi).openai.baseURL).toBe(
210+ "https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1",
211+ );
212+ expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
213+ });
214+
215+ it("should configure Azure OpenAI client with root URL and no trailing slash", () => {
216+ const azure = constructLlmApi({
217+ provider: "azure",
218+ apiKey: "sk-xxx",
219+ apiBase: "https://test-azure-openai.azure.com",
220+ env: {
221+ deployment: "gpt-4.1",
222+ apiType: "azure-openai",
223+ apiVersion: "2023-05-15",
224+ },
225+ });
226+
227+ // The Azure client modifies the baseURL to include the deployment
228+ expect((azure as OpenAIApi).openai.baseURL).toBe(
229+ "https://test-azure-openai.azure.com/openai/deployments/gpt-4.1",
230+ );
231+ expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
232+ });
233+
234+ it("should configure Azure OpenAI client with path and no trailing slash", () => {
235+ const azure = constructLlmApi({
236+ provider: "azure",
237+ apiKey: "sk-xxx",
238+ apiBase: "https://test-azure-openai.azure.com/v1",
239+ env: {
240+ deployment: "gpt-4.1",
241+ apiType: "azure-openai",
242+ apiVersion: "2023-05-15",
243+ },
244+ });
245+
246+ // The Azure client modifies the baseURL to include the deployment
247+ expect((azure as OpenAIApi).openai.baseURL).toBe(
248+ "https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1",
249+ );
250+ expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
251+ });
176252 });