Yago Bolivar commited on
Commit
def985a
·
1 Parent(s): 2803e9d

refactor: convert final_answer function to FinalAnswerTool class for improved structure and extensibility

Browse files
Files changed (1) hide show
  1. src/final_answer_tool.py +12 -9
src/final_answer_tool.py CHANGED
@@ -1,11 +1,14 @@
1
  from typing import Any, Optional
2
- from smolagents import tool
3
 
4
- @tool(
5
- name="final_answer",
6
- description="Provides a final answer to the given problem.",
7
- inputs={'answer': {'type': 'any', 'description': 'The final answer to the problem'}},
8
- output_type="any"
9
- )
10
- def final_answer(answer: Any) -> Any:
11
- return answer
 
 
 
 
1
  from typing import Any, Optional
2
+ from smolagents.tools import Tool
3
 
4
+ class FinalAnswerTool(Tool):
5
+ name = "final_answer"
6
+ description = "Provides a final answer to the given problem."
7
+ inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
8
+ output_type = "any"
9
+
10
+ def forward(self, answer: Any) -> Any:
11
+ return answer
12
+
13
+ def __init__(self, *args, **kwargs):
14
+ self.is_initialized = False