pub struct FunctionDefinition {
pub name: String,
pub description: String,
pub parameters: Value,
}Expand description
JSON-Schema-based description of a tool the LLM may call.
Pass a slice of FunctionDefinitions to
Llm::generate_with_tools to enable
native function calling instead of text-based ReAct parsing.
§Example
use rune_chain_core::FunctionDefinition;
use serde_json::json;
let def = FunctionDefinition::new(
"get_weather",
"Return the current weather for a city.",
json!({
"type": "object",
"properties": {
"city": { "type": "string", "description": "City name" }
},
"required": ["city"]
}),
);Fields§
§name: StringUnique tool name (no spaces; matches Tool::name).
description: StringOne-sentence description the LLM uses to decide when to call this tool.
parameters: ValueJSON Schema object describing the tool’s parameter object.
Implementations§
Source§impl FunctionDefinition
impl FunctionDefinition
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
Create a new function definition.
Sourcepub fn single_input(
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn single_input( name: impl Into<String>, description: impl Into<String>, ) -> Self
Build a definition with the standard single-string "input" parameter.
Use this as a quick wrapper for tools that accept a plain string.
§Example
use rune_chain_core::FunctionDefinition;
let def = FunctionDefinition::single_input(
"upper_case",
"Convert a string to upper case.",
);Trait Implementations§
Source§impl Clone for FunctionDefinition
impl Clone for FunctionDefinition
Source§fn clone(&self) -> FunctionDefinition
fn clone(&self) -> FunctionDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FunctionDefinition
impl Debug for FunctionDefinition
Source§impl<'de> Deserialize<'de> for FunctionDefinition
impl<'de> Deserialize<'de> for FunctionDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FunctionDefinition
impl RefUnwindSafe for FunctionDefinition
impl Send for FunctionDefinition
impl Sync for FunctionDefinition
impl Unpin for FunctionDefinition
impl UnsafeUnpin for FunctionDefinition
impl UnwindSafe for FunctionDefinition
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