File size: 835 Bytes
a21372d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21e59fd
eb61540
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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