Spaces:
Sleeping
Sleeping
Initial commit with full functionality extend app req tools
Browse files- tools/final_answer.py +23 -3
tools/final_answer.py
CHANGED
|
@@ -4,15 +4,35 @@ from smolagents import tool
|
|
| 4 |
|
| 5 |
@tool
|
| 6 |
class FinalAnswerTool:
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
description = "A tool to provide the final answer"
|
| 9 |
|
| 10 |
def __call__(self, answer: str) -> str:
|
| 11 |
-
"""
|
|
|
|
| 12 |
Args:
|
| 13 |
-
answer: The final answer to
|
|
|
|
|
|
|
|
|
|
| 14 |
"""
|
| 15 |
return answer
|
| 16 |
|
| 17 |
def __str__(self) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
return self.name
|
|
|
|
| 4 |
|
| 5 |
@tool
|
| 6 |
class FinalAnswerTool:
|
| 7 |
+
"""A tool that provides the final answer for the agent's response.
|
| 8 |
+
|
| 9 |
+
This tool is used to format and return the final response from the agent.
|
| 10 |
+
It ensures that the response is properly formatted and ready for presentation
|
| 11 |
+
to the user.
|
| 12 |
+
|
| 13 |
+
Attributes:
|
| 14 |
+
name (str): The name identifier for the tool
|
| 15 |
+
description (str): A brief description of the tool's purpose
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
name = "final_answer"
|
| 19 |
description = "A tool to provide the final answer"
|
| 20 |
|
| 21 |
def __call__(self, answer: str) -> str:
|
| 22 |
+
"""Process and return the final answer.
|
| 23 |
+
|
| 24 |
Args:
|
| 25 |
+
answer: The final answer text to be returned to the user
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
str: The formatted final answer
|
| 29 |
"""
|
| 30 |
return answer
|
| 31 |
|
| 32 |
def __str__(self) -> str:
|
| 33 |
+
"""Return string representation of the tool.
|
| 34 |
+
|
| 35 |
+
Returns:
|
| 36 |
+
str: The tool's name
|
| 37 |
+
"""
|
| 38 |
return self.name
|