pub trait Handler:
Send
+ Sync
+ 'static {
type Input: DeserializeOwned + JsonSchema + Send + 'static;
type Output: Serialize + JsonSchema + Send + 'static;
type Error: Into<Error> + Send + 'static;
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn execute<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
context: Context,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn display_name(&self) -> Option<&str> { ... }
fn hints(&self) -> Hints { ... }
}Expand description
Implemented by one typed tool inside an advanced capability.
Input values are deserialized after the model calls the tool. Output values
are serialized as JSON without a String intermediary. Both types also
provide schemas, allowing hosts and documentation to inspect the full
protocol even though the current model protocol consumes only the input
schema.
Required Associated Types§
Sourcetype Input: DeserializeOwned + JsonSchema + Send + 'static
type Input: DeserializeOwned + JsonSchema + Send + 'static
Typed tool arguments.
Sourcetype Output: Serialize + JsonSchema + Send + 'static
type Output: Serialize + JsonSchema + Send + 'static
Typed, JSON-serializable tool result.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Model-facing description of when and how to use the tool.
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
context: Context,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
context: Context,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute one call.
Awaited work is cancelled by dropping this future when the turn stops.
Use Context::cancellation for child tasks or resources that can
outlive this future, and Context::progress for correlated status.
Provided Methods§
Sourcefn display_name(&self) -> Option<&str>
fn display_name(&self) -> Option<&str>
Optional human-readable display name for clients.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".