Skip to content

feat: add Exa AI-powered search tool#255

Open
tgonzalezc5 wants to merge 1 commit intoAlibaba-NLP:mainfrom
tgonzalezc5:feat/exa-search
Open

feat: add Exa AI-powered search tool#255
tgonzalezc5 wants to merge 1 commit intoAlibaba-NLP:mainfrom
tgonzalezc5:feat/exa-search

Conversation

@tgonzalezc5
Copy link
Copy Markdown

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

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

Adds Exa as an additional option for web search and Google Scholar
search in inference/, alongside the existing Serper backend. Behavior
is selected at runtime via the SEARCH_PROVIDER environment variable
and defaults to "serper" so existing deployments are unaffected.

- inference/tool_exa.py: Exa client wrapper, typed ExaResult dataclass,
  shared snippet/result formatting helpers used by both tool_search
  and tool_scholar
- inference/tool_search.py: route to Exa when SEARCH_PROVIDER=exa
- inference/tool_scholar.py: route to Exa (research-paper category)
  when SEARCH_PROVIDER=exa
- requirements.txt: add exa-py>=2.0.0
- .env.example: document SEARCH_PROVIDER and EXA_API_KEY
- inference/tests/test_tool_exa.py: unit tests for response parsing,
  snippet fallback, integration header, and missing-key behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant