From e249e428dd577c1fa62e9bfe3bb2b19ae52da7e9 Mon Sep 17 00:00:00 2001 From: Matthias Kuhr <52661546+MatKuhr@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:01:36 +0100 Subject: [PATCH] chore: Add test for api-version override (#287) --- .../azure-openai-chat-client.test.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts index 9bcee50e..408dbdf5 100644 --- a/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts +++ b/packages/foundation-models/src/azure-openai/azure-openai-chat-client.test.ts @@ -55,6 +55,38 @@ describe('Azure OpenAI chat client', () => { const response = await client.run(prompt); expect(response.data).toEqual(mockResponse); }); + it('allows a custom api-version', async () => { + const prompt = { + messages: [ + { + role: 'user' as const, + content: 'Where is the deepest place on earth located' + } + ] + }; + + const mockResponse = + await parseMockResponse( + 'foundation-models', + 'azure-openai-chat-completion-success-response.json' + ); + + mockInference( + { + data: prompt + }, + { + data: mockResponse, + status: 200 + }, + { ...chatCompletionEndpoint, apiVersion: 'foo-bar' } + ); + + const response = await client.run(prompt, { + params: { 'api-version': 'foo-bar' } + }); + expect(response.data).toEqual(mockResponse); + }); it('throws on bad request', async () => { const prompt = { messages: [] };