docs: add Command/GraphCommand docs

This commit is contained in:
vbarda
2024-12-04 15:46:40 -05:00
parent 851e6d1d4c
commit 90eab07ded
8 changed files with 435 additions and 2 deletions
+12 -1
View File
@@ -86,7 +86,18 @@ def _get_node_name(node: RunnableLike) -> str:
@dataclasses.dataclass(**_DC_KWARGS)
class GraphCommand(Generic[N], Command[N]):
"""One or more commands to update a StateGraph's state and go to, or send messages to nodes."""
"""One or more commands to update a StateGraph's state and go to, or send messages to nodes.
Args:
goto: name of the node to navigate to next.
If not specified, the graph will halt after executing the current superstep.
graph: graph to send the command to. Supported values are:
- None: the current graph (default)
- GraphCommand.PARENT: closest parent graph
update: state update to apply to the graph's state at the current superstep.
send: list of `Send` objects to send to other nodes.
resume: value to resume execution with. Will be used when `interrupt()` is called.
"""
goto: Union[str, Sequence[str]] = ()
+10 -1
View File
@@ -239,7 +239,16 @@ N = TypeVar("N", bound=Hashable)
@dataclasses.dataclass(**_DC_KWARGS)
class Command(Generic[N]):
"""One or more commands to update the graph's state and send messages to nodes."""
"""One or more commands to update the graph's state and send messages to nodes.
Args:
graph: graph to send the command to. Supported values are:
- None: the current graph (default)
- GraphCommand.PARENT: closest parent graph
update: state update to apply to the graph's state at the current superstep.
send: list of `Send` objects to send to other nodes.
resume: value to resume execution with. Will be used when `interrupt()` is called.
"""
graph: Optional[str] = None
update: Optional[dict[str, Any]] = None