pub trait LlmTool: Send + Sync {
// Required methods
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 HashMap<String, Value>,
ctx: &'life2 ToolRunCtx,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn descriptor(&self) -> ToolDescriptor;
fn clone_box(&self) -> Box<dyn LlmTool>;
// Provided method
fn matches(&self, name: &str) -> bool { ... }
}Expand description
Trait for LLM tools.
2.0 change: run is now async and accepts an optional ToolRunCtx.
Existing tools that previously implemented sync run(&self, args) need to
be ported to the new signature. The minimal migration is to wrap the body
in async {} and add an unused _ctx parameter; see book/src/migration.md.
Required Methods§
Sourcefn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 HashMap<String, Value>,
ctx: &'life2 ToolRunCtx,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 HashMap<String, Value>,
ctx: &'life2 ToolRunCtx,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute the tool with given arguments.
Sourcefn descriptor(&self) -> ToolDescriptor
fn descriptor(&self) -> ToolDescriptor
Get tool descriptor for LLM
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".