pub enum ToolMode {
Auto,
Required(Option<String>),
None,
}Expand description
If and how tools may be used for a request. Mirrors the Python ToolMode.
The four modes are Auto, “required any” (ToolMode::required_any, i.e.
Required(None)), a specific required function
(ToolMode::required_function, i.e. Required(Some(name))), and None
(tools disabled). Like Python’s serialize_model, serialization emits only
the mode string; the specific function name is applied by the provider
mapping, not persisted on the mode itself.
Variants§
Auto
The model decides whether to call tools.
Required(Option<String>)
The model must call a tool; optionally a specific named function.
None
Tools are disabled.
Implementations§
Source§impl ToolMode
impl ToolMode
Sourcepub fn required(function_name: Option<String>) -> ToolMode
pub fn required(function_name: Option<String>) -> ToolMode
Construct a Required mode, optionally pinning a specific function.
Sourcepub fn required_any() -> ToolMode
pub fn required_any() -> ToolMode
The model must call some tool, but any tool is acceptable.
Sourcepub fn required_function(function_name: impl Into<String>) -> ToolMode
pub fn required_function(function_name: impl Into<String>) -> ToolMode
The model must call the named function.
Sourcepub fn required_function_name(&self) -> Option<&str>
pub fn required_function_name(&self) -> Option<&str>
The specific function name pinned by a Required mode, if any.