pub fn tool<I, O, F, Fut>(
name: &str,
description: &str,
effect: Effect,
f: F,
) -> FnTool<I, O, F>Expand description
Builds a typed tool from an async function. The JSON schema shown to the
model is derived from I, and model input is validated against it.
ⓘ
#[derive(Deserialize, JsonSchema)]
struct GetOrder { order_id: String }
let get_order = tool("get_order", "Look up an order", Effect::Read,
|i: GetOrder, _ctx| async move { Ok(json!({"id": i.order_id})) });