Skip to content

Commit fb71b73

Browse files
author
Zoo (VP)
committed
test(openai): cover abortSignal forwarding in non-streaming O3 branch
1 parent bb1f35b commit fb71b73

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎src/api/providers/__tests__/openai.spec.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,31 @@ describe("OpenAiHandler", () => {
14601460
})
14611461
})
14621462

1463+
it.each([
1464+
{ name: "standard", baseUrl: undefined },
1465+
{ name: "Azure AI Inference", baseUrl: "https://test.services.ai.azure.com" },
1466+
])("should forward the task abortSignal to non-streaming O3 requests ($name)", async ({ baseUrl }) => {
1467+
const o3Handler = new OpenAiHandler({
1468+
...o3Options,
1469+
openAiStreamingEnabled: false,
1470+
...(baseUrl ? { openAiBaseUrl: baseUrl, azureApiVersion: "2024-05-01-preview" } : {}),
1471+
})
1472+
const controller = new AbortController()
1473+
1474+
await collectStream(
1475+
o3Handler.createMessage(
1476+
"You are a helpful assistant.",
1477+
[{ role: "user", content: "Hello!" }],
1478+
makeCreateMessageMetadata({ abortSignal: controller.signal }),
1479+
),
1480+
)
1481+
1482+
expect(mockCreate).toHaveBeenCalledWith(expect.objectContaining({ model: "o3-mini" }), {
1483+
signal: controller.signal,
1484+
...(baseUrl ? { path: "/models/chat/completions" } : {}),
1485+
})
1486+
})
1487+
14631488
it.each([true, false])("adds Extra Body fields to O3 requests when streaming is %s", async (streaming) => {
14641489
const o3Handler = new OpenAiHandler({
14651490
...o3Options,

0 commit comments

Comments
 (0)