Agents-Course-Assignment / my_tool_reverse_string.py
krzsam's picture
commit
86cbfce
raw
history blame contribute delete
810 Bytes
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