File size: 574 Bytes
5c02d2d
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from typing import Any, Optional
from smolagents.tools import Tool

class BooleanDefaultTool(Tool):
    name = "boolean_default_tool"
    description = "A tool with a boolean default parameter"
    inputs = {'text': {'type': 'string', 'description': 'Input text'}, 'flag': {'type': 'boolean', 'description': 'Boolean flag with default value', 'nullable': True}}
    output_type = "string"

    def forward(self, text: str, flag: bool = False) -> str:
        return f"Text: {text}, Flag: {flag}"

    def __init__(self, *args, **kwargs):
        self.is_initialized = False