``` const stream = await retrivalChain.stream({ input: 'what is hello world', }); return new Respon

const stream = await retrivalChain.stream({
input: 'what is hello world',
});

return new Response(stream, {
    headers: {
    'content-type': 'text/event-stream',
    'Access-Control-Allow-Origin': '*',
    },
});


is this the correct way to send streams from cloudflare worker?
getting typescript error,

Argument of type 'IterableReadableStream<{ context: Document<Record<string, any>>[]; answer: string; } & { [key: string]: unknown; }>' is not assignable to parameter of type 'BodyInit | null | undefined'.
  Type 'IterableReadableStream<{ context: Document<Record<string, any>>[]; answer: string; } & { [key: string]: unknown; }>' is not assignable to type 'ReadableStream<Uint8Array>'.
    The types returned by 'getReader()' are incompatible between these types.
      Type 'ReadableStreamDefaultReader<{ context: Document<Record<string, any>>[]; answer: string; } & { [key: string]: unknown; }>' is not assignable to type 'ReadableStreamDefaultReader<Uint8Array>'.
        Type '{ context: Document<Record<string, any>>[]; answer: string; } & { [key: string]: unknown; }' is missing the following properties from type 'Uint8Array': BYTES_PER_ELEMENT, buffer, byteLength, byteOffset, and 27 more.ts(2345)
const stream: IterableReadableStream<{
    context: Document<Record<string, any>>[];
    answer: string;
} & {
    [key: string]: unknown;
}>
Was this page helpful?