pub struct FnTool<A, F> { /* private fields */ }Expand description
A Tool built from a closure.
#[derive(Instructor, Serialize, Deserialize)]
struct WeatherArgs {
#[llm(description = "City name")]
city: String,
}
let tool = FnTool::new("get_weather", "Get the current weather for a city", |args: WeatherArgs| async move {
Ok(json!({ "city": args.city, "temp_f": 72 }))
});
let toolbox = Toolbox::new().with(tool);Implementations§
Trait Implementations§
Source§impl<A, F, Fut> Tool for FnTool<A, F>where
A: Instructor + DeserializeOwned + Send + 'static,
F: Fn(A) -> Fut + Send + Sync,
Fut: Future<Output = Result<Value>> + Send,
impl<A, F, Fut> Tool for FnTool<A, F>where
A: Instructor + DeserializeOwned + Send + 'static,
F: Fn(A) -> Fut + Send + Sync,
Fut: Future<Output = Result<Value>> + Send,
Auto Trait Implementations§
impl<A, F> Freeze for FnTool<A, F>where
F: Freeze,
impl<A, F> RefUnwindSafe for FnTool<A, F>where
F: RefUnwindSafe,
impl<A, F> Send for FnTool<A, F>where
F: Send,
impl<A, F> Sync for FnTool<A, F>where
F: Sync,
impl<A, F> Unpin for FnTool<A, F>where
F: Unpin,
impl<A, F> UnsafeUnpin for FnTool<A, F>where
F: UnsafeUnpin,
impl<A, F> UnwindSafe for FnTool<A, F>where
F: UnwindSafe,
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
Source§impl<T> DynTool for Twhere
T: Tool,
impl<T> DynTool for Twhere
T: Tool,
Source§fn description(&self) -> String
fn description(&self) -> String
The tool description.
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
The canonical JSON Schema for the tool’s arguments. Read more