google_search
Module Contents
Classes
Wrapper around the Serper.dev Google Search API. |
- class lagent.actions.google_search.GoogleSearch(api_key=None, timeout=5, search_type='search', description=None, parser=JsonParser, enable=True)
Bases:
lagent.actions.base_action.BaseActionWrapper around the Serper.dev Google Search API.
To use, you should pass your serper API key to the constructor.
Code is modified from lang-chain GoogleSerperAPIWrapper (https://github.com/langchain-ai/langchain/blob/ba5f baba704a2d729a4b8f568ed70d7c53e799bb/libs/langchain/ langchain/utilities/google_serper.py)
- Parameters:
api_key (str) – API KEY to use serper google search API, You can create a free API key at https://serper.dev.
timeout (int) – Upper bound of waiting time for a serper request.
search_type (str) – Serper API support [‘search’, ‘images’, ‘news’, ‘places’] types of search, currently we only support ‘search’.
description (dict) – The description of the action. Defaults to
None.parser (Type[BaseParser]) – The parser class to process the action’s inputs and outputs. Defaults to
JsonParser.enable (bool) – Whether the action is enabled. Defaults to
True.
- result_key_for_type
- run(query, k=10)
一个可以从谷歌搜索结果的API。当你需要对于一个特定问题找到简短明了的回答时,可以使用它。输入应该是一个搜索查询。
- Parameters:
query (str) – the search content
k (int) – select first k results in the search results as response
- Return type: