Channels¶
BaseChannel
¶
Bases:
,
Source code in libs/langgraph/langgraph/channels/base.py
ValueType: Any
abstractmethod
property
¶
The type of the value stored in the channel.
UpdateType: Any
abstractmethod
property
¶
The type of the update received by the channel.
checkpoint() -> Optional[C]
¶
Return a serializable representation of the channel's current state. Raises EmptyChannelError if the channel is empty (never updated yet), or doesn't support checkpoints.
Source code in libs/langgraph/langgraph/channels/base.py
from_checkpoint(checkpoint: Optional[C]) -> Self
abstractmethod
¶
Return a new identical channel, optionally initialized from a checkpoint. If the checkpoint contains complex data structures, they should be copied.
update(values: Sequence[Update]) -> bool
abstractmethod
¶
Update the channel's value with the given sequence of updates. The order of the updates in the sequence is arbitrary. This method is called by Pregel for all channels at the end of each step. If there are no updates, it is called with an empty sequence. Raises InvalidUpdateError if the sequence of updates is invalid. Returns True if the channel was updated, False otherwise.
Source code in libs/langgraph/langgraph/channels/base.py
get() -> Value
abstractmethod
¶
Return the current value of the channel.
Raises EmptyChannelError if the channel is empty (never updated yet).
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.
Source code in libs/langgraph/langgraph/channels/base.py
Topic
¶
Bases:
,
A configurable PubSub Topic.
Parameters:
-
typ
(
) –Type [Value ]The type of the value stored in the channel.
-
accumulate
(
, default:bool False
) –Whether to accumulate values across steps. If False, the channel will be emptied after each step.
Source code in libs/langgraph/langgraph/channels/topic.py
ValueType: Any
property
¶
The type of the value stored in the channel.
UpdateType: Any
property
¶
The type of the update received by the channel.
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.
Source code in libs/langgraph/langgraph/channels/base.py
LastValue
¶
Bases:
,
Stores the last value received, can receive at most one value per step.
Source code in libs/langgraph/langgraph/channels/last_value.py
ValueType: Type[Value]
property
¶
The type of the value stored in the channel.
UpdateType: Type[Value]
property
¶
The type of the update received by the channel.
checkpoint() -> Optional[C]
¶
Return a serializable representation of the channel's current state. Raises EmptyChannelError if the channel is empty (never updated yet), or doesn't support checkpoints.
Source code in libs/langgraph/langgraph/channels/base.py
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.
Source code in libs/langgraph/langgraph/channels/base.py
EphemeralValue
¶
Bases:
,
Stores the value received in the step immediately preceding, clears after.
Source code in libs/langgraph/langgraph/channels/ephemeral_value.py
ValueType: Type[Value]
property
¶
The type of the value stored in the channel.
UpdateType: Type[Value]
property
¶
The type of the update received by the channel.
checkpoint() -> Optional[C]
¶
Return a serializable representation of the channel's current state. Raises EmptyChannelError if the channel is empty (never updated yet), or doesn't support checkpoints.
Source code in libs/langgraph/langgraph/channels/base.py
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.
Source code in libs/langgraph/langgraph/channels/base.py
BinaryOperatorAggregate
¶
Bases:
,
Stores the result of applying a binary operator to the current value and each new value.
Source code in libs/langgraph/langgraph/channels/binop.py
ValueType: Type[Value]
property
¶
The type of the value stored in the channel.
UpdateType: Type[Value]
property
¶
The type of the update received by the channel.
checkpoint() -> Optional[C]
¶
Return a serializable representation of the channel's current state. Raises EmptyChannelError if the channel is empty (never updated yet), or doesn't support checkpoints.
Source code in libs/langgraph/langgraph/channels/base.py
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.
Source code in libs/langgraph/langgraph/channels/base.py
AnyValue
¶
Bases:
,
Stores the last value received, assumes that if multiple values are received, they are all equal.
Source code in libs/langgraph/langgraph/channels/any_value.py
ValueType: Type[Value]
property
¶
The type of the value stored in the channel.
UpdateType: Type[Value]
property
¶
The type of the update received by the channel.
checkpoint() -> Optional[C]
¶
Return a serializable representation of the channel's current state. Raises EmptyChannelError if the channel is empty (never updated yet), or doesn't support checkpoints.
Source code in libs/langgraph/langgraph/channels/base.py
consume() -> bool
¶
Mark the current value of the channel as consumed. By default, no-op. This is called by Pregel before the start of the next step, for all channels that triggered a node. If the channel was updated, return True.