Download agents/tools/base_tool.py from jayashree/TatTwamAI: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/jayashree/TatTwamAI/resolve/main/agents/tools/base_tool.py
- Command line
-
hf download hf://spaces/jayashree/TatTwamAI/agents/tools/base_tool.py
-
curl -L -o base_tool.py https://huggingface.co/spaces/jayashree/TatTwamAI/resolve/main/agents/tools/base_tool.py
1.46 kB
| class BaseTool: | |
| """ | |
| Minimal base class for CrewAI or modular AI agent tools. | |
| Inherit from this class for each custom tool to ensure a consistent interface. | |
| Attributes: | |
| config (dict or object, optional): Configuration provided on initialization. | |
| """ | |
| def __init__(self, config=None): | |
| """ | |
| Initialize the tool with optional configuration. | |
| Args: | |
| config (dict or object, optional): Configuration dictionary or object. | |
| """ | |
| self.config = config | |
| def __call__(self, *args, **kwargs): | |
| """ | |
| Abstract method for executing the tool's logic. | |
| To be implemented in child classes. | |
| Raises: | |
| NotImplementedError: If not overridden in a subclass. | |
| """ | |
| raise NotImplementedError( | |
| f"{self.__class__.__name__} must implement the __call__ method." | |
| ) | |
| def name(self): | |
| """ | |
| Returns the name of the tool class. | |
| Returns: | |
| str: Class name by default. | |
| """ | |
| return self.__class__.__name__ | |
| def description(self): | |
| """ | |
| Optionally provide a description string for the tool. | |
| Returns: | |
| str: Tool description, can be overridden by child classes. | |
| """ | |
| return f"{self.name} (custom tool base class for CrewAI and modular agents)." | |
| # You can add more utility methods/properties if you wish (e.g., metadata) |