fix role add actions

This commit is contained in:
better629 2023-12-27 15:03:34 +08:00
parent 83dbf97819
commit 7d523b3922
4 changed files with 23 additions and 16 deletions

View file

@ -17,9 +17,11 @@ from metagpt.roles.role import Role
from metagpt.schema import Message
from metagpt.utils.common import format_trackback_info
from tests.metagpt.serialize_deserialize.test_serdeser_base import (
ActionOK,
RoleA,
RoleB,
RoleC,
RoleD,
serdeser_path,
)
@ -31,6 +33,9 @@ def test_roles():
assert len(role_a.rc.watch) == 1
assert len(role_b.rc.watch) == 1
role_d = RoleD(actions=[ActionOK()])
assert len(role_d.actions) == 1
def test_role_serialize():
role = Role()

View file

@ -91,3 +91,10 @@ class RoleC(Role):
self._watch([UserRequirement])
self.rc.react_mode = RoleReactMode.BY_ORDER
self.rc.memory.ignore_id = True
class RoleD(Role):
name: str = Field(default="RoleD")
profile: str = Field(default="Role D")
goal: str = "RoleD's goal"
constraints: str = "RoleD's constraints"