pub trait Tool:
    Send
    + Sync
    + DynClone {
    // Required methods
    fn invoke<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        agent_context: &'life1 dyn AgentContext,
        raw_args: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn name(&self) -> Cow<'_, str>;
    fn tool_spec(&self) -> ToolSpec;
    // Provided method
    fn boxed<'a>(self) -> Box<dyn Tool + 'a>
       where Self: Sized + 'a { ... }
}Expand description
The Tool trait is the main interface for chat completion and agent tools.
swiftide-macros provides a set of macros to generate implementations of this trait. If you
need more control over the implementation, you can implement the trait manually.
The ToolSpec is what will end up with the LLM. A builder is provided. The name is expected
to be unique, and is used to identify the tool. It should be the same as the name in the
ToolSpec.
Required Methods§
fn invoke<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    agent_context: &'life1 dyn AgentContext,
    raw_args: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
fn name(&self) -> Cow<'_, str>
fn tool_spec(&self) -> ToolSpec
Provided Methods§
Trait Implementations§
Source§impl PartialEq for Box<dyn Tool>
Tools are identified and unique by name
These allow comparison and lookups
 
impl PartialEq for Box<dyn Tool>
Tools are identified and unique by name These allow comparison and lookups