Expand description
A tool’s parameters derived from its arguments type, so the schema the model sees and the type its arguments are parsed into cannot disagree:
use schemars::JsonSchema;
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
struct Args {
/// How many lines to read.
limit: Option<u32>,
}
let schema = rig_core::tool::args_schema::<Args>();
let limit = serde_json::json!({"type": "integer", "minimum": 0,
"description": "How many lines to read."});
assert_eq!(schema["properties"]["limit"], limit);
assert_eq!(schema["additionalProperties"], false);Functions§
- args_
schema - The JSON schema of the arguments type
A, in the plain shape tool definitions use: inline, without$schema,title,default,format(providers support it unevenly) or the type’s own doc comment, and withOptionfields optional, not nullable (nonulltype, enum value oranyOfalternative), and each object refusing keys it does not declare (additionalProperties: false, asdeny_unknown_fieldssays; a map keeps its own).