File size: 551 Bytes
54f968b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from smolagents import Tool
from typing import Any, Optional

class SimpleTool(Tool):
    name = "calculator"
    description = "Calculate the result of the expression."
    inputs = {"expr":{"type":"string","description":"The math expression to calculate."}}
    output_type = "string"

    def forward(self, expr: str) -> str:
        """
        Calculate the result of the expression.
        Args:
            expr: The math expression to calculate.
        Returns:
            The result of the expression.
        """
        return eval(expr)