Skip to content

IRChatStream

IRChatStream = AsyncGenerator<IRStreamChunk, void, undefined>

Defined in: packages/ai.matey.types/src/ir.ts:977

Async generator for streaming responses.

Yields IR stream chunks as they arrive from the backend.

async function processStream(stream: IRChatStream) {
for await (const chunk of stream) {
switch (chunk.type) {
case 'start':
console.log('Stream started:', chunk.metadata.requestId);
break;
case 'content':
process.stdout.write(chunk.delta);
break;
case 'done':
console.log('\nStream finished:', chunk.finishReason);
break;
case 'error':
console.error('Stream error:', chunk.error.message);
break;
}
}
}