Merge pull request #18 from jeroen-vet/jeroen-vet-patch-1

Update serper_dev_tool.py consider n_results parameter
This commit is contained in:
João Moura
2024-05-02 02:26:55 -03:00
committed by GitHub

View File

@@ -12,17 +12,17 @@ class SerperDevToolSchema(BaseModel):
class SerperDevTool(BaseTool):
name: str = "Search the internet"
description: str = "A tool that can be used to search the internet."
description: str = "A tool that can be used to search the internet with a search_query."
args_schema: Type[BaseModel] = SerperDevToolSchema
search_url: str = "https://google.serper.dev/search"
n_results: int = None
n_results: int = 10
def _run(
self,
search_query: str,
**kwargs: Any,
) -> Any:
payload = json.dumps({"q": search_query})
payload = json.dumps({"q": search_query, "num": self.n_results})
headers = {
'X-API-KEY': os.environ['SERPER_API_KEY'],
'content-type': 'application/json'