pub struct ToolSchema {
pub name: String,
pub description: String,
pub parameters: Value,
}Expand description
A function the model may call, described with JSON Schema.
Fields§
§name: String§description: String§parameters: ValueA JSON Schema object describing the arguments.
Implementations§
Source§impl ToolSchema
impl ToolSchema
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, parameters: Value, ) -> Self
Examples found in repository?
examples/tools.rs (lines 15-26)
14fn schemas() -> Vec<ToolSchema> {
15 vec![ToolSchema::new(
16 "distance_km",
17 "Straight-line distance between two cities, in kilometres.",
18 json!({
19 "type": "object",
20 "properties": {
21 "from": { "type": "string" },
22 "to": { "type": "string" },
23 },
24 "required": ["from", "to"],
25 }),
26 )]
27}More examples
examples/agent.rs (lines 14-25)
13 fn schemas(&self) -> Vec<ToolSchema> {
14 vec![ToolSchema::new(
15 "add",
16 "Add two numbers and return the sum.",
17 json!({
18 "type": "object",
19 "properties": {
20 "a": { "type": "number" },
21 "b": { "type": "number" },
22 },
23 "required": ["a", "b"],
24 }),
25 )]
26 }Trait Implementations§
Source§impl Clone for ToolSchema
impl Clone for ToolSchema
Source§impl Debug for ToolSchema
impl Debug for ToolSchema
Source§impl PartialEq for ToolSchema
impl PartialEq for ToolSchema
impl StructuralPartialEq for ToolSchema
Auto Trait Implementations§
impl Freeze for ToolSchema
impl RefUnwindSafe for ToolSchema
impl Send for ToolSchema
impl Sync for ToolSchema
impl Unpin for ToolSchema
impl UnsafeUnpin for ToolSchema
impl UnwindSafe for ToolSchema
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