test: azure pathname

This commit is contained in:
Tomasz Stefaniak 2025-06-25 15:44:20 -07:00
parent 22adae6157
commit 066c595ed7

View file

@ -173,4 +173,80 @@ describe("Configuration", () => {
"https://api.example.com",
);
});
it("should configure Azure OpenAI client with root URL and trailing slash", () => {
const azure = constructLlmApi({
provider: "azure",
apiKey: "sk-xxx",
apiBase: "https://test-azure-openai.azure.com/",
env: {
deployment: "gpt-4.1",
apiType: "azure-openai",
apiVersion: "2023-05-15",
},
});
// The Azure client modifies the baseURL to include the deployment
expect((azure as OpenAIApi).openai.baseURL).toBe(
"https://test-azure-openai.azure.com/openai/deployments/gpt-4.1",
);
expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
});
it("should configure Azure OpenAI client with path and trailing slash", () => {
const azure = constructLlmApi({
provider: "azure",
apiKey: "sk-xxx",
apiBase: "https://test-azure-openai.azure.com/v1/",
env: {
deployment: "gpt-4.1",
apiType: "azure-openai",
apiVersion: "2023-05-15",
},
});
// The Azure client modifies the baseURL to include the deployment
expect((azure as OpenAIApi).openai.baseURL).toBe(
"https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1",
);
expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
});
it("should configure Azure OpenAI client with root URL and no trailing slash", () => {
const azure = constructLlmApi({
provider: "azure",
apiKey: "sk-xxx",
apiBase: "https://test-azure-openai.azure.com",
env: {
deployment: "gpt-4.1",
apiType: "azure-openai",
apiVersion: "2023-05-15",
},
});
// The Azure client modifies the baseURL to include the deployment
expect((azure as OpenAIApi).openai.baseURL).toBe(
"https://test-azure-openai.azure.com/openai/deployments/gpt-4.1",
);
expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
});
it("should configure Azure OpenAI client with path and no trailing slash", () => {
const azure = constructLlmApi({
provider: "azure",
apiKey: "sk-xxx",
apiBase: "https://test-azure-openai.azure.com/v1",
env: {
deployment: "gpt-4.1",
apiType: "azure-openai",
apiVersion: "2023-05-15",
},
});
// The Azure client modifies the baseURL to include the deployment
expect((azure as OpenAIApi).openai.baseURL).toBe(
"https://test-azure-openai.azure.com/v1/openai/deployments/gpt-4.1",
);
expect((azure as OpenAIApi).openai.apiKey).toBe("sk-xxx");
});
});