Utility function to collect the complete text from an event stream.
This helper accumulates all text deltas and returns the final complete text once streaming is finished. Useful when you want streaming behavior but need the full text at the end.
AsyncIterable of Event objects from runner.runAsync()
Promise resolving to the complete text
import { collectTextFrom } from '@iqai/adk/utils';const events = runner.runAsync({ userId: 'user-123', sessionId: 'session-456', newMessage: { role: 'user', parts: [{ text: 'Hello' }] }});const fullText = await collectTextFrom(events);console.log(fullText); // Complete response text Copy
import { collectTextFrom } from '@iqai/adk/utils';const events = runner.runAsync({ userId: 'user-123', sessionId: 'session-456', newMessage: { role: 'user', parts: [{ text: 'Hello' }] }});const fullText = await collectTextFrom(events);console.log(fullText); // Complete response text
Utility function to collect the complete text from an event stream.
This helper accumulates all text deltas and returns the final complete text once streaming is finished. Useful when you want streaming behavior but need the full text at the end.