pydantic_graph.basenode
Bases: Generic[StateT, DepsT]
Context for a graph.
The state of the graph.
Type: StateT
Dependencies for the graph.
Type: DepsT
Bases: ABC, Generic[StateT, DepsT, NodeRunEndT]
Base class for a node.
@abstractmethod
@async
def run(
ctx: GraphRunContext[StateT, DepsT],
) -> BaseNode[StateT, DepsT, Any] | End[NodeRunEndT]
Run the node.
This is an abstract method that must be implemented by subclasses.
BaseNode[StateT, DepsT, Any] | End[NodeRunEndT] — The next node to run or End to signal the end of the graph.
The graph context.
@cached
@classmethod
def get_node_id(cls) -> str
Get the ID of the node.
Bases: Generic[RunEndT]
Type to return from a node to signal the end of the graph.
Data to return from the graph.
Type: RunEndT
Annotation to apply a label to an edge in a graph.
Label for the edge.
Type variable for the state in a graph.
Default: TypeVar('StateT', default=object)
Type variable for the dependencies of a graph and node.
Default: TypeVar('DepsT', default=object, contravariant=True)
Covariant type variable for the return type of a graph run.
Default: TypeVar('RunEndT', covariant=True, default=object)
Covariant type variable for the return type of a node run.
Default: TypeVar('NodeRunEndT', covariant=True, default=Never)