Streaming & Events
The Event Stream
const stream = conversation.send("Tell me a short story about a robot.");
for await (const event of stream) {
console.log("Received Event:", event.type, event);
switch (event.type) {
case 'assistant':
// Process assistant's text response chunk
break;
case 'tool.generating':
// LLM is generating raw input for a tool (optional handling)
break;
case 'tool.calling':
// A tool is about to be called
break;
case 'tool':
// A tool has finished executing, result is available
break;
case 'error':
// An error occurred during processing
break;
}
}Event Types
Why Streaming Matters
Last updated