pub struct SimpleTool { /* private fields */ }Expand description
Simple function tool that wraps an async closure.
Implementations§
Source§impl SimpleTool
impl SimpleTool
Sourcepub fn new<F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
parameters: Option<Value>,
handler: F,
) -> Self
pub fn new<F, Fut>( name: impl Into<String>, description: impl Into<String>, parameters: Option<Value>, handler: F, ) -> Self
Create a new simple function tool.
§Examples
ⓘ
use rs_adk::tool::SimpleTool;
use serde_json::json;
let tool = SimpleTool::new(
"greet",
"Greet a user by name",
Some(json!({"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]})),
|args| async move {
let name = args["name"].as_str().unwrap_or("World");
Ok(json!({"greeting": format!("Hello, {name}!")}))
},
);Trait Implementations§
Source§impl ToolFunction for SimpleTool
impl ToolFunction for SimpleTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what this tool does.
Source§fn parameters(&self) -> Option<Value>
fn parameters(&self) -> Option<Value>
JSON Schema for the tool’s input parameters, or
None if parameterless.Auto Trait Implementations§
impl Freeze for SimpleTool
impl !RefUnwindSafe for SimpleTool
impl Send for SimpleTool
impl Sync for SimpleTool
impl Unpin for SimpleTool
impl UnsafeUnpin for SimpleTool
impl !UnwindSafe for SimpleTool
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