Spaces:
Sleeping
Sleeping
Update tools/final_answer.py
Browse files- tools/final_answer.py +5 -4
tools/final_answer.py
CHANGED
|
@@ -8,13 +8,13 @@ class FinalAnswerTool(Tool):
|
|
| 8 |
name = "final_answer"
|
| 9 |
description = "Provides a final answer to the given problem. Can include a textual response and/or a path to a generated image."
|
| 10 |
|
| 11 |
-
# CORRECTED:
|
| 12 |
inputs = {
|
| 13 |
-
'text': {'type': 'string', 'description': 'The final textual answer to the problem'},
|
| 14 |
-
'image_path': {'type': 'string', 'description': 'Optional path to a generated image file (e.g., .webp, .png, .jpg) to be displayed.'}
|
| 15 |
}
|
| 16 |
|
| 17 |
-
output_type = "string" # Output will be a Markdown string
|
| 18 |
|
| 19 |
def forward(self, text: Optional[str] = None, image_path: Optional[str] = None) -> str:
|
| 20 |
"""
|
|
@@ -49,6 +49,7 @@ class FinalAnswerTool(Tool):
|
|
| 49 |
output_content.append(text)
|
| 50 |
|
| 51 |
if not output_content:
|
|
|
|
| 52 |
return "No final answer provided."
|
| 53 |
|
| 54 |
return "\n\n".join(output_content)
|
|
|
|
| 8 |
name = "final_answer"
|
| 9 |
description = "Provides a final answer to the given problem. Can include a textual response and/or a path to a generated image."
|
| 10 |
|
| 11 |
+
# CORRECTED: Add "nullable": True for both 'text' and 'image_path'
|
| 12 |
inputs = {
|
| 13 |
+
'text': {'type': 'string', 'description': 'The final textual answer to the problem', 'nullable': True},
|
| 14 |
+
'image_path': {'type': 'string', 'description': 'Optional path to a generated image file (e.g., .webp, .png, .jpg) to be displayed.', 'nullable': True}
|
| 15 |
}
|
| 16 |
|
| 17 |
+
output_type = "string" # Output will be a Markdown string
|
| 18 |
|
| 19 |
def forward(self, text: Optional[str] = None, image_path: Optional[str] = None) -> str:
|
| 20 |
"""
|
|
|
|
| 49 |
output_content.append(text)
|
| 50 |
|
| 51 |
if not output_content:
|
| 52 |
+
# If both are None, provide a default message
|
| 53 |
return "No final answer provided."
|
| 54 |
|
| 55 |
return "\n\n".join(output_content)
|