File size: 1,141 Bytes
c52d511
39e9071
5724962
c52d511
39e9071
 
 
 
3792131
 
268976d
5724962
 
67d97f3
ec08c09
 
5724962
ec08c09
268976d
 
ecb2900
3792131
 
 
69dd942
67d97f3
39e9071
67d97f3
c52d511
39e9071
67d97f3
ff69472
39e9071
c52d511
67d97f3
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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 with the correct type string
    inputs: Dict[str, Any] = {
        "answer": {
            "type": "string",
            "description": "The final answer to be returned"
        }
    }
    
    # Specify output type with correct string
    output_type = "string"
    
    def __init__(self, description: Optional[str] = None):
        super().__init__()
        self.description = description or self.description
    
    def forward(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

    def __call__(self, answer: str) -> str:
        """Alias for forward method to maintain compatibility"""
        return self.forward(answer)