Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research role fails if some of Serpapi searches return no results #1356

Open
igor-pechersky opened this issue Jun 19, 2024 · 1 comment
Open

Comments

@igor-pechersky
Copy link
Contributor

igor-pechersky commented Jun 19, 2024

Bug description
Research role fails if some of Serpapi searches return no results

Reproduction
Configuration

llm:
  api_type: "openai"  
  model: "gpt-4o"  
  base_url: "https://api.openai.com/v1"  # or forward url / other llm url
  api_key: "sk-XXX"

search:
  api_type: 'serpapi' 
  api_key: 'XXX'
  params:
    tbs: qdr:y #last year
    gl: us
    hl: en

Command line

python3 -m metagpt.roles.researcher 'Coulianu Tozgrec'
----
python3 -m metagpt.roles.researcher 'Compare LLM Agent Frameworks, such as AutoGen, MetaGPT, Lyzr, GPTSwarm, Langroid, and crewAI'

Bug solved method
PR 1357

Environment information

  • LLM type and model name: gpt-4o
  • System version: Linux codespaces-27135d 6.5.0-1021-azure
  • Python version: Python 3.9.17
  • MetaGPT version or branch: main, after 38cea1d

Screenshots or logs

Traceback (most recent call last):
  File "/workspaces/MetaGPT/metagpt/utils/common.py", line 640, in wrapper
    return await func(self, *args, **kwargs)
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 550, in run
    rsp = await self.react()
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 96, in react
    msg = await super().react()
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 519, in react
    rsp = await self._react()
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 474, in _react
    rsp = await self._act()
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 63, in _act
    summaries = await asyncio.gather(*todos)
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 61, in <genexpr>
    todos = (todo.run(*url, query=query, system_text=research_system_text) for (query, url) in links.items())
TypeError: run() missing 1 required positional argument: 'url'
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 117, in <module>
    fire.Fire(main)
  File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 679, in _CallAndUpdateTrace
    component = loop.run_until_complete(fn(*varargs, **kwargs))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 115, in main
    await role.run(topic)
  File "/workspaces/MetaGPT/metagpt/utils/common.py", line 662, in wrapper
    raise Exception(format_trackback_info(limit=None))
Exception: Traceback (most recent call last):
  File "/workspaces/MetaGPT/metagpt/utils/common.py", line 640, in wrapper
    return await func(self, *args, **kwargs)
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 550, in run
    rsp = await self.react()
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 96, in react
    msg = await super().react()
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 519, in react
    rsp = await self._react()
  File "/workspaces/MetaGPT/metagpt/roles/role.py", line 474, in _react
    rsp = await self._act()
  File "/workspaces/MetaGPT/metagpt/roles/researcher.py", line 55, in _act
    links = await todo.run(topic, 8, 8)
  File "/workspaces/MetaGPT/metagpt/actions/research.py", line 120, in run
    results = await asyncio.gather(*(self.search_engine.run(i, as_string=False) for i in keywords))
  File "/workspaces/MetaGPT/metagpt/tools/search_engine.py", line 164, in run
    raise e
  File "/workspaces/MetaGPT/metagpt/tools/search_engine.py", line 159, in run
    return await self.run_func(query, max_results=max_results, as_string=as_string)
  File "/workspaces/MetaGPT/metagpt/tools/search_engine_serpapi.py", line 47, in run
    return self._process_response(result, as_string=as_string)
  File "/workspaces/MetaGPT/metagpt/tools/search_engine_serpapi.py", line 90, in _process_response
    raise ValueError(f"Got error from SerpAPI: {res['error']}")
ValueError: Got error from SerpAPI: Google hasn't returned any results for this query.
@shenchucheng
Copy link
Collaborator

Thank you for your PR #1357 to fix this issue. Now that it has been merged, we will be closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants