pub struct StateGraph {
pub schema: StateSchema,
pub nodes: HashMap<String, Arc<dyn Node>>,
pub edges: Vec<Edge>,
}Expand description
Builder for constructing graphs
Fields§
§schema: StateSchemaState schema
nodes: HashMap<String, Arc<dyn Node>>Registered nodes
edges: Vec<Edge>Registered edges
Implementations§
Source§impl StateGraph
impl StateGraph
Sourcepub fn new(schema: StateSchema) -> Self
pub fn new(schema: StateSchema) -> Self
Create a new graph with the given state schema
Sourcepub fn with_channels(channels: &[&str]) -> Self
pub fn with_channels(channels: &[&str]) -> Self
Create with a simple schema (just channel names, all overwrite)
Sourcepub fn add_node_fn<F, Fut>(self, name: &str, func: F) -> Selfwhere
F: Fn(NodeContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<NodeOutput>> + Send + 'static,
pub fn add_node_fn<F, Fut>(self, name: &str, func: F) -> Selfwhere
F: Fn(NodeContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<NodeOutput>> + Send + 'static,
Add a function as a node
Sourcepub fn add_edge(self, source: &str, target: &str) -> Self
pub fn add_edge(self, source: &str, target: &str) -> Self
Add a direct edge from source to target
Sourcepub fn add_conditional_edges<F, I>(
self,
source: &str,
router: F,
targets: I,
) -> Self
pub fn add_conditional_edges<F, I>( self, source: &str, router: F, targets: I, ) -> Self
Add a conditional edge with a router function
Sourcepub fn add_conditional_edges_arc<I>(
self,
source: &str,
router: RouterFn,
targets: I,
) -> Self
pub fn add_conditional_edges_arc<I>( self, source: &str, router: RouterFn, targets: I, ) -> Self
Add a conditional edge with an Arc router (for pre-built routers)
Sourcepub fn compile(self) -> Result<CompiledGraph>
pub fn compile(self) -> Result<CompiledGraph>
Compile the graph for execution