Class SearchApiWebSearchEngine
java.lang.Object
dev.langchain4j.web.search.searchapi.SearchApiWebSearchEngine
- All Implemented Interfaces:
WebSearchEngine
An implementation of a
WebSearchEngine
that uses
Search API for performing web searches. Search API supports not only Google Search, but many other engines
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionsearch
(WebSearchRequest webSearchRequest) Performs a search request on the web search engine and returns the search results.static WebSearchEngine
withApiKey
(String apiKey) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.web.search.WebSearchEngine
search
-
Constructor Details
-
SearchApiWebSearchEngine
public SearchApiWebSearchEngine(String apiKey, String baseUrl, Duration timeout, String engine, Map<String, Object> optionalParameters) - Parameters:
apiKey
- Required - the Search API key for accessing their APIbaseUrl
- overrides the default SearchApi base urltimeout
- the timeout duration for API requestsDefault value is 30 seconds.
engine
- the engine used by Search API to execute the searchDefault engine is Google Search.
optionalParameters
- parameters to be passed on every request of this the engine, they can be overridden by the WebSearchRequest additional parameters for matching keysCheck Search API for more information on available parameters for each engine
-
-
Method Details
-
search
Description copied from interface:WebSearchEngine
Performs a search request on the web search engine and returns the search results.- Specified by:
search
in interfaceWebSearchEngine
- Parameters:
webSearchRequest
- Check Search API for more information on available additional parameters for each engine that can be inside the request- Returns:
- the web search results
-
withApiKey
-