pub struct ToolCall {
pub id: CallId,
pub function: ToolFunction,
pub native: Option<Native>,
}Expand description
A tool call: its id, and the function and arguments requested.
Fields§
§id: CallIdThe call’s one identity: the provider’s id, or one rig issued when the provider sent none.
function: ToolFunctionFunction name and JSON arguments requested by the model.
native: Option<Native>The provider item this call was decoded from.
Implementations§
Source§impl ToolCall
impl ToolCall
Sourcepub fn new(id: CallId, function: ToolFunction) -> ToolCall
pub fn new(id: CallId, function: ToolFunction) -> ToolCall
A call with id and no provider item.
Sourcepub fn from_wire(wire_id: impl Into<String>, function: ToolFunction) -> ToolCall
pub fn from_wire(wire_id: impl Into<String>, function: ToolFunction) -> ToolCall
A call the provider identified by wire_id; rig issues an id when it
is empty.
Sourcepub fn result(&self, content: Vec<ToolResultContent>) -> ToolResult
pub fn result(&self, content: Vec<ToolResultContent>) -> ToolResult
The result answering this call: its id and name, and content.
Sourcepub fn answer(&self, result: &ToolResult) -> ToolResult
pub fn answer(&self, result: &ToolResult) -> ToolResult
The result answering this call with what its tool did: the output the model reads, an error result for anything but a success.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolCall
impl<'de> Deserialize<'de> for ToolCall
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolCall, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ToolCall
impl Serialize for ToolCall
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ToolCall
Auto Trait Implementations§
impl Freeze for ToolCall
impl RefUnwindSafe for ToolCall
impl Send for ToolCall
impl Sync for ToolCall
impl Unpin for ToolCall
impl UnsafeUnpin for ToolCall
impl UnwindSafe for ToolCall
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> 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> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Convert this value without routing structured data through a string.