pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Value;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer2Result<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn validate_args(&self, _args: &Value) -> Layer2Result<bool> { ... }
}Expand description
工具接口
所有工具必须实现此接口。
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
获取工具描述
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
获取参数 schema
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer2Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer2Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
执行工具
Provided Methods§
Sourcefn validate_args(&self, _args: &Value) -> Layer2Result<bool>
fn validate_args(&self, _args: &Value) -> Layer2Result<bool>
验证参数
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".