pub struct ToolDefaults { /* private fields */ }Expand description
Per-tool default kwargs for LLM-generated tool calls.
Defaults are stored as JSON objects (serde_json::Map<String, Value>).
apply merges them into the caller-supplied args; caller-supplied keys win.
null is a real value — passing {"timeout": null} will NOT be replaced
by the registered default. To get the default, omit the key entirely.
Implementations§
Source§impl ToolDefaults
impl ToolDefaults
pub fn new() -> Self
Sourcepub fn register(&mut self, tool_name: impl Into<String>, defaults: Value)
pub fn register(&mut self, tool_name: impl Into<String>, defaults: Value)
Register (or overwrite) defaults for tool_name.
defaults must be a JSON object (Value::Object); panics otherwise.
Sourcepub fn register_many(&mut self, map: Value)
pub fn register_many(&mut self, map: Value)
Register multiple tools at once from a JSON object of objects.
Sourcepub fn update(&mut self, tool_name: impl Into<String>, extra: Value)
pub fn update(&mut self, tool_name: impl Into<String>, extra: Value)
Merge new defaults into an existing registration (or create one).
Sourcepub fn unregister(&mut self, tool_name: &str) -> bool
pub fn unregister(&mut self, tool_name: &str) -> bool
Drop a tool’s defaults. Returns true if it was registered.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Sorted list of registered tool names.
Sourcepub fn defaults_for(&self, tool_name: &str) -> Option<Map<String, Value>>
pub fn defaults_for(&self, tool_name: &str) -> Option<Map<String, Value>>
Copy of the defaults for tool_name.
pub fn contains(&self, tool_name: &str) -> bool
Sourcepub fn apply(
&self,
tool_name: &str,
args: &Value,
strict: bool,
) -> Result<Value, ToolNotRegisteredError>
pub fn apply( &self, tool_name: &str, args: &Value, strict: bool, ) -> Result<Value, ToolNotRegisteredError>
Merge defaults into args. Caller-supplied keys win.
args must be a JSON object or Value::Null (treated as empty).
Returns Err(ToolNotRegisteredError) if strict=true and tool not found.
If strict=false and tool not found, returns args unchanged.
Trait Implementations§
Source§impl Clone for ToolDefaults
impl Clone for ToolDefaults
Source§fn clone(&self) -> ToolDefaults
fn clone(&self) -> ToolDefaults
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more