Skip to main content

Tool

Trait Tool 

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

Trait for implementing tools that agents can invoke.

Tools provide specific capabilities to agents, such as calculations, web searches, or API calls.

Required Methods§

Source

fn name(&self) -> &str

Returns the unique name of this tool.

Source

fn description(&self) -> &str

Returns a description of what this tool does.

Source

fn parameters_schema(&self) -> Value

Returns the JSON schema for this tool’s parameters.

Source

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

Executes the tool with the given arguments.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§