langchain.utilities.google_serper.GoogleSerperAPIWrapper¶
class langchain.utilities.google_serper.GoogleSerperAPIWrapper[source]¶
Bases: BaseModel
Wrapper around the Serper.dev Google Search API.
You can create a free API key at https://serper.dev.
To use, you should have the environment variable SERPER_API_KEY
set with your API key, or pass serper_api_key as a named parameter
to the constructor.
Example
from langchain.utilities import GoogleSerperAPIWrapper
google_serper = GoogleSerperAPIWrapper()
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param aiosession: Optional[aiohttp.client.ClientSession] = None¶
param gl: str = 'us'¶
param hl: str = 'en'¶
param k: int = 10¶
param serper_api_key: Optional[str] = None¶
param tbs: Optional[str] = None¶
param type: Literal['news', 'search', 'places', 'images'] = 'search'¶
async aresults(query: str, **kwargs: Any) → Dict[source]¶
Run query through GoogleSearch.
async arun(query: str, **kwargs: Any) → str[source]¶
Run query through GoogleSearch and parse result async.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values