pub struct Tool { /* private fields */ }Expand description
A tool the program runs (R8.4.1): a name, a description, an input schema sent to the model as given, whether it asks before every call, how long harness waits for it, and an async handler.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new<T, E, F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
schema: Value,
handler: F,
) -> Selfwhere
T: DeserializeOwned + Send + 'static,
E: Display + 'static,
F: Fn(T, ToolContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ToolOutput, E>> + Send + 'static,
pub fn new<T, E, F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
schema: Value,
handler: F,
) -> Selfwhere
T: DeserializeOwned + Send + 'static,
E: Display + 'static,
F: Fn(T, ToolContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ToolOutput, E>> + Send + 'static,
A tool whose calls run handler with the model’s arguments as a T.
Before the handler runs, the arguments are checked against the
schema’s top-level required, each property’s type and
additionalProperties: false, then deserialized; a call that fails
either, an Err, or a panic answers is_error with the reason.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tool
impl !UnwindSafe for Tool
impl Freeze for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnsafeUnpin for Tool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more