Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn input_schema(&self) -> Value;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: Value,
        ctx: &'life1 ToolContext,
    ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn permission_level(&self) -> PermissionLevel { ... }
    fn category(&self) -> ToolCategory { ... }
    fn to_definition(&self) -> ToolDefinition { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Tool name (used by the model to invoke it).

Source

fn description(&self) -> &str

Human-readable description shown to the model.

Source

fn input_schema(&self) -> Value

JSON Schema for the tool’s input parameters.

Source

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

Execute the tool with the given JSON input.

Provided Methods§

Source

fn permission_level(&self) -> PermissionLevel

Permission level required for this tool.

Source

fn category(&self) -> ToolCategory

Category for grouping in tool listings.

Source

fn to_definition(&self) -> ToolDefinition

Convert to a ToolDefinition for the provider.

Implementors§