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(&self) -> Value;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        params: Value,
        ctx: ToolContext,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn extension_id(&self) -> Option<&str> { ... }
}
Expand description

The core trait for all tools. Implement this to add a new tool.

Required Methods§

Source

fn name(&self) -> &str

Tool name as it appears in the API (e.g. “bash”, “read”).

Source

fn description(&self) -> &str

Human-readable description sent to the model.

Source

fn parameters(&self) -> Value

JSON Schema for the tool’s parameters.

Source

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

Execute the tool with the given parameters.

Provided Methods§

Source

fn extension_id(&self) -> Option<&str>

Owning extension id for tools registered by an extension. Built-in tools return None.

Implementors§