tag_search
File: core/src/utcp/implementations/tag_search.py
class TagAndDescriptionWordMatchStrategy (ToolSearchStrategy)
Documentation
Tag and description word match strategy.
Implements A Weighted Scoring System That Matches Tools Based On
- Tag matches (higher weight)
- Description word matches (lower weight)
The strategy normalizes queries to lowercase, extracts words using regex, and calculates relevance scores for each tool. Results are sorted by score in descending order.
Attributes
tool_search_strategy_type: Always "tag_and_description_word_match".description_weight: Weight multiplier for description word matches (default: 1.0).tag_weight: Weight multiplier for tag matches (default: 3.0).
Scoring Algorithm
- Each matching tag contributes tag_weight points
- Each matching description word contributes description_weight points
- Tools with higher scores are ranked first
- Tools with zero score are included in results (ranked last)
Fields:
- tool_search_strategy_type: Literal['tag_and_description_word_match']
- description_weight: float
- tag_weight: float
Methods:
async search_tools(self, tool_repository: ConcurrentToolRepository, query: str, limit: int, any_of_tags_required: Optional[List[str]]) -> List[Tool]
Search for tools based on the given query.
Args
tool_repository: The tool repository to search in.query: The query to search for.limit: The maximum number of results to return.any_of_tags_required: A list of tags that must be present in the tool.
Returns
A list of tools that match the query.
class TagAndDescriptionWordMatchStrategyConfigSerializer (Serializer[TagAndDescriptionWordMatchStrategy])
No class documentation available
Methods:
to_dict(self, obj: TagAndDescriptionWordMatchStrategy) -> dict
Convert a TagAndDescriptionWordMatchStrategy instance to a dictionary.
Args
obj: TheTagAndDescriptionWordMatchStrategyinstance to convert.
Returns
A dictionary representing the TagAndDescriptionWordMatchStrategy instance.
validate_dict(self, data: dict) -> TagAndDescriptionWordMatchStrategy
Convert a dictionary to a TagAndDescriptionWordMatchStrategy instance.
Args
data: The dictionary to convert.
Returns
A TagAndDescriptionWordMatchStrategy instance representing the dictionary.