pub struct AgentNode { /* private fields */ }Expand description
Wrapper to use an existing ADK Agent as a graph node
Implementations§
Source§impl AgentNode
impl AgentNode
Sourcepub fn with_input_mapper<F>(self, mapper: F) -> Self
pub fn with_input_mapper<F>(self, mapper: F) -> Self
Set custom input mapper
Sourcepub fn with_output_mapper<F>(self, mapper: F) -> Self
pub fn with_output_mapper<F>(self, mapper: F) -> Self
Set custom output mapper
Sourcepub fn with_goto_mapper<F>(self, mapper: F) -> Self
pub fn with_goto_mapper<F>(self, mapper: F) -> Self
Chooses this node’s successors from the updates the output mapper produced.
An agent’s answer often decides where control goes next. The output mapper turns the agent’s events into state; this turns that state into a route, so the classification is parsed once.
Returning None leaves the declared edges in charge. Returning targets
replaces them, exactly as NodeOutput::with_goto does for a plain node.
§Example
node.with_goto_mapper(|updates: &HashMap<String, serde_json::Value>| {
match updates.get("category").and_then(|v| v.as_str()) {
Some("refund") => Some(vec!["refund_desk".to_string()]),
Some(_) => Some(vec!["general_desk".to_string()]),
None => None,
}
})Trait Implementations§
Source§impl Node for AgentNode
impl Node for AgentNode
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the node and return state updates
Source§fn execute_stream<'a>(
&'a self,
ctx: &'a NodeContext,
) -> Pin<Box<dyn Stream<Item = Result<StreamEvent>> + Send + 'a>>
fn execute_stream<'a>( &'a self, ctx: &'a NodeContext, ) -> Pin<Box<dyn Stream<Item = Result<StreamEvent>> + Send + 'a>>
Streams execution events for this node. Read more
Source§fn validate_against(&self, _parent: &StateSchema) -> Result<()>
fn validate_against(&self, _parent: &StateSchema) -> Result<()>
Rejects a node that cannot execute, before the graph runs. Read more
fn validate(&self) -> Result<()>
Auto Trait Implementations§
impl !RefUnwindSafe for AgentNode
impl !UnwindSafe for AgentNode
impl Freeze for AgentNode
impl Send for AgentNode
impl Sync for AgentNode
impl Unpin for AgentNode
impl UnsafeUnpin for AgentNode
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