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

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

Required Methods§

Source

fn name(&self) -> &str

Machine-readable tool name (e.g. “echo”).

Source

fn description(&self) -> &str

Human-readable description the LLM uses to decide when to call this tool.

Source

fn parameters_schema(&self) -> Value

JSON Schema describing the parameters this tool accepts.

Source

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

Execute the tool with the given JSON arguments.

Provided Methods§

Source

fn to_definition(&self) -> ToolDefinition

Build a llm_cascade::ToolDefinition that can be passed to the model.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§