feat: add Exa AI-powered search tool#1
Open
tgonzalezc5 wants to merge 1 commit into
Open
Conversation
Adds an `exa` provider behind a SEARCH_PROVIDER env switch (default
remains `searxng`, so the local-first / no-cloud experience is
unchanged). When SEARCH_PROVIDER=exa and EXA_API_KEY is set, the search
node calls Exa's search_and_contents instead of SearXNG; everything
downstream (retrieve, fetch_url, compress, synthesize, verify) is
untouched because the provider returns the same {url, title, snippet}
shape.
engine/core/pipeline.py
SEARCH_PROVIDER, EXA_API_KEY, EXA_SEARCH_TYPE, EXA_CATEGORY,
EXA_INCLUDE_DOMAINS, EXA_EXCLUDE_DOMAINS, EXA_START_PUBLISHED_DATE,
EXA_END_PUBLISHED_DATE, EXA_HIGHLIGHTS_CHARS — new env gates.
_exa(query, n) requests summary + highlights so the snippet
extractor can cascade summary → highlights → text head.
_get_exa_client() lazy-imports exa-py and stamps an
x-exa-integration tracking header.
_web_search(query, n) is the new dispatcher; _search_one calls it
instead of _searxng directly. _searxng stays public for tests +
backward compat.
engine/core/__init__.py
Re-export _exa and _web_search alongside _searxng.
engine/tests/test_search_providers.py
11 mocked tests: snippet fallback chain, kwargs forwarding, lazy
client + tracking header, dispatcher routing, _search_one wiring.
No network, no API key.
pyproject.toml + engine/requirements.txt
exa-py>=2.0.0 added under the new `exa` extra; the requirements
file documents it as opt-in (commented). Default install stays
light — exa-py is only imported when the provider is used.
README.md + docs/architecture.md
SEARCH_PROVIDER + EXA_API_KEY rows added to the env-vars table;
architecture reference grouped under a new "web search" row.
Tests: 234 → 245 (+11) repo-wide green; engine/tests 104 → 115.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds Exa as an optional web-search provider behind a
SEARCH_PROVIDERenv switch. The default stayssearxng, so the local-first / no-cloud experience is unchanged.Why
The pipeline currently has one web-search backend (SearXNG). For users who don't run SearXNG locally, or who want a single hosted endpoint with semantic ranking + content extraction in one call, Exa is a natural drop-in. The provider returns the same
{url, title, snippet}shape that_search_onealready consumes, so retrieve / fetch_url / compress / synthesize / verify are untouched.How
SEARCH_PROVIDERenv var (defaultsearxng) routes_web_searchto either_searxng(existing) or_exa(new)._exacallsexa.search_and_contentsrequestingsummary+highlightstogether, then the snippet extractor cascades summary → joined highlights → text head so a missing field in any one mode doesn't drop the result._get_exa_clientlazy-importsexa-pyand stamps anx-exa-integrationtracking header so usage is attributable. Lazy import means installs withoutexa-pykeep importing the module cleanly; the import only happens when the provider is actually used._searxngstays public for backward compat (and so the existing recipe tests that monkeypatch it don't change).EXA_CATEGORY,EXA_INCLUDE_DOMAINS,EXA_EXCLUDE_DOMAINS,EXA_START_PUBLISHED_DATE,EXA_END_PUBLISHED_DATE,EXA_SEARCH_TYPE) are forwarded to the SDK only when set, so an unset value never overrides the SDK default.exa-py>=2.0.0lives under a new[exa]optional extra inpyproject.toml; defaultpip installis still light.Usage
Optional tuning:
Tests
New file:
engine/tests/test_search_providers.py— 11 mocked tests, no network, no API key:EXA_API_KEYis unsetx-exa-integration) set on the client_search_oneend-to-end through the new dispatcherRepo-wide test count: 234 → 245 (+11) green.
engine/tests: 104 → 115. (Pre-existingrecipes/by-use-case/trading-copilotcollection error from missingta/yfinancedeps is unrelated and reproduces onmain.)Files changed
engine/core/pipeline.py—_exa,_web_search,_get_exa_client, env gatesengine/core/__init__.py— re-export_exa,_web_searchengine/tests/test_search_providers.py— new (11 tests)pyproject.toml—[exa]extra withexa-py>=2.0.0engine/requirements.txt— comment line documenting the optional depREADME.md—SEARCH_PROVIDER+EXA_API_KEYrows in the env tabledocs/architecture.md— newweb searchrow in the env-vars groupingsChecklist
pytest core/rag recipes engine/tests --ignore=recipes/by-use-case/trading-copilot -q→ 245 passed)EXA_API_KEY+ cloud egress