pub struct ToolResult {
pub success: bool,
pub output: String,
}Expand description
The result of a tool execution.
Fields§
§success: boolWhether the execution was successful.
output: StringThe output of the execution.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(output: impl Into<String>) -> Self
pub fn success(output: impl Into<String>) -> Self
Creates a new successful ToolResult.
Examples found in repository?
examples/custom_tool.rs (line 69)
49 async fn execute(&self, args: Value) -> helios_engine::Result<ToolResult> {
50 let location = args
51 .get("location")
52 .and_then(|v| v.as_str())
53 .unwrap_or("Unknown");
54
55 let unit = args
56 .get("unit")
57 .and_then(|v| v.as_str())
58 .unwrap_or("fahrenheit");
59
60 // In a real implementation, you would call a weather API here.
61 let temp = if unit == "celsius" { "22" } else { "72" };
62 let weather = format!(
63 "The weather in {} is sunny with a temperature of {}°{}",
64 location,
65 temp,
66 if unit == "celsius" { "C" } else { "F" }
67 );
68
69 Ok(ToolResult::success(weather))
70 }Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
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 moreAuto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnwindSafe for ToolResult
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