diff --git a/packages/ai/test/openai-completions-tool-choice.test.ts b/packages/ai/test/openai-completions-tool-choice.test.ts index 62185d3e..485e973e 100644 --- a/packages/ai/test/openai-completions-tool-choice.test.ts +++ b/packages/ai/test/openai-completions-tool-choice.test.ts @@ -24,9 +24,9 @@ vi.mock("openai", () => { class FakeOpenAI { chat = { completions: { - create: async (params: unknown) => { + create: (params: unknown) => { mockState.lastParams = params; - return { + const stream = { async *[Symbol.asyncIterator]() { const chunks = mockState.chunks ?? [ { @@ -44,6 +44,17 @@ vi.mock("openai", () => { } }, }; + const promise = Promise.resolve(stream) as Promise & { + withResponse: () => Promise<{ + data: typeof stream; + response: { status: number; headers: Headers }; + }>; + }; + promise.withResponse = async () => ({ + data: stream, + response: { status: 200, headers: new Headers() }, + }); + return promise; }, }, };