First_agent_template / tools /final_answer.py
ronak008's picture
Update tools/final_answer.py
044c01f verified
raw
history blame contribute delete
574 Bytes
from typing import Any
from smolagents.tools import Tool
class FinalAnswerTool(Tool):
name = "final_answer"
description = "Provides a final answer to the given problem."
inputs = {"answer": {"type": "string", "description": "The final answer to the problem"}}
output_type = "string"
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) # Initialize the parent class
self.is_initialized = True # Correctly initialized
def forward(self, answer: Any) -> str:
return str(answer) # Ensures a string output