pub struct ToolResult {
pub success: bool,
pub output: String,
}Fields§
§success: bool§output: StringImplementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(output: impl Into<String>) -> Self
pub fn success(output: impl Into<String>) -> Self
Examples found in repository?
examples/custom_tool.rs (line 60)
40 async fn execute(&self, args: Value) -> helios_engine::Result<ToolResult> {
41 let location = args
42 .get("location")
43 .and_then(|v| v.as_str())
44 .unwrap_or("Unknown");
45
46 let unit = args
47 .get("unit")
48 .and_then(|v| v.as_str())
49 .unwrap_or("fahrenheit");
50
51 // Simulate weather data (in a real implementation, call a weather API)
52 let temp = if unit == "celsius" { "22" } else { "72" };
53 let weather = format!(
54 "The weather in {} is sunny with a temperature of {}°{}",
55 location,
56 temp,
57 if unit == "celsius" { "C" } else { "F" }
58 );
59
60 Ok(ToolResult::success(weather))
61 }pub fn error(message: impl Into<String>) -> Self
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