pub struct Graph {
pub id: String,
pub name: String,
pub nodes: HashMap<String, GraphNode>,
pub edges: Vec<GraphEdge>,
pub entry_node: String,
pub config: GraphConfig,
pub checkpoint_store: Option<Arc<dyn CheckpointStore>>,
}Expand description
The main graph structure
Fields§
§id: StringGraph ID
name: StringGraph name
nodes: HashMap<String, GraphNode>Nodes in the graph
edges: Vec<GraphEdge>Edges in the graph
entry_node: StringEntry node ID
config: GraphConfigConfiguration
checkpoint_store: Option<Arc<dyn CheckpointStore>>Checkpoint store
Implementations§
Source§impl Graph
impl Graph
Sourcepub async fn invoke(
&self,
initial_state: GraphState,
) -> Result<GraphResult, CrewError>
pub async fn invoke( &self, initial_state: GraphState, ) -> Result<GraphResult, CrewError>
Execute the graph with initial state
Sourcepub async fn resume(
&self,
checkpoint_id: &str,
) -> Result<GraphResult, CrewError>
pub async fn resume( &self, checkpoint_id: &str, ) -> Result<GraphResult, CrewError>
Resume from a checkpoint
Sourcepub fn find_next_node(
&self,
current: &str,
state: &GraphState,
) -> Result<String, CrewError>
pub fn find_next_node( &self, current: &str, state: &GraphState, ) -> Result<String, CrewError>
Find the next node based on edges
Sourcepub fn stream(&self, initial_state: GraphState) -> GraphStream<'_>
pub fn stream(&self, initial_state: GraphState) -> GraphStream<'_>
Stream execution, yielding state after each node
Sourcepub fn to_mermaid(&self) -> String
pub fn to_mermaid(&self) -> String
Get a visual representation of the graph (Mermaid format)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl !RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl !UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more