AttributeError: ‘NoneType‘ object has no attribute ‘profile‘
最近在学习MetaGPT:https://github.com/geekan/MetaGPT
在多智能体入门(多智能体入门 | MetaGPT)以及辩论:智能体对抗(辩论:智能体对抗 | MetaGPT)中,代码均会报错:
(venv) PS D:\研究生\pythonProject2\文化设施社交媒体\examples> python .\debate.py --idea "Talk about how the U.S. should respond to climate change"
2025-03-19 22:06:54.115 | INFO | metagpt.const:get_metagpt_package_root:15 - Package root set to D:\研究生\pythonProject2\venv\Lib\site-packages
2025-03-19 22:06:54.117 | INFO | metagpt.const:get_metagpt_package_root:15 - Package root set to D:\研究生\pythonProject2\venv\Lib\site-packages
Traceback (most recent call last):
File "D:\研究生\pythonProject2\文化设施社交媒体\examples\debate.py", line 109, in <module>
fire.Fire(main) # run as python debate.py --idea="TOPIC" --investment=3.0 --n_round=5
^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\venv\Lib\site-packages\fire\core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\venv\Lib\site-packages\fire\core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\venv\Lib\site-packages\fire\core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\文化设施社交媒体\examples\debate.py", line 105, in main
asyncio.run(debate(idea, investment, n_round))
File "C:\Users\THUNDEROBOT\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\THUNDEROBOT\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\THUNDEROBOT\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\文化设施社交媒体\examples\debate.py", line 91, in debate
team.run_project(idea, send_to="Biden") # send debate topic to Biden and let him speak first
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\研究生\pythonProject2\venv\Lib\site-packages\metagpt\team.py", line 107, in run_project
self.env.publish_message(Message(content=idea))
File "D:\研究生\pythonProject2\venv\Lib\site-packages\metagpt\environment\mgx\mgx_env.py", line 48, in publish_message
elif publicer == tl.profile:
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'profile'

据官方修复(https://github.com/geekan/MetaGPT/pull/1759),需要引入Teamleader:
即添加:
from metagpt.roles.di.team_leader import TeamLeader
以及
team.hire([TeamLeader(), ......])
from metagpt.roles.di.team_leader import TeamLeader
......
......
async def main(
idea: str = "write a function that calculates the product of a list",
investment: float = 0.1,
n_round: int = 3,
add_human: bool = False,
):
logger.info(idea)
team = Team()
team.hire(
[
TeamLeader(),
SimpleCoder(),
SimpleTester(),
SimpleReviewer(is_human=True),
]
)
team.invest(investment=investment)
team.run_project(idea)
await team.run(n_round=n_round)
更多推荐
所有评论(0)