pub enum ToolChoice {
Auto,
None,
Any,
Specific(SpecificToolChoice),
}
Expand description
Tool choice configuration that works across different providers Based on OpenAI, Anthropic, and Gemini API specifications Follows Anthropic’s tool use best practices for optimal performance
Variants§
Auto
Let the model decide whether to call tools (“auto”) Default behavior - allows model to use tools when appropriate
None
Force the model to not call any tools (“none”) Useful for pure conversational responses without tool usage
Any
Force the model to call at least one tool (“any”) Ensures tool usage even when model might prefer direct response
Specific(SpecificToolChoice)
Force the model to call a specific tool Useful for directing model to use particular functionality
Implementations§
Source§impl ToolChoice
impl ToolChoice
Sourcepub fn allows_parallel_tools(&self) -> bool
pub fn allows_parallel_tools(&self) -> bool
Check if this tool choice allows parallel tool use Based on Anthropic’s parallel tool use guidelines
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Get human-readable description of tool choice behavior
Sourcepub fn to_provider_format(&self, provider: &str) -> Value
pub fn to_provider_format(&self, provider: &str) -> Value
Convert to provider-specific format
Trait Implementations§
Source§impl Clone for ToolChoice
impl Clone for ToolChoice
Source§fn clone(&self) -> ToolChoice
fn clone(&self) -> ToolChoice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more