pub struct ToolCall {
pub id: String,
pub name: String,
pub arguments: JsonValue,
}Expand description
A tool invocation a model emitted: a call id, a tool name, and a JSON arguments object.
Fields§
§id: String§name: String§arguments: JsonValueImplementations§
Source§impl ToolCall
impl ToolCall
Sourcepub fn new(name: impl Into<String>, arguments: JsonValue) -> Self
pub fn new(name: impl Into<String>, arguments: JsonValue) -> Self
A call with a freshly generated id.
Sourcepub fn with_id(
id: impl Into<String>,
name: impl Into<String>,
arguments: JsonValue,
) -> Self
pub fn with_id( id: impl Into<String>, name: impl Into<String>, arguments: JsonValue, ) -> Self
A call with an explicit id.
Sourcepub fn payload_value(&self) -> JsonValue
pub fn payload_value(&self) -> JsonValue
The {id, name, arguments} payload form.
Sourcepub fn from_payload(value: &JsonValue) -> Option<Self>
pub fn from_payload(value: &JsonValue) -> Option<Self>
Parse a call from its payload form. Requires a name and an object
arguments (defaulting to {}); a fresh id is minted if none is given.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolCall
impl<'de> Deserialize<'de> for ToolCall
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>,
Deserialize this value from the given Serde deserializer. 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