ExUtcp.Search.Semantic (ex_utcp v0.3.2)

Copy Markdown View Source

Semantic search implementation for UTCP tools and providers.

Uses Haystack for full-text search and keyword extraction for intelligent tool discovery.

Summary

Functions

Calculates contextual similarity based on tool categories and domains.

Creates a Haystack index from tools for full-text search.

Extracts keywords from text for semantic analysis.

Finds similar tools based on semantic similarity.

Calculates semantic similarity between two sets of keywords.

Searches providers using semantic matching.

Searches tools using Haystack full-text search and semantic matching.

Searches tools using Haystack full-text search.

Searches tools using keyword-based semantic matching.

Functions

contextual_similarity(tool, query_keywords)

@spec contextual_similarity(ExUtcp.Types.tool(), [String.t()]) :: float()

Calculates contextual similarity based on tool categories and domains.

create_tools_index(tools)

@spec create_tools_index([ExUtcp.Types.tool()]) :: Haystack.t()

Creates a Haystack index from tools for full-text search.

extract_keywords(text)

@spec extract_keywords(String.t()) :: [String.t()]

Extracts keywords from text for semantic analysis.

find_similar_tools(reference_tool, candidate_tools, threshold \\ 0.3)

@spec find_similar_tools(ExUtcp.Types.tool(), [ExUtcp.Types.tool()], float()) ::
  list()

Finds similar tools based on semantic similarity.

keyword_similarity(keywords1, keywords2)

@spec keyword_similarity([String.t()], [String.t()]) :: float()

Calculates semantic similarity between two sets of keywords.

search_providers(providers, query, opts)

@spec search_providers(list(), String.t(), map()) :: list()

Searches providers using semantic matching.

search_tools(tools, query, opts)

@spec search_tools([map()], String.t(), map()) :: [map()]

Searches tools using Haystack full-text search and semantic matching.

search_tools_with_haystack(tools, query, opts)

@spec search_tools_with_haystack([map()], String.t(), map()) :: [map()]

Searches tools using Haystack full-text search.

search_tools_with_keywords(tools, query, opts)

@spec search_tools_with_keywords([ExUtcp.Types.tool()], String.t(), map()) :: list()

Searches tools using keyword-based semantic matching.