DeepResearch icon indicating copy to clipboard operation
DeepResearch copied to clipboard

feat: add Exa AI-powered search tool

Open tgonzalezc5 opened this issue 6 months ago • 0 comments

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.py with a typed ExaResult dataclass and shared snippet/result formatting
  • tool_search.py and tool_scholar.py route to Exa when SEARCH_PROVIDER=exa
  • Exa scholar search uses the research paper category
  • Snippet extraction cascades through highlights -> summary -> truncated text so any combination of returned content fields produces a usable snippet
  • requirements.txt: adds exa-py>=2.0.0
  • .env.example: documents SEARCH_PROVIDER and EXA_API_KEY
  • Unit tests in inference/tests/test_tool_exa.py covering response parsing, snippet fallback, the x-exa-integration attribution 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 by SEARCH_PROVIDER)
  • inference/tool_scholar.py (route by SEARCH_PROVIDER)
  • inference/tests/test_tool_exa.py (new)
  • inference/tests/__init__.py (new)
  • requirements.txt (add exa-py>=2.0.0)
  • .env.example (add SEARCH_PROVIDER, EXA_API_KEY)

Test plan

  • [x] python -m unittest inference.tests.test_tool_exa passes locally (5 tests)
  • [x] All touched files parse cleanly (python -m py_compile)
  • [x] Default SEARCH_PROVIDER value preserves existing Serper behavior
  • [ ] Live Exa call from a configured environment (requires EXA_API_KEY)

tgonzalezc5 avatar May 04 '26 23:05 tgonzalezc5