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>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn to_definition(&self) -> ToolDefinition { ... }
}
Expand description

Trait for implementing tools

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>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes the tool with the given arguments

Provided Methods§

Source

fn to_definition(&self) -> ToolDefinition

Convert to ToolDefinition

Implementors§