pub enum ToolChoice {
Auto,
None,
Required,
Tool(String),
}Expand description
How the model should route tool selection for the current turn.
Mapped to each provider’s wire field by chat_request_body:
| variant | OpenAI | Anthropic |
|---|---|---|
Auto | "auto" (or omitted) | {"type":"auto"} (or omitted) |
None | "none" — model MUST NOT call a tool | (degrades: tools field dropped) |
Required | "required" — model MUST call at least one tool | {"type":"any"} |
Tool(name) | {"type":"function","function":{"name":name}} — forced | {"type":"tool","name":name} |
The None variant has no direct Anthropic equivalent — Anthropic
forces tool consideration whenever tools is non-empty. We
approximate it by dropping the tools field entirely for that turn;
the model can’t call what it doesn’t know about.
Variants§
Implementations§
Trait Implementations§
Source§impl Clone for ToolChoice
impl Clone for ToolChoice
Source§fn clone(&self) -> ToolChoice
fn clone(&self) -> ToolChoice
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 ToolChoice
impl Debug for ToolChoice
Source§impl Default for ToolChoice
impl Default for ToolChoice
Source§fn default() -> ToolChoice
fn default() -> ToolChoice
Returns the “default value” for a type. Read more
Source§impl PartialEq for ToolChoice
impl PartialEq for ToolChoice
Source§fn eq(&self, other: &ToolChoice) -> bool
fn eq(&self, other: &ToolChoice) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ToolChoice
Auto Trait Implementations§
impl Freeze for ToolChoice
impl RefUnwindSafe for ToolChoice
impl Send for ToolChoice
impl Sync for ToolChoice
impl Unpin for ToolChoice
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more