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.

hour[source]
minute[source]
second[source]
microsecond[source]
tzinfo[source]
fold[source]
fromtimestamp()[source]

timestamp[, tz] -> tz’s local time from POSIX timestamp.

utcfromtimestamp()[source]

Construct a naive UTC datetime from a POSIX timestamp.

now()[source]

Returns new datetime object representing current time local to tz.

tz

Timezone object.

If no tz is specified, uses local timezone.

utcnow()[source]

Return a new datetime representing UTC day and time.

combine()[source]

date, time -> datetime with same date and time fields

fromisoformat()[source]

string -> datetime from datetime.isoformat() output

timetuple()[source]

Return time tuple, compatible with time.localtime().

timestamp()[source]

Return POSIX timestamp as float.

utctimetuple()[source]

Return UTC time tuple, compatible with time.localtime().

date()[source]

Return date object with same year, month and day.

time()[source]

Return time object with same time but with tzinfo=None.

timetz()[source]

Return time object with same time and tzinfo.

replace()[source]

Return datetime with new specified fields.

astimezone()[source]

tz -> convert to local time in new timezone tz

ctime()[source]

Return ctime() style string.

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’.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

strptime()[source]

string, format -> new datetime parsed from a string (like time.strptime()).

utcoffset()[source]

Return self.tzinfo.utcoffset(self).

tzname()[source]

Return self.tzinfo.tzname(self).

dst()[source]

Return self.tzinfo.dst(self).

max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)[source]
min = datetime.datetime(1, 1, 1, 0, 0)[source]
resolution = datetime.timedelta(microseconds=1)[source]
class tooluniverse.tool_finder_llm.BaseTool(tool_config)[source][source]

Bases: object

__init__(tool_config)[source][source]
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:

  1. Installed packages: Uses importlib.resources for proper package resource access

  2. Development mode: Falls back to file-based path resolution

  3. 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

classmethod load_defaults_from_file()[source][source]

Load defaults from the configuration file

run(arguments=None)[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.

check_function_call(function_call_json)[source][source]
get_required_parameters()[source][source]

Retrieve required parameters from the endpoint definition. Returns: list: List of required parameters for the given endpoint.

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:

bool

__init__(tool_config: Dict[str, Any])[source][source]
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_prompt_preview(arguments: Dict[str, Any]) str[source][source]
get_model_info() Dict[str, Any][source][source]
is_available() bool[source][source]

Check if the tool is available for use.

get_availability_status() Dict[str, Any][source][source]

Get detailed availability status of the tool.

retry_initialization() bool[source][source]

Attempt to reinitialize the tool (useful if API keys were updated).

get_prompt_template() str[source][source]
get_input_arguments() List[str][source][source]
validate_configuration() Dict[str, Any][source][source]
estimate_token_usage(arguments: Dict[str, Any]) Dict[str, int][source][source]
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:
  • query (str) – User query describing needed functionality

  • limit (int) – Maximum number of tools to return

  • include_reasoning (bool) – Whether to include selection reasoning

  • categories (list, optional) – List of tool categories to filter by

Returns:

Dictionary containing selected tools and metadata

Return type:

dict

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:

str, tuple, or list

Raises:

AssertionError – If both message and picked_tool_names are None

get_tool_stats()[source][source]

Get statistics about available tools.

clear_cache()[source][source]

Clear the tool cache to force refresh on next access.

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

find_tools_legacy(query, limit=5, include_reasoning=False, return_format='prompts')[source][source]

Legacy method for finding tools with different parameter names.

This provides backward compatibility for any code that might use ‘query’ instead of ‘description’.