mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
Update serper_dev_tool.py consider n_results parameter
In original code n_results is always None so you always get only 10 results from Serper. With this change, when you explicitly set the n_results parameter when creating a SerperDevTool object it is taken into account.
This commit is contained in:
@@ -15,14 +15,14 @@ class SerperDevTool(BaseTool):
|
||||
description: str = "A tool that can be used to semantic search a query from a txt's content."
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user