Tool

Trait Tool 

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

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

A trait for tools that can be used by agents.

Required Methods§

Source

fn name(&self) -> &str

The name of the tool.

Source

fn description(&self) -> &str

A description of the tool.

Source

fn parameters(&self) -> HashMap<String, ToolParameter>

The parameters for the tool.

Source

fn execute<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + 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

Converts the tool to a ToolDefinition.

Implementors§