Skip to content

Commit 64f1c80

Browse files
committed
Quick Fix for Respones API Only (for Hannes)
1 parent 7007d4e commit 64f1c80

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/api/providers/__tests__/azure.spec.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ const { mockStreamText, mockGenerateText, mockCreateAzure } = vi.hoisted(() => (
33
mockStreamText: vi.fn(),
44
mockGenerateText: vi.fn(),
55
mockCreateAzure: vi.fn(() => {
6-
// Return a function that returns a mock language model
7-
return vi.fn(() => ({
6+
// Return a provider function that supports Responses API model creation
7+
const mockProvider = vi.fn(() => ({
88
modelId: "gpt-4o",
99
provider: "azure",
1010
}))
11+
;(mockProvider as any).responses = vi.fn(() => ({
12+
modelId: "gpt-4o",
13+
provider: "azure.responses",
14+
}))
15+
return mockProvider
1116
}),
1217
}))
1318

@@ -139,6 +144,27 @@ describe("AzureHandler", () => {
139144
},
140145
]
141146

147+
it("should use the Responses API language model", async () => {
148+
async function* mockFullStream() {
149+
yield { type: "text-delta", text: "Test response" }
150+
}
151+
152+
mockStreamText.mockReturnValue({
153+
fullStream: mockFullStream(),
154+
usage: Promise.resolve({ inputTokens: 1, outputTokens: 1 }),
155+
providerMetadata: Promise.resolve({}),
156+
})
157+
158+
const stream = handler.createMessage(systemPrompt, messages)
159+
for await (const _chunk of stream) {
160+
// exhaust stream
161+
}
162+
163+
expect(mockStreamText).toHaveBeenCalled()
164+
const requestOptions = mockStreamText.mock.calls[0][0]
165+
expect((requestOptions.model as any).provider).toBe("azure.responses")
166+
})
167+
142168
it("should handle streaming responses", async () => {
143169
// Mock the fullStream async generator
144170
async function* mockFullStream() {

src/api/providers/azure.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ export class AzureHandler extends BaseProvider implements SingleCompletionHandle
7272

7373
/**
7474
* Get the language model for the configured deployment name.
75+
* Azure provider is wired to use the Responses API endpoint.
7576
*/
7677
protected getLanguageModel() {
7778
const { id } = this.getModel()
78-
return this.provider(id)
79+
return this.provider.responses(id)
7980
}
8081

8182
/**

0 commit comments

Comments
 (0)