Class GoogleCustomWebSearchEngine
java.lang.Object
dev.langchain4j.web.search.google.customsearch.GoogleCustomWebSearchEngine
- All Implemented Interfaces:
WebSearchEngine
An implementation of a
WebSearchEngine
that uses
Google Custom Search API for performing web searches.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionsearch
(WebSearchRequest webSearchRequest) Performs a search request on the web search engine and returns the search results.static GoogleCustomWebSearchEngine
withApiKeyAndCsi
(String apiKey, String csi) Creates a new builder for constructing a GoogleCustomWebSearchEngine with the specified API key and Custom Search ID.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
-
GoogleCustomWebSearchEngine
public GoogleCustomWebSearchEngine(String apiKey, String csi, Boolean siteRestrict, Boolean includeImages, Duration timeout, Integer maxRetries, Boolean logRequests, Boolean logResponses) Constructs a new GoogleCustomWebSearchEngine with the specified parameters.- Parameters:
apiKey
- the Google Search API key for accessing the Google Custom Search APIYou can just generate an API key here
csi
- the Custom Search ID parameter for search the entire webYou can create a Custom Search Engine here
siteRestrict
- if your Search Engine is restricted to only searching specific sites, you can set this parameter to true.Default value is false. View the documentation for more information here
includeImages
- If it is true then include public images relevant to the query. This can add more latency to the search.Default value is false.
timeout
- the timeout duration for API requestsDefault value is 60 seconds.
maxRetries
- the maximum number of retries for API requestsDefault value is 10.
logRequests
- whether to log API requestsDefault value is false.
logResponses
- whether to log API responsesDefault value is false.
-
-
Method Details
-
withApiKeyAndCsi
Creates a new builder for constructing a GoogleCustomWebSearchEngine with the specified API key and Custom Search ID.- Parameters:
apiKey
- the API key for accessing the Google Custom Search APIcsi
- the Custom Search ID parameter for search the entire web- Returns:
- a new builder instance
-
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
- the search request- Returns:
- the web search results
-