TatTwamAI / agents /tools /base_tool.py
Jayashree Sridhar
Written custom base tool
8bacf7a
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."
)
@property
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)