tooluniverse.tool_finder_keyword moduleΒΆ
Keyword-based Tool Finder - An advanced keyword search tool for finding relevant tools.
This tool provides sophisticated keyword matching functionality using natural language processing techniques including tokenization, stop word removal, stemming, and TF-IDF scoring for improved relevance ranking. It serves as a robust search method when AI-powered search methods are unavailable.
- class tooluniverse.tool_finder_keyword.ToolFinderKeyword[source]ΒΆ
Bases:
BaseTool
Advanced keyword-based tool finder that uses sophisticated text processing and TF-IDF scoring.
This class implements natural language processing techniques for tool discovery including: - Tokenization and normalization - Stop word removal - Basic stemming - TF-IDF relevance scoring - Semantic phrase matching
The search operates by parsing user queries to extract key terms, processing them through NLP pipelines, and matching against pre-built indices of tool metadata for efficient and relevant tool discovery.
- STOP_WORDS = {'a', 'all', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'boy', 'but', 'by', 'came', 'can', 'day', 'did', 'do', 'down', 'each', 'find', 'for', 'from', 'get', 'had', 'has', 'have', 'he', 'how', 'if', 'in', 'is', 'it', 'its', 'long', 'made', 'may', 'new', 'no', 'now', 'number', 'of', 'old', 'on', 'part', 'said', 'see', 'that', 'the', 'their', 'they', 'this', 'time', 'to', 'two', 'up', 'use', 'was', 'way', 'what', 'which', 'who', 'will', 'with', 'your'}ΒΆ
- STEMMING_RULES = [('ies', 'y'), ('ied', 'y'), ('ying', 'y'), ('ing', ''), ('ly', ''), ('ed', ''), ('ies', 'y'), ('ier', 'y'), ('iest', 'y'), ('s', ''), ('es', ''), ('er', ''), ('est', ''), ('tion', 't'), ('sion', 's'), ('ness', ''), ('ment', ''), ('able', ''), ('ible', ''), ('ful', ''), ('less', ''), ('ous', ''), ('ive', ''), ('al', ''), ('ic', ''), ('ize', ''), ('ise', ''), ('ate', ''), ('fy', ''), ('ify', '')]ΒΆ
- __init__(tool_config, tooluniverse=None)[source]ΒΆ
Initialize the Advanced Keyword-based Tool Finder.
- Parameters:
tool_config (
dict
) β Configuration dictionary for the tooltooluniverse β Reference to the ToolUniverse instance containing all tools
- find_tools(message=None, picked_tool_names=None, rag_num=5, return_call_result=False, categories=None)[source]ΒΆ
Find relevant tools based on a message or pre-selected tool names.
This method matches the interface of other tool finders to ensure seamless replacement. It uses keyword-based search 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.
- Returns:
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]ΒΆ
Find tools using advanced keyword-based search with NLP processing and TF-IDF scoring.
This method provides a unified interface compatible with other tool finders.
- Parameters:
arguments (
dict
) β Dictionary containing: - description (str): Search query string (unified parameter name) - categories (list, optional): List of categories to filter by - limit (int, optional): Maximum number of results to return (default: 10) - 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.- Returns:
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: