sonald commited on
Commit
54f968b
·
verified ·
1 Parent(s): 4fbb75e

Upload tool

Browse files
Files changed (3) hide show
  1. app.py +6 -0
  2. requirements.txt +1 -0
  3. tool.py +18 -0
app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from smolagents import launch_gradio_demo
2
+ from tool import SimpleTool
3
+
4
+ tool = SimpleTool()
5
+
6
+ launch_gradio_demo(tool)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ smolagents
tool.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from typing import Any, Optional
3
+
4
+ class SimpleTool(Tool):
5
+ name = "calculator"
6
+ description = "Calculate the result of the expression."
7
+ inputs = {"expr":{"type":"string","description":"The math expression to calculate."}}
8
+ output_type = "string"
9
+
10
+ def forward(self, expr: str) -> str:
11
+ """
12
+ Calculate the result of the expression.
13
+ Args:
14
+ expr: The math expression to calculate.
15
+ Returns:
16
+ The result of the expression.
17
+ """
18
+ return eval(expr)