langchain.utilities.serpapi.SerpAPIWrapper¶
- class langchain.utilities.serpapi.SerpAPIWrapper(*, search_engine: Any = None, params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}, serpapi_api_key: Optional[str] = None, aiosession: Optional[ClientSession] = None)[source]¶
Bases:
BaseModelWrapper around SerpAPI.
To use, you should have the
google-search-resultspython package installed, and the environment variableSERPAPI_API_KEYset with your API key, or pass serpapi_api_key as a named parameter to the constructor.Example
from langchain.utilities import SerpAPIWrapper serpapi = SerpAPIWrapper()
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 params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}¶
- param serpapi_api_key: Optional[str] = None¶
- async aresults(query: str) dict[source]¶
Use aiohttp to run query through SerpAPI and return the results async.
- async arun(query: str, **kwargs: Any) str[source]¶
Run query through SerpAPI and parse result async.