pub struct ToolUse {
pub name: String,
pub args: Value,
pub expected_response: Option<Value>,
}Expand description
A tool use (function call)
Fields§
§name: StringTool/function name
args: ValueArguments passed to the tool.
In an expected tool use, Value::Null (the value when args is omitted from a
test file) places no constraint on the actual arguments.
expected_response: Option<Value>Expected response (optional, for mocking)
Implementations§
Source§impl ToolUse
impl ToolUse
Sourcepub fn matches(&self, other: &ToolUse, strict_args: bool) -> bool
pub fn matches(&self, other: &ToolUse, strict_args: bool) -> bool
Checks whether other, an actual tool call, satisfies this expected tool use.
Names must be equal. Expected arguments of Value::Null match any arguments.
Otherwise arguments are compared recursively, and numbers compare by value, so
1 matches 1.0.
strict_args | Objects | Arrays |
|---|---|---|
false | every expected key is present with a matching value; extra keys are allowed at any depth | same length, matched element by element |
true | same key set, values matched recursively | same length, matched element by element |
§Example
use adk_eval::ToolUse;
use serde_json::json;
let expected = ToolUse::new("search").with_args(json!({"filter": {"limit": 10}}));
let actual = ToolUse::new("search")
.with_args(json!({"query": "rust", "filter": {"limit": 10.0, "page": 2}}));
assert!(expected.matches(&actual, false));
assert!(!expected.matches(&actual, true));Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolUse
impl<'de> Deserialize<'de> for ToolUse
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 Forget for ToolUse
impl Freeze for ToolUsewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
impl Move for ToolUse
impl RefUnwindSafe for ToolUse
impl Send for ToolUse
impl Sync for ToolUse
impl Unpin for ToolUse
impl UnsafeUnpin for ToolUsewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
impl UnwindSafe for ToolUse
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