pub struct PayloadNode { /* private fields */ }Expand description
A node that wraps a Payload for execution within the graph.
input_selector extracts what to pass to the payload from graph state.
output_mapper folds the payload output back into graph state.
Defaults: pass entire state as input; replace entire state with output.value.
Implementations§
Source§impl PayloadNode
impl PayloadNode
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set a name for this node (for debugging and events).
Sourcepub fn with_input_selector(
self,
selector: impl Fn(&Value) -> Value + Send + Sync + 'static,
) -> Self
pub fn with_input_selector( self, selector: impl Fn(&Value) -> Value + Send + Sync + 'static, ) -> Self
Set the input selector function.
Receives the entire state as a JSON value and returns the value
to pass to the payload’s invoke method.
Sourcepub fn with_output_mapper(
self,
mapper: impl Fn(&Value, &PayloadOutput) -> Value + Send + Sync + 'static,
) -> Self
pub fn with_output_mapper( self, mapper: impl Fn(&Value, &PayloadOutput) -> Value + Send + Sync + 'static, ) -> Self
Set the output mapper function.
Receives the current state and the payload output, returns the new state.
Trait Implementations§
Source§impl Debug for PayloadNode
impl Debug for PayloadNode
Source§impl Node for PayloadNode
impl Node for PayloadNode
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 AgentState,
_config: &'life2 GraphConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 AgentState,
_config: &'life2 GraphConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute this node
Auto Trait Implementations§
impl !RefUnwindSafe for PayloadNode
impl !UnwindSafe for PayloadNode
impl Freeze for PayloadNode
impl Send for PayloadNode
impl Sync for PayloadNode
impl Unpin for PayloadNode
impl UnsafeUnpin for PayloadNode
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