Skip to main content

Tool

Trait Tool 

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

The core Tool trait. Each tool implements this.

Required Methods§

Source

fn name(&self) -> &str

Tool name (must match the ToolSpec name)

Source

fn spec(&self) -> ToolSpec

Get the tool specification for LLM function calling

Source

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

Execute the tool with the given arguments (JSON string)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§