ExUtcp.Search.Engine (ex_utcp v0.3.2)

Copy Markdown View Source

Search engine for managing and indexing UTCP tools and providers.

The engine maintains an in-memory index of tools and providers for fast searching.

Summary

Functions

Adds a provider to the search index.

Adds a tool to the search index.

Returns a specification to start this module under a supervisor.

Clears all tools and providers from the search index.

Gets all providers from the search index.

Gets all tools from the search index.

Gets a tool by name.

Creates a new search engine.

Removes a provider from the search index.

Removes a tool from the search index.

Starts the search engine as a GenServer.

Gets search engine statistics.

Types

t()

@type t() :: %ExUtcp.Search.Engine{
  config: map(),
  providers_index: %{required(String.t()) => map()},
  tools_index: %{required(String.t()) => ExUtcp.Types.tool()}
}

Functions

add_provider(engine_or_pid, provider)

@spec add_provider(t() | pid(), map()) :: t() | :ok

Adds a provider to the search index.

add_tool(engine_or_pid, tool)

@spec add_tool(t() | pid(), ExUtcp.Types.tool()) :: t() | :ok

Adds a tool to the search index.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(engine_or_pid)

@spec clear(t() | pid()) :: t() | :ok

Clears all tools and providers from the search index.

get_all_providers(engine_or_pid)

@spec get_all_providers(t() | pid()) :: [map()]

Gets all providers from the search index.

get_all_tools(engine_or_pid)

@spec get_all_tools(t() | pid()) :: [ExUtcp.Types.tool()]

Gets all tools from the search index.

get_provider(engine_or_pid, provider_name)

@spec get_provider(t() | pid(), String.t()) :: map() | nil

Gets a provider by name.

get_tool(engine_or_pid, tool_name)

@spec get_tool(t() | pid(), String.t()) :: ExUtcp.Types.tool() | nil

Gets a tool by name.

new(opts \\ [])

@spec new(keyword()) :: %ExUtcp.Search.Engine{
  config: %{
    enable_caching: boolean(),
    fuzzy_threshold: float(),
    max_results: integer(),
    semantic_threshold: float()
  },
  providers_index: %{required(String.t()) => map()},
  tools_index: %{required(String.t()) => ExUtcp.Types.tool()}
}

Creates a new search engine.

remove_provider(engine_or_pid, provider_name)

@spec remove_provider(t() | pid(), String.t()) :: t() | :ok

Removes a provider from the search index.

remove_tool(engine_or_pid, tool_name)

@spec remove_tool(t() | pid(), String.t()) :: t() | :ok

Removes a tool from the search index.

start_link(opts \\ [])

@spec start_link(keyword()) :: {:ok, pid()} | {:error, term()}

Starts the search engine as a GenServer.

stats(engine_or_pid)

@spec stats(t() | pid()) :: map()

Gets search engine statistics.