Class TavilyWebSearchEngine
java.lang.Object
dev.langchain4j.web.search.tavily.TavilyWebSearchEngine
- All Implemented Interfaces:
WebSearchEngine
Represents Tavily Search API as a
When
When
WebSearchEngine.
See more details here.
When
includeRawContent is set to true,
the raw content will appear in the WebSearchOrganicResult.content() field of each result.
When
includeAnswer is set to true,
the answer will appear in the WebSearchOrganicResult.snippet() field of the first result.
In this case, the WebSearchOrganicResult.url() of the first result will always be "https://tavily.com/" and
the WebSearchOrganicResult.title() will always be "Tavily Search API".-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()search(WebSearchRequest webSearchRequest) Performs a search request on the web search engine and returns the search results.searchAsync(WebSearchRequest webSearchRequest) Genuinely non-blocking counterpart ofsearch(WebSearchRequest), used by the asynchronous and reactive RAG flow.static TavilyWebSearchEnginewithApiKey(String apiKey) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WebSearchEngine
search
-
Constructor Details
-
TavilyWebSearchEngine
-
TavilyWebSearchEngine
-
-
Method Details
-
builder
-
search
Description copied from interface:WebSearchEnginePerforms a search request on the web search engine and returns the search results.- Specified by:
searchin interfaceWebSearchEngine- Parameters:
webSearchRequest- the search request- Returns:
- the web search results
-
searchAsync
Genuinely non-blocking counterpart ofsearch(WebSearchRequest), used by the asynchronous and reactive RAG flow. The underlying HTTP call is dispatched asynchronously (no thread is parked while it is in flight), and cancelling the returned future aborts the in-flight call (best-effort).- Specified by:
searchAsyncin interfaceWebSearchEngine- Parameters:
webSearchRequest- the search request- Returns:
- a
CompletableFutureof the web search results
-
withApiKey
-