pub struct Calculator;Expand description
Calculator tool
Evaluates math expressions. Supports: basic arithmetic (+, -, *, /, %), power (^), functions (sin, cos, tan, sqrt, log, exp, abs, …), and constants (pi, e).
Implementations§
Source§impl Calculator
impl Calculator
Trait Implementations§
Source§impl BaseTool for Calculator
Implement BaseTool trait (string version, for Agent)
impl BaseTool for Calculator
Implement BaseTool trait (string version, for Agent)
Source§fn description(&self) -> &str
fn description(&self) -> &str
Returns the tool description. Read more
Source§fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool (string version). Read more
Source§fn return_direct(&self) -> bool
fn return_direct(&self) -> bool
Whether to return result directly to user. Read more
Source§fn risk(&self) -> ToolRiskProfile
fn risk(&self) -> ToolRiskProfile
Declared Rule-of-Two risk profile (A2, v0.22.1). Read more
Source§impl Default for Calculator
impl Default for Calculator
Source§impl Tool for Calculator
Implement Tool trait (type-safe version)
impl Tool for Calculator
Implement Tool trait (type-safe version)
Source§type Input = CalculatorInput
type Input = CalculatorInput
Input type (must support deserialization and JSON Schema).
Source§type Output = CalculatorOutput
type Output = CalculatorOutput
Output type (must support serialization).
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool. Read more
Source§fn args_schema(&self) -> Option<Value>
fn args_schema(&self) -> Option<Value>
Returns the input JSON Schema.
Auto Trait Implementations§
impl Freeze for Calculator
impl RefUnwindSafe for Calculator
impl Send for Calculator
impl Sync for Calculator
impl Unpin for Calculator
impl UnsafeUnpin for Calculator
impl UnwindSafe for Calculator
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