pub struct CalculatorTool;Expand description
Calculator tool for evaluating mathematical expressions.
Uses the meval crate to evaluate expressions. Supports arithmetic,
power, trigonometric, and logarithmic functions.
§Example
ⓘ
use synaptic_tools::CalculatorTool;
use synaptic_core::Tool;
let tool = CalculatorTool;
let result = tool.call(serde_json::json!({"expression": "2 + 3 * 4"})).await?;
assert_eq!(result["result"], 14.0);Trait Implementations§
Source§impl Default for CalculatorTool
impl Default for CalculatorTool
Source§impl Tool for CalculatorTool
impl Tool for CalculatorTool
fn name(&self) -> &'static str
fn description(&self) -> &'static str
fn parameters(&self) -> Option<Value>
fn call<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, SynapticError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn as_tool_definition(&self) -> ToolDefinition
Auto Trait Implementations§
impl Freeze for CalculatorTool
impl RefUnwindSafe for CalculatorTool
impl Send for CalculatorTool
impl Sync for CalculatorTool
impl Unpin for CalculatorTool
impl UnsafeUnpin for CalculatorTool
impl UnwindSafe for CalculatorTool
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