File size: 716 Bytes
a01e687
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Base class for all tools."""

from abc import ABC, abstractmethod
from typing import Any, Dict


class BaseTool(ABC):
    """Abstract base class for tools."""

    def __init__(self):
        self.name = self.__class__.__name__

    @property
    @abstractmethod
    def description(self) -> str:
        """Description of what the tool does."""
        pass

    @abstractmethod
    def run(self, text: str) -> Dict[str, Any]:
        """Execute the tool on the given text.

        Args:
            text: The input text to analyze

        Returns:
            Dictionary containing the analysis results
        """
        pass

    def __str__(self) -> str:
        return f"{self.name}: {self.description}"