ExAthena.Search behaviour (ExAthena v0.17.0)

Copy Markdown View Source

Behaviour for web-search backends.

The web_search tool calls search/2; the concrete implementation is chosen via application config so the dependency on any particular search provider is wrapped behind a contract we own (and can mock with Mox in tests):

config :ex_athena, :search, adapter: ExAthena.Search.Http, backend: :duckduckgo

Mirrors the provider-resolution pattern in ExAthena.Config (a default module plus per-env override). The default adapter is ExAthena.Search.Http, which is itself pluggable across backends (DuckDuckGo / Tavily / Brave / SearXNG).

Summary

Functions

The configured search backend module (defaults to ExAthena.Search.Http).

Run a web search through the configured backend.

Types

opts()

@type opts() :: [
  max_results: pos_integer(),
  topic: String.t(),
  recency: String.t(),
  timeout_ms: pos_integer()
]

Callbacks

search(query, opts)

@callback search(query :: String.t(), opts()) ::
  {:ok, [ExAthena.Search.Result.t()]} | {:error, term()}

Functions

impl()

@spec impl() :: module()

The configured search backend module (defaults to ExAthena.Search.Http).

search(query, opts \\ [])

@spec search(String.t(), opts()) ::
  {:ok, [ExAthena.Search.Result.t()]} | {:error, term()}

Run a web search through the configured backend.