pub struct Function {
pub name: String,
pub description: String,
pub parameters: Option<Value>,
}Expand description
Definition of a callable function tool.
This structure defines a function that can be called by the assistant, including its name, description, and parameter schema.
§Validation
name- Must be between 1 and 64 charactersparameters- Must be a valid JSON schema
Fields§
§name: StringThe name of the function. Must be between 1 and 64 characters.
description: StringA description of what the function does.
parameters: Option<Value>JSON schema describing the function’s parameters. Server expects an object; keep as Value to avoid double-encoding strings.
Implementations§
Source§impl Function
impl Function
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
Creates a new function call definition.
§Arguments
name- The name of the functiondescription- A description of what the function doesparameters- JSON schema string describing the function parameters
§Returns
A new Function instance.
§Examples
ⓘ
let func = Function::new(
"get_weather",
"Get current weather for a location",
r#"{"type": "object", "properties": {"location": {"type": "string"}}}"#
);Trait Implementations§
Source§impl<'v_a> ValidateArgs<'v_a> for Function
impl<'v_a> ValidateArgs<'v_a> for Function
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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