Skip to content

teeStream

teeStream(stream, count?): IRChatStream[]

Defined in: ai.matey.utils/dist/types/streaming.d.ts:383

Split a stream into multiple streams that can be consumed independently. Each returned stream receives all chunks from the source. Alias for splitStream with a simpler interface.

IRChatStream

The source stream

number

Number of streams to create

IRChatStream[]

const [stream1, stream2] = teeStream(originalStream, 2);
// Consume independently
const [result1, result2] = await Promise.all([
collectStreamFull(stream1),
processStream(stream2, { onContent: console.log }),
]);