diff --git a/core/llm/stream.ts b/core/llm/stream.ts index b51f1fd36..0a014d931 100644 --- a/core/llm/stream.ts +++ b/core/llm/stream.ts @@ -1,10 +1,15 @@ -async function* toAsyncIterable(nodeReadable: NodeJS.ReadableStream): AsyncGenerator { +async function* toAsyncIterable( + nodeReadable: NodeJS.ReadableStream, +): AsyncGenerator { for await (const chunk of nodeReadable) { + // @ts-ignore yield chunk as Uint8Array; } } -export async function* streamResponse(response: Response): AsyncGenerator { +export async function* streamResponse( + response: Response, +): AsyncGenerator { if (response.status !== 200) { throw new Error(await response.text()); } @@ -19,7 +24,9 @@ export async function* streamResponse(response: Response): AsyncGenerator= 20) { // Use the new API for Node 20 and above const stream = (ReadableStream as any).from(response.body); - for await (const chunk of stream.pipeThrough(new TextDecoderStream("utf-8"))) { + for await (const chunk of stream.pipeThrough( + new TextDecoderStream("utf-8"), + )) { yield chunk; } } else {