refactor: cause_by

This commit is contained in:
莘权 马 2023-11-10 16:48:34 +08:00
parent efe6ead27c
commit 44aa1dd563
6 changed files with 22 additions and 25 deletions

View file

@ -15,6 +15,7 @@ from metagpt.logs import logger
from metagpt.roles import Role
from metagpt.schema import Message
from metagpt.software_company import SoftwareCompany
from metagpt.utils.common import any_to_str
class ShoutOut(Action):
@ -101,7 +102,9 @@ class Biden(Role):
await super()._observe()
# accept the very first human instruction (the debate topic) or messages sent (from opponent) to self,
# disregard own messages from the last round
self._rc.news = [msg for msg in self._rc.news if msg.cause_by == BossRequirement or msg.send_to == {self.name}]
self._rc.news = [
msg for msg in self._rc.news if msg.cause_by == any_to_str(BossRequirement) or msg.send_to == {self.name}
]
return len(self._rc.news)
async def _act(self) -> Message: