Skip to content

Commit 4b778e7

Browse files
authored
Add Exa Search API support as internet search tool (#1846)
## Summary - Add `exa_internet_search` tool using `langchain_exa.ExaSearchResults`, mirroring the existing `tavily_internet_search` tool - Includes `ExaInternetSearchToolConfig` with configurable `max_results`, `search_type` (`Literal["auto", "neural", "keyword"]`), `livecrawl` (`Literal["always", "fallback", "never"]`), `max_query_length`, and `api_key` (via config or `EXA_API_KEY` env var) - Client instantiated lazily inside the invocation path, only when a valid API key is present - Adds `langchain-exa>=1.1.0,<2.0.0` dependency to `nvidia-nat-langchain` - Updates tutorial documentation with an "Using Exa Search" section alongside the existing Tavily section Closes #1848 ## Test plan - [x] Unit tests pass (12 tests in `test_exa_internet_search.py` — config validation, retries, truncation, empty results, empty key) - [x] Existing Tavily tests still pass (no regressions) - [x] Tool registers correctly in `GlobalTypeRegistry` and appears in `nat info components -t function` - [x] `ruff check` passes on all new/modified files - [x] Integration test with a valid `EXA_API_KEY` against live Exa API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Authors: - Max Buckley (https://github.com/maxwbuckley) - Bryan Bednarski (https://github.com/bbednarski9) Approvers: - Bryan Bednarski (https://github.com/bbednarski9) - https://github.com/Salonijain27 URL: #1846
1 parent a328e8a commit 4b778e7

49 files changed

Lines changed: 1977 additions & 130 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ci/vale/styles/config/vocabularies/nat/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Dynatrace
6565
[Ee]ngineerable
6666
etcd
6767
[Ee]val
68+
Exa
6869
[Ee]xfiltration
6970
[Ee]xplainability
7071
Faiss

docs/source/get-started/tutorials/add-tools-to-a-workflow.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ Workflow Result:
109109
```
110110

111111
## Alternate Method Using a Web Search Tool
112-
Adding individual web pages to a workflow can be cumbersome, especially when dealing with multiple web pages. An alternative method is to use a web search tool. One of the tools available in NeMo Agent Toolkit is the `tavily_internet_search` tool, which utilizes the [Tavily Search API](https://tavily.com/).
112+
Adding individual web pages to a workflow can be cumbersome, especially when dealing with multiple web pages. An alternative method is to use a web search tool. NeMo Agent Toolkit provides two web search tools: `tavily_internet_search` which utilizes the [Tavily Search API](https://tavily.com/), and `exa_internet_search` which utilizes the [Exa Search API](https://exa.ai/).
113+
114+
### Using Tavily Search
113115

114116
The `tavily_internet_search` tool is part of the `nvidia-nat[langchain]` package, to install the package run:
115117
```bash
@@ -151,3 +153,46 @@ Which will then yield a slightly different result to the same question:
151153
Workflow Result:
152154
['To trace only specific parts of a LangChain application, users can use the `@traceable` decorator to mark specific functions or methods as traceable. Additionally, users can configure the tracing functionality to log traces to a specific project, add metadata and tags to traces, and customize the run name and ID. Users can also use the `LangChainTracer` class to trace specific invocations or parts of their application. Furthermore, users can use the `tracing_v2_enabled` context manager to trace a specific block of code.']
153155
```
156+
157+
### Using Exa Search
158+
159+
The `exa_internet_search` tool is also part of the `nvidia-nat[langchain]` package. If you haven't already installed it:
160+
```bash
161+
# local package install from source
162+
uv pip install -e ".[langchain]"
163+
```
164+
165+
Prior to using the `exa_internet_search` tool, create an account at [`exa.ai`](https://exa.ai/) and obtain an API key. Once obtained, set the `EXA_API_KEY` environment variable to the API key:
166+
```bash
167+
export EXA_API_KEY=<YOUR_EXA_API_KEY>
168+
```
169+
170+
You can use the `exa_internet_search` tool in the same way as `tavily_internet_search` by updating the `functions` section of the configuration file:
171+
```yaml
172+
functions:
173+
internet_search:
174+
_type: exa_internet_search
175+
current_datetime:
176+
_type: current_datetime
177+
```
178+
179+
The `exa_internet_search` tool supports additional configuration options:
180+
```yaml
181+
functions:
182+
internet_search:
183+
_type: exa_internet_search
184+
max_results: 5
185+
search_type: neural # 'auto', 'fast', 'deep', 'neural', or 'instant'
186+
livecrawl: fallback # 'always', 'fallback', or 'never'
187+
max_retries: 3
188+
max_query_length: 2000 # queries longer than this are truncated
189+
highlights: true # include highlights in results
190+
max_content_length: 10000 # max chars of text per result; set to None to disable
191+
```
192+
193+
Then ensure the tool is included in the workflow tool list:
194+
```yaml
195+
workflow:
196+
_type: react_agent
197+
tool_names: [internet_search, current_datetime]
198+
```

examples/A2A/math_assistant_a2a/uv.lock

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)