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

运行狼人杀后<class 'pydantic._internal._model_construction.ModelMetaclass'> #1691

Open
QiXingRan opened this issue Feb 13, 2025 · 1 comment

Comments

@QiXingRan
Copy link

windows环境运行狼人杀后一段对话报错

Traceback (most recent call last):
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\actions\common_actions.py", line 237, in run
    rsp = await self._aask(prompt)
TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not CompletionUsage

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\utils\common.py", line 640, in wrapper
    return await func(self, *args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\roles\role.py", line 550, in run
    rsp = await self.react()
tenacity.RetryError: RetryError[<Future at 0x1e8ddda8b80 state=finished raised TypeError>]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\utils\common.py", line 626, in wrapper
    result = await func(self, *args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\team.py", line 134, in run
    await self.env.run()
Exception: Traceback (most recent call last):
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\actions\common_actions.py", line 237, in run
    rsp = await self._aask(prompt)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\actions\action.py", line 93, in _aask
    return await self.llm.aask(prompt, system_msgs)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\provider\base_llm.py", line 150, in aask
    rsp = await self.acompletion_text(message, stream=stream, timeout=self.get_timeout(timeout))
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\__init__.py", line 314, in iter
    return fut.result()
  File "D:\ProgramData\envs\agent\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "D:\ProgramData\envs\agent\lib\concurrent\futures\_base.py", line 391, in __get_result
    raise self._exception
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\provider\openai_api.py", line 141, in acompletion_text
    return await self._achat_completion_stream(messages, timeout=timeout)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\provider\openai_api.py", line 94, in _achat_completion_stream
    usage = CompletionUsage(**chunk.usage)
TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not CompletionUsage

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\utils\common.py", line 640, in wrapper
    return await func(self, *args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\roles\role.py", line 550, in run
    rsp = await self.react()
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\roles\role.py", line 517, in react
    rsp = await self._react()
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\roles\role.py", line 463, in _react
    rsp = await self._act()
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\roles\base_player.py", line 101, in _act
    await Reflect().run(
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
  File "D:\ProgramData\envs\agent\lib\site-packages\tenacity\__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x1e8ddda8b80 state=finished raised TypeError>]


Traceback (most recent call last):
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\start_game.py", line 68, in <module>
    fire.Fire(main)
  File "D:\ProgramData\envs\agent\lib\site-packages\fire\core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "D:\ProgramData\envs\agent\lib\site-packages\fire\core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "D:\ProgramData\envs\agent\lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\start_game.py", line 53, in main
    asyncio.run(
  File "D:\ProgramData\envs\agent\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\ProgramData\envs\agent\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "E:\Project_python\llm_related\knowledge_distillation_llm\Agent\werewolf\start_game.py", line 40, in start_game
    await game.run(n_round=n_round)
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\utils\common.py", line 632, in wrapper
    self.serialize()  # Team.serialize
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\team.py", line 60, in serialize
    write_json_file(team_info_path, self.model_dump())
  File "D:\ProgramData\envs\agent\lib\site-packages\metagpt\utils\common.py", line 581, in write_json_file
    json.dump(data, fout, ensure_ascii=False, indent=indent, default=to_jsonable_python)
  File "D:\ProgramData\envs\agent\lib\json\__init__.py", line 179, in dump
    for chunk in iterable:
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 405, in _iterencode_dict
    yield from chunks
  [Previous line repeated 1 more time]
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "D:\ProgramData\envs\agent\lib\json\encoder.py", line 438, in _iterencode
    o = _default(o)
pydantic_core._pydantic_core.PydanticSerializationError: Unable to serialize unknown type: <class 'pydantic._internal._model_construction.ModelMetaclass'>

**Screenshots or logs**
<!-- Screenshots or logs of the bug can help us understand the problem more quickly -->
@Terrdi
Copy link

Terrdi commented Feb 14, 2025

我修复了这个bug,但是还没有merge
https://github.com/Terrdi/MetaGPT/tree/fix-serialize-error
你试试这个分支呢

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