Upload tool
Browse files- app.py +5 -0
- requirements.txt +1 -0
- tool.py +25 -0
app.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import launch_gradio_demo
|
| 2 |
+
from tool import SimpleTool
|
| 3 |
+
|
| 4 |
+
tool = SimpleTool()
|
| 5 |
+
launch_gradio_demo(tool)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
smolagents
|
tool.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import Tool
|
| 2 |
+
from typing import Any, Optional
|
| 3 |
+
|
| 4 |
+
class SimpleTool(Tool):
|
| 5 |
+
name = "divisors"
|
| 6 |
+
description = "This is a tool that returns a list of the divisors for an integer number, including itself."
|
| 7 |
+
inputs = {'numb': {'type': 'integer', 'description': 'the number for which to get the list of divisors.'}}
|
| 8 |
+
output_type = "string"
|
| 9 |
+
|
| 10 |
+
def forward(self, numb: int) -> str:
|
| 11 |
+
"""
|
| 12 |
+
This is a tool that returns a list of the forward for an integer number, including itself.
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
numb: the number for which to get the list of forward.
|
| 16 |
+
"""
|
| 17 |
+
i = 2
|
| 18 |
+
divlist = []
|
| 19 |
+
while i <= numb:
|
| 20 |
+
if numb % i == 0:
|
| 21 |
+
print(i)
|
| 22 |
+
divlist.append(i)
|
| 23 |
+
i += 1
|
| 24 |
+
|
| 25 |
+
return divlist.tostring()
|