MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

error when run crawl_webpage.py

Open guiwenhou opened this issue 1 year ago • 2 comments
trafficstars

Bug description

exception happens in File "\MetaGPT\metagpt\actions\mi\write_plan.py", line 63, in assign_task_type task_type_list = rsp["task_type"] KeyError: 'task_type'

Bug solved method

Environment information

  • LLM type and model name: Qwen1.5-14B-Chat
  • System version: windows 11
  • Python version: python 3.9.18
  • packages version:
  • installation method:

Screenshots or logs

To install langchain-community run pip install -U langchain-community. warnings.warn(

[
    {
        "task_id": "task01",
        "dependent_task_ids": [],
        "instruction": "Scrape the data from the ICLR 2024 statistics page on multiagent and large language model-related papers"
    },
    {
        "task_id": "task02",
        "dependent_task_ids": ["task01"],
        "instruction": "Filter the scraped data to include papers with 'multiagent' or 'large language model' in the title"
    },
    {
        "task_id": "task03",
        "dependent_task_ids": ["task02"],
        "instruction": "Extract key variables (e.g., title, authors, publication date) from the filtered data"
    },
    {
        "task_id": "task04",
        "dependent_task_ids": ["task03"],
        "instruction": "Save the filtered and key variable data into a CSV file"
    }
]

Warning: model not found. Using cl100k_base encoding. 2024-03-04 10:09:23.738 | WARNING | metagpt.provider.openai_api:_calc_usage:277 - usage calculation failed: num_tokens_from_messages() is not implemented for model Qwen1.5-14B-Chat. See https://github.com/openai/openai-python/blob/main/chatml.md for information on how messages are converted to tokens. 2024-03-04 10:09:23.740 | WARNING | metagpt.utils.cost_manager:update_cost:47 - Model Qwen1.5-14B-Chat not found in TOKEN_COSTS. 2024-03-04 10:09:34.769 | WARNING | metagpt.utils.cost_manager:update_cost:47 - Model Qwen1.5-14B-Chat not found in TOKEN_COSTS. 2024-03-04 10:09:44.147 | WARNING | metagpt.utils.cost_manager:update_cost:47 - Model Qwen1.5-14B-Chat not found in TOKEN_COSTS. 2024-03-04 10:09:44.147 | WARNING | metagpt.utils.common:wrapper:571 - There is a exception in role's execution, in order to resume, we delete the newest role communication message in the role's memory. Traceback (most recent call last): File "C:\xxx\works\MetaGPT\metagpt\utils\common.py", line 562, in wrapper return await func(self, *args, **kwargs) File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 558, in run rsp = await self.react() File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 529, in react rsp = await self._plan_and_act() File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 489, in _plan_and_act await self.planner.update_plan(goal=goal) File "C:\xxx\works\MetaGPT\metagpt\strategy\planner.py", line 56, in update_plan rsp = await WritePlan().run(context, max_tasks=max_tasks, use_tools=self.use_tools) File "C:\xxx\works\MetaGPT\metagpt\actions\mi\write_plan.py", line 78, in run rsp = await self.assign_task_type(json.loads(rsp)) File "C:\xxx\works\MetaGPT\metagpt\actions\mi\write_plan.py", line 63, in assign_task_type task_type_list = rsp["task_type"] KeyError: 'task_type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\xxx\works\MetaGPT\examples\mi\crawl_webpage.py", line 22, in asyncio.run(main()) File "C:\Users\guiwe\miniconda3\envs\metagpt\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\guiwe\miniconda3\envs\metagpt\lib\asyncio\base_events.py", line 647, in run_until_complete return future.result() File "C:\xxx\works\MetaGPT\examples\mi\crawl_webpage.py", line 16, in main await mi.run(prompt) File "C:\xxx\works\MetaGPT\metagpt\utils\common.py", line 584, in wrapper raise Exception(format_trackback_info(limit=None)) Exception: Traceback (most recent call last): File "C:\xxx\works\MetaGPT\metagpt\utils\common.py", line 562, in wrapper return await func(self, *args, **kwargs) File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 558, in run rsp = await self.react() File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 529, in react rsp = await self._plan_and_act() File "C:\xxx\works\MetaGPT\metagpt\roles\role.py", line 489, in _plan_and_act await self.planner.update_plan(goal=goal) File "C:\xxx\works\MetaGPT\metagpt\strategy\planner.py", line 56, in update_plan rsp = await WritePlan().run(context, max_tasks=max_tasks, use_tools=self.use_tools) File "C:\xxx\works\MetaGPT\metagpt\actions\mi\write_plan.py", line 78, in run rsp = await self.assign_task_type(json.loads(rsp)) File "C:\xxx\works\MetaGPT\metagpt\actions\mi\write_plan.py", line 63, in assign_task_type task_type_list = rsp["task_type"] KeyError: 'task_type'

guiwenhou avatar Mar 04 '24 02:03 guiwenhou

same problem, any solution?

chunzha1 avatar Mar 12 '24 09:03 chunzha1

It seems the llm responds unexpected data. You can retry with the main branch, some bugs have beed fixed on that branch.

iorisa avatar Mar 19 '24 08:03 iorisa

Hey. Can you try the latest version to make sure the problem still exists?

geekan avatar Mar 21 '24 06:03 geekan

Hey. Can you try the latest version to make sure the problem still exists?

I had tried and work for me

chunzha1 avatar Mar 21 '24 07:03 chunzha1

@chunzha1 Great! Thx for your effort.

geekan avatar Mar 21 '24 07:03 geekan