feat: merge fixbug/geekan/v0.5-release

This commit is contained in:
莘权 马 2023-12-18 16:39:02 +08:00
commit 5593008110
7 changed files with 52 additions and 6 deletions

View file

@ -28,6 +28,7 @@ from pydantic import BaseModel, Field
from metagpt.actions import Action, ActionOutput
from metagpt.actions.action_node import ActionNode
from metagpt.actions.role_run import RoleRun
from metagpt.llm import LLM, HumanProvider
from metagpt.logs import logger
from metagpt.memory import Memory
@ -317,7 +318,9 @@ class Role:
old_messages = [] if ignore_memory else self._rc.memory.get()
self._rc.memory.add_batch(news)
# Filter out messages of interest.
self._rc.news = [n for n in news if n.cause_by in self._rc.watch and n not in old_messages]
watch = self._rc.watch or set()
watch.add(any_to_str(RoleRun))
self._rc.news = [n for n in news if n.cause_by in watch and n not in old_messages]
# Design Rules:
# If you need to further categorize Message objects, you can do so using the Message.set_meta function.
@ -397,6 +400,8 @@ class Role:
msg = with_message
elif isinstance(with_message, list):
msg = Message("\n".join(with_message))
if not msg.cause_by:
msg.cause_by = RoleRun
self.put_message(msg)
if not await self._observe():