stream(
self,
input: InputT | Command | None,
config: RunnableConfig| Name | Type | Description |
|---|---|---|
input* | InputT | Command | None | The input to the graph. |
config | RunnableConfig | None | Default: NoneThe configuration to use for the run. |
context | ContextT | None | Default: None |
stream_mode | StreamMode | Sequence[StreamMode] | None | Default: None |
print_mode | StreamMode | Sequence[StreamMode] | Default: () |
output_keys | str | Sequence[str] | None | Default: None |
interrupt_before | All | Sequence[str] | None | Default: None |
interrupt_after | All | Sequence[str] | None | Default: None |
durability | Durability | None | Default: None |
control | RunControl | None | Default: None |
subgraphs | bool | Default: False |
Stream graph steps for a single input.
The static context to use for the run.
The mode to stream output, defaults to self.stream_mode.
Options are:
"values": Emit all values in the state after each step, including interrupts.
When used with functional API, values are emitted once at the end of the workflow."updates": Emit only the node or task names and updates returned by the nodes or tasks after each step.
If multiple updates are made in the same step (e.g. multiple nodes are run) then those updates are emitted separately."custom": Emit custom data from inside nodes or tasks using StreamWriter."messages": Emit LLM messages token-by-token together with metadata for any LLM invocations inside nodes or tasks.
(LLM token, metadata)."checkpoints": Emit an event when a checkpoint is created, in the same format as returned by get_state()."tasks": Emit events when tasks start and finish, including their results and errors."debug": Emit debug events with as much information as possible for each step.You can pass a list as the stream_mode parameter to stream multiple modes at once.
The streamed outputs will be tuples of (mode, data).
See LangGraph streaming guide for more details.
Accepts the same values as stream_mode, but only prints the output to the console, for debugging purposes.
Does not affect the output of the graph in any way.
The keys to stream, defaults to all non-context channels.
Nodes to interrupt before, defaults to all nodes in the graph.
Nodes to interrupt after, defaults to all nodes in the graph.
The durability mode for the graph execution, defaults to "async".
Options are:
"sync": Changes are persisted synchronously before the next step starts."async": Changes are persisted asynchronously while the next step executes."exit": Changes are persisted only when the graph exits.Optional run control used to request cooperative drain.
Whether to stream events from inside subgraphs, defaults to False.
If True, the events will be emitted as tuples (namespace, data),
or (namespace, mode, data) if stream_mode is a list,
where namespace is a tuple with the path to the node where a subgraph is invoked,
e.g. ("parent_node:<task_id>", "child_node:<task_id>").
See LangGraph streaming guide for more details.