pub struct ToolCall {
pub id: String,
pub name: String,
pub arguments: Value,
}Expand description
A tool call generated by the LLM.
When the LLM decides to use a tool, it generates a ToolCall with:
- A unique ID to match with the response
- The tool name to invoke
- Arguments parsed from the conversation
Your application should:
- Execute the tool with the provided arguments
- Return a
ToolResultwith the matchingtool_call_id - Continue the conversation so the LLM can use the result
§Example
use multi_llm::ToolCall;
// Received from LLM response
let call = ToolCall {
id: "call_abc123".to_string(),
name: "get_weather".to_string(),
arguments: serde_json::json!({"city": "Paris", "units": "celsius"}),
};
// Parse and execute
let city = call.arguments["city"].as_str().unwrap();
// ... execute weather lookup ...Fields§
§id: StringUnique identifier for this tool call (generated by the LLM).
Use this ID when returning the ToolResult to match the response
with the original call.
name: StringName of the tool to call.
Must match a Tool::name from the request’s tool list.
arguments: ValueArguments to pass to the tool as JSON.
Structure matches the parameters schema defined in the Tool.
May be an empty object {} if the tool has no required parameters.
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 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