Skip to main content

Module streaming

Module streaming 

Source
Expand description

Unified Streaming for Workflows and Agents

Provides token-level and event-level streaming across all workflow types:

  • Graph node execution with LLM token streaming
  • Handoff conversation streaming
  • Workflow step streaming
  • Real-time event callbacks

§Example

use cortexai_crew::streaming::{StreamingGraph, WorkflowEvent};

// Create a streaming graph
let streaming = StreamingGraph::new(graph, backend);

// Execute with event stream
let mut stream = streaming.execute_streaming(initial_state).await?;

while let Some(event) = stream.next().await {
    match event? {
        WorkflowEvent::NodeStarted { node_id } => println!("Starting: {}", node_id),
        WorkflowEvent::TokenDelta { token } => print!("{}", token),
        WorkflowEvent::NodeCompleted { node_id, .. } => println!("\nDone: {}", node_id),
        WorkflowEvent::WorkflowCompleted { .. } => break,
        _ => {}
    }
}

Structs§

EventCallbackBuilder
Builder for event callbacks
EventEmitter
Event emitter for sending events to multiple receivers
EventHandler
Handler for workflow events
StreamingGraph
Streaming wrapper for Graph execution
StreamingHandoff
Streaming wrapper for Handoff execution
StreamingStats
Statistics about a streaming execution
TokenCollector
Collector for aggregating streamed tokens

Enums§

StreamingNodeType
Type of streaming node
StreamingStatus
Status of streaming workflow completion
WorkflowEvent
Unified workflow event for streaming
WorkflowType
Type of workflow

Type Aliases§

EventCallback
Event callback function type
EventStream
Stream of workflow events