tooluniverse.tool_finder_llm module¶
LLM-based Tool Finder - A tool that uses LLM to find relevant tools based on descriptions.
This tool leverages AgenticTool’s LLM functionality to create an intelligent tool finder that puts only essential tool information (name and description) in the prompt to minimize context window cost while letting the LLM decide which tools to return based on the query.
Key optimizations: - Only sends tool name and description to LLM (no parameters, configs, etc.) - Uses compact formatting to reduce token count - Caches tool descriptions to avoid repeated processing - Excludes irrelevant tools from prompt
- class tooluniverse.tool_finder_llm.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])[source][source]¶
Bases:
date
The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
- now()[source]¶
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- isoformat()[source]¶
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.
- class tooluniverse.tool_finder_llm.BaseTool(tool_config)[source][source]¶
Bases:
object
- classmethod get_default_config_file()[source][source]¶
Get the path to the default configuration file for this tool type.
This method uses a robust path resolution strategy that works across different installation scenarios:
Installed packages: Uses importlib.resources for proper package resource access
Development mode: Falls back to file-based path resolution
Legacy Python: Handles importlib.resources and importlib_resources
Override this method in subclasses to specify a custom defaults file.
- Returns:
Path or resource object pointing to the defaults file
- tooluniverse.tool_finder_llm.register_tool(tool_type_name=None, config=None)[source][source]¶
Decorator to automatically register tool classes and their configs.
- Usage:
@register_tool(‘CustomToolName’, config={…}) class MyTool:
pass
- class tooluniverse.tool_finder_llm.AgenticTool(tool_config: Dict[str, Any])[source][source]¶
Bases:
BaseTool
Generic wrapper around LLM prompting supporting JSON-defined configs with prompts and input arguments.
- static has_any_api_keys() bool [source][source]¶
Check if any API keys are available across all supported API types.
- Returns:
True if at least one API type has all required keys, False otherwise
- Return type:
- run(arguments: Dict[str, Any]) Dict[str, Any] [source][source]¶
Execute the tool.
The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.
- get_availability_status() Dict[str, Any] [source][source]¶
Get detailed availability status of the tool.
- class tooluniverse.tool_finder_llm.ToolFinderLLM(tool_config, tooluniverse=None)[source][source]¶
Bases:
BaseTool
LLM-based tool finder that uses natural language processing to select relevant tools.
This class leverages AgenticTool’s LLM capabilities to analyze tool descriptions and match them with user queries. It’s optimized for minimal context window cost by only sending essential information (tool name and description) to the LLM, providing an intelligent alternative to embedding-based similarity search.
Cost optimizations: - Only includes tool name and description in LLM prompt - Uses compact formatting to minimize token usage - Excludes unnecessary tool metadata and parameters - Implements caching to avoid repeated tool processing
- __init__(tool_config, tooluniverse=None)[source][source]¶
Initialize the LLM-based Tool Finder.
- Parameters:
tool_config (dict) – Configuration dictionary containing LLM settings and prompts
tooluniverse – Reference to the ToolUniverse instance containing all tools
- find_tools_llm(query, limit=5, include_reasoning=False, categories=None)[source][source]¶
Find relevant tools using LLM-based selection.
- Parameters:
- Returns:
Dictionary containing selected tools and metadata
- Return type:
- find_tools(message=None, picked_tool_names=None, rag_num=5, return_call_result=False, categories=None, return_list_only=None)[source][source]¶
Find relevant tools based on a message or pre-selected tool names.
This method matches the interface of the original ToolFinderEmbedding to ensure seamless replacement. It uses LLM-based selection instead of embedding similarity.
- Parameters:
message (str, optional) – Query message to find tools for. Required if picked_tool_names is None.
picked_tool_names (list, optional) – Pre-selected tool names to process. Required if message is None.
rag_num (int, optional) – Number of tools to return after filtering. Defaults to 5.
return_call_result (bool, optional) – If True, returns both prompts and tool names. Defaults to False.
categories (list, optional) – List of tool categories to filter by. Applied before LLM selection.
return_list_only (bool, optional) – If True, returns only a list of tool specifications. Overrides other return options.
- Returns:
If return_list_only is True: List of tool specifications
If return_call_result is False: Tool prompts as a formatted string
If return_call_result is True: Tuple of (tool_prompts, tool_names)
- Return type:
- Raises:
AssertionError – If both message and picked_tool_names are None
- run(arguments)[source][source]¶
Run the tool finder with given arguments following the standard tool interface.
This method now returns JSON format by default to ensure consistency with other search tools and simplify integration with SMCP.
- Parameters:
arguments (dict) – Dictionary containing: - description (str, optional): Query message to find tools for (maps to ‘message’) - limit (int, optional): Number of tools to return (maps to ‘rag_num’). Defaults to 5. - picked_tool_names (list, optional): Pre-selected tool names to process - return_call_result (bool, optional): Whether to return both prompts and names. Defaults to False. - return_format (str, optional): ‘json’ (default) or ‘legacy’ for old format - return_list_only (bool, optional): Whether to return only tool specifications as a list - categories (list, optional): List of tool categories to filter by