SmartWebAnalyzerPlus / tools /final_answer.py
MHamdan's picture
Initial commit with full functionality extend app req tools
5724962
raw
history blame
908 Bytes
# tools/final_answer.py
from smolagents import Tool
from typing import Optional, Dict, Any
class FinalAnswerTool(Tool):
"""Tool for providing final answers to user queries."""
name = "final_answer"
description = "Tool for providing the final answer to the agent's task"
# Define inputs as a class attribute (now a dictionary)
inputs: Dict[str, Any] = {
"answer": {
"type": "str",
"description": "The final answer to be returned"
}
}
def __init__(self, description: Optional[str] = None):
super().__init__()
self.description = description or self.description
def __call__(self, answer: str) -> str:
"""Process and return the final answer.
Args:
answer: The answer text to be returned
Returns:
str: The processed answer
"""
return answer