DeepResearch
DeepResearch copied to clipboard
feat: add Exa AI-powered search tool
Summary
Adds Exa as an additional option for web search and Google Scholar search in inference/, alongside the existing Serper backend. Selection is runtime via the SEARCH_PROVIDER environment variable and defaults to serper, so existing deployments are unaffected.
- New
inference/tool_exa.pywith a typedExaResultdataclass and shared snippet/result formatting tool_search.pyandtool_scholar.pyroute to Exa whenSEARCH_PROVIDER=exa- Exa scholar search uses the
research papercategory - Snippet extraction cascades through
highlights->summary-> truncatedtextso any combination of returned content fields produces a usable snippet requirements.txt: addsexa-py>=2.0.0.env.example: documentsSEARCH_PROVIDERandEXA_API_KEY- Unit tests in
inference/tests/test_tool_exa.pycovering response parsing, snippet fallback, thex-exa-integrationattribution header, and the missing-key disabled state
Usage
# .env
SEARCH_PROVIDER=exa
EXA_API_KEY=your_exa_key
# Same Search() / Scholar() tool surface as before
from tool_search import Search
result = Search().call({"query": ["transformer scaling laws"]})
When SEARCH_PROVIDER is unset or set to serper, the existing Serper code path is used unchanged.
Files changed
inference/tool_exa.py(new)inference/tool_search.py(route bySEARCH_PROVIDER)inference/tool_scholar.py(route bySEARCH_PROVIDER)inference/tests/test_tool_exa.py(new)inference/tests/__init__.py(new)requirements.txt(addexa-py>=2.0.0).env.example(addSEARCH_PROVIDER,EXA_API_KEY)
Test plan
- [x]
python -m unittest inference.tests.test_tool_exapasses locally (5 tests) - [x] All touched files parse cleanly (
python -m py_compile) - [x] Default
SEARCH_PROVIDERvalue preserves existing Serper behavior - [ ] Live Exa call from a configured environment (requires
EXA_API_KEY)