Skip to content

toolsets

Class info

Classes

Name Children Inherits
ToolSet
llmling.tools.toolsets
Container class for related tools.

🛈 DocStrings

Base class for tool collections.

ToolSet

Bases: ABC

Container class for related tools.

Source code in src/llmling/tools/toolsets.py
class ToolSet(ABC):
    """Container class for related tools."""

    @abstractmethod
    def get_tools(self) -> list[Callable[..., Any]]:
        """Get all tools from this toolset.

        Returns:
            List of callables to be converted to LLMCallableTools
        """
        raise NotImplementedError

    def get_llm_callable_tools(self) -> list[LLMCallableTool]:
        """Get all tools as LLMCallableTools.

        Returns:
            List of LLMCallableTools ready for registration

        Raises:
            ValueError: If a tool cannot be converted
        """
        tools = []
        for method in self.get_tools():
            try:
                tool = LLMCallableTool.from_callable(method)
                tools.append(tool)
            except Exception as exc:
                logger.exception("Failed to convert %s to LLMCallableTool", method)
                msg = f"Failed to convert {getattr(method, '__name__', method)} to LLMCallableTool"
                raise ValueError(msg) from exc
        return tools

get_llm_callable_tools

get_llm_callable_tools() -> list[LLMCallableTool]

Get all tools as LLMCallableTools.

Returns:

Type Description
list[LLMCallableTool]

List of LLMCallableTools ready for registration

Raises:

Type Description
ValueError

If a tool cannot be converted

Source code in src/llmling/tools/toolsets.py
def get_llm_callable_tools(self) -> list[LLMCallableTool]:
    """Get all tools as LLMCallableTools.

    Returns:
        List of LLMCallableTools ready for registration

    Raises:
        ValueError: If a tool cannot be converted
    """
    tools = []
    for method in self.get_tools():
        try:
            tool = LLMCallableTool.from_callable(method)
            tools.append(tool)
        except Exception as exc:
            logger.exception("Failed to convert %s to LLMCallableTool", method)
            msg = f"Failed to convert {getattr(method, '__name__', method)} to LLMCallableTool"
            raise ValueError(msg) from exc
    return tools

get_tools abstractmethod

get_tools() -> list[Callable[..., Any]]

Get all tools from this toolset.

Returns:

Type Description
list[Callable[..., Any]]

List of callables to be converted to LLMCallableTools

Source code in src/llmling/tools/toolsets.py
@abstractmethod
def get_tools(self) -> list[Callable[..., Any]]:
    """Get all tools from this toolset.

    Returns:
        List of callables to be converted to LLMCallableTools
    """
    raise NotImplementedError