assafelovic / gpt-researcher

GPT based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
MIT License
13.05k stars 1.61k forks source link

SerperSearch Class updates 1. max_results param is now used. 2. timeo… #499

Closed dphiggs01 closed 1 month ago

dphiggs01 commented 1 month ago

Hi GPT-Researcher team,

This pull request updates the SerperSearch class, following the coding patterns defined in TavilySearch. Two simple modifications were made.

  1. The max_results param was not being used.
  2. The POST request did not have a timeout, potentially leading to the code hanging.

I have tested the changes using the local client, and the below simple test.

from gpt_researcher.retrievers.serper.serper import SerperSearch

def main():
    """
    This is Simple test of SerperSearch
    """
    # Query
    query = "Openai History"
    serper = SerperSearch(query)
    results = serper.search(max_results=5)
    assert len(results) == 5
    results = serper.search(max_results=6)
    assert len(results) == 6
    results = results[0]
    assert "href" in results

if __name__ == "__main__":
    main()

Thanks, Dan