Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;

    // Provided method
    fn validate_args(&self, _args: &Value) -> Result<()> { ... }
}
Expand description

Core trait for all agent tools

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the tool with given arguments

Source

fn name(&self) -> &'static str

Get the tool’s name

Source

fn description(&self) -> &'static str

Get the tool’s description

Provided Methods§

Source

fn validate_args(&self, _args: &Value) -> Result<()>

Validate arguments before execution

Implementors§