ABVM commited on
Commit
858f29d
·
verified ·
1 Parent(s): ec0c239

Delete calculator_tool.py

Browse files
Files changed (1) hide show
  1. calculator_tool.py +0 -34
calculator_tool.py DELETED
@@ -1,34 +0,0 @@
1
- #from https://github.com/aymeric-roucher/GAIA/blob/main/scripts/experiments/calculator_tool.py
2
- import math
3
- import numexpr
4
- from typing import Dict
5
- from smolagents import Tool
6
-
7
- class CalculatorTool(Tool):
8
- name = "calculator"
9
- description = "This is a tool that performs simple arithmetic operations."
10
-
11
- inputs = {
12
- "expression": {
13
- "type": "string",
14
- "description": "The expression to be evaluated.The variables used CANNOT be placeholders like 'x' or 'mike's age', they must be numbers",
15
- }
16
-
17
- }
18
- output_type = "string"
19
-
20
- def __init__(self, *args, **kwargs):
21
- super().__init__(*args, **kwargs)
22
-
23
- def __call__(self, expression):
24
- if isinstance(expression, dict):
25
- expression = expression["expression"]
26
- local_dict = {"pi": math.pi, "e": math.e}
27
- output = str(
28
- numexpr.evaluate(
29
- expression.strip().replace("^", "**"),
30
- global_dict={}, # restrict access to globals
31
- local_dict=local_dict, # add common mathematical functions
32
- )
33
- )
34
- return output