Builder for directed graphs of node functions. Nodes are named R functions;
edges are fixed or conditional routing rules. Call $compile() to produce
an executable GraphRunner.
Use the pipe-friendly wrappers add_node(), add_edge(), and
add_conditional_edge() rather than $-methods directly.
Value
A new StateGraph object.
Invisibly, self (for chaining with |>).
Invisibly, self.
Invisibly, self.
Invisibly, self.
A GraphRunner object ready to execute.
Character string.
Character string.
Invisibly, path.
Methods
Method new()
Create a new StateGraph.
Usage
StateGraph$new(state_schema)Arguments
state_schemaA WorkflowState object, or a named list that will be passed to
workflow_state().
Method add_node()
Register a node function.
Method add_edge()
Add a fixed edge between two nodes.
Method add_conditional_edge()
Add a conditional (routing) edge.
Arguments
fromNode name. Must already be registered.
routing_fnFunction
function(state)returning a character key present inroute_map.route_mapNamed list mapping routing keys to node names or END.
Method compile()
Validate and compile the graph into a GraphRunner.
Usage
StateGraph$compile(
agents = list(),
checkpointer = NULL,
termination = NULL,
output_channel = NULL
)Arguments
agentsNamed list of
Agentobjects passed to node functions viaconfig$agents.checkpointerA Checkpointer object or
NULL.terminationA termination condition (from
max_turns()etc.) orNULL.output_channelCharacter or
NULL. The channel whose value is returned byWorkflowState$output(). IfNULL,$output()will error unless set by a workflow constructor.
Method visualize()
Render a visualization.
Usage
StateGraph$visualize(engine = c("dot", "visnetwork", "mermaid"))