pub struct ToolCall {
pub id: String,
pub name: String,
pub arguments: String,
}Expand description
A tool/function call requested by a model, the same shape for every provider (OpenAI, Claude, Ollama, Bedrock, …).
arguments is the raw JSON string produced by the model; only the tool knows how to
interpret it. Serializes to the OpenAI wire format
({"id","type":"function","function":{"name","arguments"}}), which is also what
Message::tool_calls holds.
Fields§
§id: String§name: String§arguments: StringImplementations§
Source§impl ToolCall
impl ToolCall
pub fn new( id: impl Into<String>, name: impl Into<String>, arguments: impl Into<String>, ) -> Self
Sourcepub fn from_value(
id: impl Into<String>,
name: impl Into<String>,
arguments: &Value,
) -> Self
pub fn from_value( id: impl Into<String>, name: impl Into<String>, arguments: &Value, ) -> Self
Builds a call from structured arguments (what Claude, Ollama and Bedrock return).
Sourcepub fn arguments_value(&self) -> Value
pub fn arguments_value(&self) -> Value
The arguments as a JSON object, for providers that take tool input as an object
(Anthropic, Ollama, Bedrock). Non-object JSON or plain text is wrapped as
{"input": ...}, and empty arguments become {}.
Sourcepub fn parse_list(s: &str) -> Option<Vec<ToolCall>>
pub fn parse_list(s: &str) -> Option<Vec<ToolCall>>
Parses an OpenAI-style JSON array of tool calls (e.g. a generation string from an
LLM that encodes tool calls as text). Returns None if it is not one.
Sourcepub fn list_to_string(calls: &[ToolCall]) -> String
pub fn list_to_string(calls: &[ToolCall]) -> String
Serializes a list of calls to the OpenAI-style JSON array.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolCall
impl<'de> Deserialize<'de> for ToolCall
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for ToolCall
Source§impl From<FunctionCallResponse> for ToolCall
impl From<FunctionCallResponse> for ToolCall
Source§fn from(r: FunctionCallResponse) -> Self
fn from(r: FunctionCallResponse) -> Self
Source§impl From<ToolCall> for FunctionCallResponse
impl From<ToolCall> for FunctionCallResponse
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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