Spaces:
Runtime error
Runtime error
Update tools/final_answer.py
Browse files- tools/final_answer.py +9 -7
tools/final_answer.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
-
from typing import Any
|
| 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 = {
|
| 8 |
-
output_type = "
|
| 9 |
-
|
| 10 |
-
def forward(self, answer: Any) -> Any:
|
| 11 |
-
return answer
|
| 12 |
|
| 13 |
def __init__(self, *args, **kwargs):
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 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": "string", "description": "The final answer to the problem"}}
|
| 8 |
+
output_type = "string"
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def __init__(self, *args, **kwargs):
|
| 11 |
+
super().__init__(*args, **kwargs) # Initialize the parent class
|
| 12 |
+
self.is_initialized = True # Correctly initialized
|
| 13 |
+
|
| 14 |
+
def forward(self, answer: Any) -> str:
|
| 15 |
+
return str(answer) # Ensures a string output
|
| 16 |
+
|