Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn spec(&self) -> &ToolSpec;
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: Value,
        ctx: &'life1 ToolCtx,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn timeout(&self) -> Option<Duration> { ... }
}

Required Methods§

Source

fn spec(&self) -> &ToolSpec

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, input: Value, ctx: &'life1 ToolCtx, ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Source

fn timeout(&self) -> Option<Duration>

Overrides the agent’s default tool timeout for this tool.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<I, O, F, Fut> Tool for FnTool<I, O, F>
where I: DeserializeOwned + JsonSchema + Send + 'static, O: Serialize + Send + 'static, F: Fn(I, ToolCtx) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<O, ToolError>> + Send + 'static,