Skip to content

Tools

llm_expose.tools.base

Abstract base class for tool/function-calling support.

BaseTool

Bases: ABC

Legacy interface for optional local tool execution.

Concrete subclasses represent callable tools executed inside this application. The current production path uses LiteLLM MCP tools directly, so this interface is kept primarily for backward compatibility and future local-only integrations.

Remove once local tool execution is either fully implemented or

formally deprecated across public API/docs.

Source code in llm_expose/tools/base.py
 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
40
41
42
43
44
45
class BaseTool(ABC):
    """Legacy interface for optional local tool execution.

    Concrete subclasses represent callable tools executed inside this
    application. The current production path uses LiteLLM MCP tools directly,
    so this interface is kept primarily for backward compatibility and future
    local-only integrations.

    TODO: Remove once local tool execution is either fully implemented or
        formally deprecated across public API/docs.
    """

    @property
    @abstractmethod
    def name(self) -> str:
        """Unique, snake_case name of the tool (used in the LLM's API call)."""

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

    @property
    @abstractmethod
    def parameters_schema(self) -> dict[str, Any]:
        """JSON-Schema dict that describes the tool's input parameters."""

    @abstractmethod
    async def execute(self, **kwargs: Any) -> str:
        """Invoke the tool with the provided keyword arguments.

        Args:
            **kwargs: Arguments validated against :attr:`parameters_schema`.

        Returns:
            The tool's result as a plain string to be passed back to the LLM.
        """

description abstractmethod property

Human-readable description of what the tool does.

name abstractmethod property

Unique, snake_case name of the tool (used in the LLM's API call).

parameters_schema abstractmethod property

JSON-Schema dict that describes the tool's input parameters.

execute(**kwargs) abstractmethod async

Invoke the tool with the provided keyword arguments.

Parameters:

Name Type Description Default
**kwargs Any

Arguments validated against :attr:parameters_schema.

{}

Returns:

Type Description
str

The tool's result as a plain string to be passed back to the LLM.

Source code in llm_expose/tools/base.py
36
37
38
39
40
41
42
43
44
45
@abstractmethod
async def execute(self, **kwargs: Any) -> str:
    """Invoke the tool with the provided keyword arguments.

    Args:
        **kwargs: Arguments validated against :attr:`parameters_schema`.

    Returns:
        The tool's result as a plain string to be passed back to the LLM.
    """