mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-23 15:48:11 +02:00
update ser&deser code
This commit is contained in:
parent
57121ef395
commit
68c8ef1073
8 changed files with 70 additions and 121 deletions
|
|
@ -84,7 +84,7 @@ async def test_role_serdeser_interrupt():
|
|||
logger.error(f"Exception in `role_a.run`, detail: {format_trackback_info()}")
|
||||
role_c.serialize(stg_path)
|
||||
|
||||
assert role_c._rc.memory.count() == 2
|
||||
assert role_c._rc.memory.count() == 1
|
||||
|
||||
new_role_a: Role = Role.deserialize(stg_path)
|
||||
assert new_role_a._rc.state == 1
|
||||
|
|
|
|||
|
|
@ -106,11 +106,23 @@ async def test_team_recover_multi_roles_save():
|
|||
stg_path = SERDESER_PATH.joinpath("team")
|
||||
shutil.rmtree(stg_path, ignore_errors=True)
|
||||
|
||||
role_a = RoleA()
|
||||
role_b = RoleB()
|
||||
|
||||
assert role_a.subscription == {"tests.metagpt.serialize_deserialize.test_serdeser_base.RoleA",
|
||||
"RoleA"}
|
||||
assert role_b.subscription == {"tests.metagpt.serialize_deserialize.test_serdeser_base.RoleB",
|
||||
"RoleB"}
|
||||
assert role_b._rc.watch == {"tests.metagpt.serialize_deserialize.test_serdeser_base.ActionPass"}
|
||||
|
||||
company = Team()
|
||||
company.hire([RoleA(), RoleB()])
|
||||
company.hire([role_a, role_b])
|
||||
company.run_project(idea)
|
||||
await company.run(n_round=4)
|
||||
|
||||
new_company = Team.recover(stg_path)
|
||||
new_company.run_project(idea)
|
||||
|
||||
assert new_company.env.get_role(role_b.profile)._rc.state == 1
|
||||
|
||||
await new_company.run(n_round=4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue