File size: 810 Bytes
1154bfc 86cbfce 1154bfc 86cbfce 1154bfc 86cbfce 1154bfc 86cbfce 1154bfc 86cbfce 1154bfc |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from smolagents import Tool
#AUTHORIZED_TYPES = [
# "string",
# "boolean",
# "integer",
# "number",
# "image",
# "audio",
# "array",
# "object",
# "any",
# "null",
#]
class ReverseStringTool(Tool):
name = "_my_tool_reverse_string"
description = """
Decode a string which is provided in a reversed form
To invoke the tool use code as below
<code>
reversed_string = _my_tool_reverse_string(input_str="dummy")
</code>
"""
inputs = {
"input_str": {
"type": "string",
"description": "encoded input string",
}
}
output_type = "string"
def forward(self, input_str: str) -> str:
_out = ""
for a in input_str:
_out = a + _out
return _out
|