pub async fn print_stream(
stream: &mut (impl StreamExt<Item = StreamPart> + Unpin),
print_updates: bool,
) -> StringExpand description
Stream graph execution and print tokens to stdout in real-time.
Handles the common streaming boilerplate in examples. Tokens from
StreamMode::Custom are printed inline (typewriter style). Node
completion updates from StreamMode::Updates are printed as [update] lines.
Thinking content is printed in dim gray with a [Thinking] prefix.
Returns the collected token text.
§Example
ⓘ
use langgraph::prelude::*;
use langgraph_prebuilt::print_stream;
let mut stream = app.astream(&input, &RunnableConfig::new(), vec![StreamMode::Custom, StreamMode::Updates]);
let text = print_stream(&mut stream, true).await;
println!("Final: {}", text);