pub struct GraphBuilder { /* private fields */ }Expand description
Builds a Graph.
Implementations§
Source§impl GraphBuilder
impl GraphBuilder
Sourcepub fn edge_if(
self,
from: impl Into<String>,
to: impl Into<String>,
condition: impl Fn(&GraphState) -> bool + WasmCompatSend + WasmCompatSync + 'static,
) -> Self
pub fn edge_if( self, from: impl Into<String>, to: impl Into<String>, condition: impl Fn(&GraphState) -> bool + WasmCompatSend + WasmCompatSync + 'static, ) -> Self
Run to after from when condition holds on the run so far.
let graph = Graph::builder()
.node("review", review)
.node("publish", publish)
.edge_if("review", "publish", |state: &GraphState| {
state.output("review").is_some_and(|verdict| verdict.contains("APPROVED"))
})
.build()?;Sourcepub fn entry(self, id: impl Into<String>) -> Self
pub fn entry(self, id: impl Into<String>) -> Self
Start the run with this node (call it again for several). Defaults to every node without incoming edges.
Sourcepub fn max_node_executions(self, max: usize) -> Self
pub fn max_node_executions(self, max: usize) -> Self
How many node runs, in all, a graph run may make. Required when the graph has a cycle; unbounded otherwise.
Sourcepub fn max_turns_per_agent(self, max_turns: usize) -> Self
pub fn max_turns_per_agent(self, max_turns: usize) -> Self
How many model calls one agent node’s run may make, counting the first
call and every follow-up after a tool call. An agent whose own
default_max_turns is higher keeps its own. Defaults to 8; zero fails
the build with BuildError::ZeroTurns. Nodes that are swarms or
functions are not affected.
Sourcepub fn execution_timeout(self, timeout: Duration) -> Self
pub fn execution_timeout(self, timeout: Duration) -> Self
How long a whole run may take. Defaults to 15 minutes.
Sourcepub fn node_timeout(self, timeout: Duration) -> Self
pub fn node_timeout(self, timeout: Duration) -> Self
How long one node may take. Defaults to 5 minutes.
Sourcepub fn checkpoints(
self,
store: impl AsyncStore + WasmCompatSend + WasmCompatSync + 'static,
) -> Self
pub fn checkpoints( self, store: impl AsyncStore + WasmCompatSend + WasmCompatSync + 'static, ) -> Self
Sourcepub fn build(self) -> Result<Graph, BuildError>
pub fn build(self) -> Result<Graph, BuildError>
Check the nodes and edges.
Auto Trait Implementations§
impl !RefUnwindSafe for GraphBuilder
impl !UnwindSafe for GraphBuilder
impl Forget for GraphBuilder
impl Freeze for GraphBuilderwhere
*const u8 is !null: Freeze,
PhantomData<(String, Box<dyn Node>)>: Freeze,
PhantomData<(String, String, Option<Arc<dyn Fn(&GraphState) -> bool + Sync + Send>>)>: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<dyn Files> is !null: Freeze,
PhantomData<ArcInner<dyn Files>>: Freeze,
&'static str: Freeze,
impl Move for GraphBuilder
impl Send for GraphBuilder
impl Sync for GraphBuilder
impl Unpin for GraphBuilder
impl UnsafeUnpin for GraphBuilderwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Box<dyn Node>)>: UnsafeUnpin,
PhantomData<(String, String, Option<Arc<dyn Fn(&GraphState) -> bool + Sync + Send>>)>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn Files> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Files>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
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