pub struct StateGraph {
pub schema: StateSchema,
pub nodes: HashMap<String, Arc<dyn Node>>,
pub edges: Vec<Edge>,
}Available on crate feature
graph only.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) -> StateGraph
pub fn new(schema: StateSchema) -> StateGraph
Create a new graph with the given state schema
Sourcepub fn with_channels(channels: &[&str]) -> StateGraph
pub fn with_channels(channels: &[&str]) -> StateGraph
Create with a simple schema (just channel names, all overwrite)
Sourcepub fn add_node<N>(self, node: N) -> StateGraphwhere
N: Node + 'static,
pub fn add_node<N>(self, node: N) -> StateGraphwhere
N: Node + 'static,
Add a node to the graph
Sourcepub fn add_node_fn<F, Fut>(self, name: &str, func: F) -> StateGraphwhere
F: Fn(NodeContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<NodeOutput, GraphError>> + Send + 'static,
pub fn add_node_fn<F, Fut>(self, name: &str, func: F) -> StateGraphwhere
F: Fn(NodeContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<NodeOutput, GraphError>> + Send + 'static,
Add a function as a node
Sourcepub fn add_edge(self, source: &str, target: &str) -> StateGraph
pub fn add_edge(self, source: &str, target: &str) -> StateGraph
Add a direct edge from source to target
Sourcepub fn add_conditional_edges<F, I>(
self,
source: &str,
router: F,
targets: I,
) -> StateGraph
pub fn add_conditional_edges<F, I>( self, source: &str, router: F, targets: I, ) -> StateGraph
Add a conditional edge with a router function
Sourcepub fn add_conditional_edges_arc<I>(
self,
source: &str,
router: Arc<dyn Fn(&HashMap<String, Value>) -> String + Sync + Send>,
targets: I,
) -> StateGraph
pub fn add_conditional_edges_arc<I>( self, source: &str, router: Arc<dyn Fn(&HashMap<String, Value>) -> String + Sync + Send>, targets: I, ) -> StateGraph
Add a conditional edge with an Arc router (for pre-built routers)
Sourcepub fn compile(self) -> Result<CompiledGraph, GraphError>
pub fn compile(self) -> Result<CompiledGraph, GraphError>
Compile the graph for execution
Auto Trait Implementations§
impl Freeze for StateGraph
impl !RefUnwindSafe for StateGraph
impl Send for StateGraph
impl Sync for StateGraph
impl Unpin for StateGraph
impl !UnwindSafe for StateGraph
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request