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 moreSource§impl Debug for ToolChoice
impl Debug for ToolChoice
Source§impl<'de> Deserialize<'de> for ToolChoice
impl<'de> Deserialize<'de> for ToolChoice
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>,
Auto Trait Implementations§
impl Freeze for ToolChoice
impl RefUnwindSafe for ToolChoice
impl Send for ToolChoice
impl Sync for ToolChoice
impl Unpin for ToolChoice
impl UnwindSafe for ToolChoice
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more