GraphAgentBuilder

Struct GraphAgentBuilder 

Source
pub struct GraphAgentBuilder { /* private fields */ }
Expand description

Builder for GraphAgent

Implementations§

Source§

impl GraphAgentBuilder

Source

pub fn new(name: &str) -> Self

Create a new builder

Source

pub fn description(self, desc: &str) -> Self

Set description

Source

pub fn state_schema(self, schema: StateSchema) -> Self

Set state schema

Source

pub fn channels(self, channels: &[&str]) -> Self

Add channels to state schema

Source

pub fn node<N: Node + 'static>(self, node: N) -> Self

Add a node

Source

pub fn node_fn<F, Fut>(self, name: &str, func: F) -> Self
where F: Fn(NodeContext) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<NodeOutput>> + Send + 'static,

Add a function as a node

Source

pub fn edge(self, source: &str, target: &str) -> Self

Add a direct edge

Source

pub fn conditional_edge<F, I>(self, source: &str, router: F, targets: I) -> Self
where F: Fn(&State) -> String + Send + Sync + 'static, I: IntoIterator<Item = (&'static str, &'static str)>,

Add a conditional edge

Source

pub fn checkpointer<C: Checkpointer + 'static>(self, checkpointer: C) -> Self

Set checkpointer

Source

pub fn checkpointer_arc(self, checkpointer: Arc<dyn Checkpointer>) -> Self

Set checkpointer with Arc

Source

pub fn interrupt_before(self, nodes: &[&str]) -> Self

Set nodes to interrupt before

Source

pub fn interrupt_after(self, nodes: &[&str]) -> Self

Set nodes to interrupt after

Source

pub fn recursion_limit(self, limit: usize) -> Self

Set recursion limit

Source

pub fn input_mapper<F>(self, mapper: F) -> Self
where F: Fn(&dyn InvocationContext) -> State + Send + Sync + 'static,

Set custom input mapper

Source

pub fn output_mapper<F>(self, mapper: F) -> Self
where F: Fn(&State) -> Vec<Event> + Send + Sync + 'static,

Set custom output mapper

Source

pub fn before_agent_callback<F, Fut>(self, callback: F) -> Self
where F: Fn(Arc<dyn InvocationContext>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<()>> + Send + 'static,

Set before agent callback

Source

pub fn after_agent_callback<F, Fut>(self, callback: F) -> Self
where F: Fn(Arc<dyn InvocationContext>, Event) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<()>> + Send + 'static,

Set after agent callback

Note: The callback receives a cloned Event to avoid lifetime issues.

Source

pub fn build(self) -> Result<GraphAgent>

Build the GraphAgent

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.