add simplest debate example

This commit is contained in:
geekan 2023-12-22 13:05:27 +08:00
parent dd57c45bbe
commit 49377c9db0
7 changed files with 71 additions and 21 deletions

View file

@ -28,6 +28,7 @@ class Environment(BaseModel):
Environment, hosting a batch of roles, roles can publish messages to the environment, and can be observed by other roles
"""
desc: str = Field(default="") # 环境描述
roles: dict[str, Role] = Field(default_factory=dict)
members: dict[Role, Set] = Field(default_factory=dict)
history: str = "" # For debug
@ -151,6 +152,9 @@ class Environment(BaseModel):
"""
return self.roles.get(name, None)
def role_names(self) -> str:
return ", ".join([f"{i.name}" for i in self.roles.values()])
@property
def is_idle(self):
"""If true, all actions have been executed."""