pub struct ToolUseBlock { /* private fields */ }Expand description
Tool use request from the AI model.
When the model determines it needs to call a tool/function, it returns
a ToolUseBlock specifying which tool to call and with what parameters.
The application must then execute the tool and return results via
ToolResultBlock.
§Fields
id: Unique identifier for this tool call, used to correlate resultsname: Name of the tool to execute (must match a registered tool)input: JSON parameters to pass to the tool
§Example
use open_agent::{ToolUseBlock, ContentBlock};
use serde_json::json;
let block = ToolUseBlock::new(
"call_123",
"calculate",
json!({"expression": "2 + 2"})
);
assert_eq!(block.id(), "call_123");
assert_eq!(block.name(), "calculate");Implementations§
Source§impl ToolUseBlock
impl ToolUseBlock
Sourcepub fn new(id: impl Into<String>, name: impl Into<String>, input: Value) -> Self
pub fn new(id: impl Into<String>, name: impl Into<String>, input: Value) -> Self
Creates a new tool use block.
§Parameters
id: Unique identifier for this tool callname: Name of the tool to executeinput: JSON parameters for the tool
§Example
use open_agent::ToolUseBlock;
use serde_json::json;
let block = ToolUseBlock::new(
"call_abc",
"search",
json!({"query": "Rust async programming"})
);Trait Implementations§
Source§impl Clone for ToolUseBlock
impl Clone for ToolUseBlock
Source§fn clone(&self) -> ToolUseBlock
fn clone(&self) -> ToolUseBlock
Returns a duplicate of the value. Read more
1.0.0 · 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 ToolUseBlock
impl Debug for ToolUseBlock
Source§impl<'de> Deserialize<'de> for ToolUseBlock
impl<'de> Deserialize<'de> for ToolUseBlock
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
Auto Trait Implementations§
impl Freeze for ToolUseBlock
impl RefUnwindSafe for ToolUseBlock
impl Send for ToolUseBlock
impl Sync for ToolUseBlock
impl Unpin for ToolUseBlock
impl UnwindSafe for ToolUseBlock
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