| from smolagents import Tool | |
| from typing import Any, Optional | |
| class SimpleTool(Tool): | |
| name = "divisors" | |
| description = "This is a tool that returns a list of the divisors for an integer number, including itself." | |
| inputs = {'numb': {'type': 'integer', 'description': 'the number for which to get the list of divisors.'}} | |
| output_type = "string" | |
| def forward(self, numb: int) -> str: | |
| """ | |
| This is a tool that returns a list of the forward for an integer number, including itself. | |
| Args: | |
| numb: the number for which to get the list of forward. | |
| """ | |
| i = 2 | |
| divlist = [] | |
| while i <= numb: | |
| if numb % i == 0: | |
| print(i) | |
| divlist.append(i) | |
| i += 1 | |
| res = ', '.join(map(str, divlist)) | |
| return res |