mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-03 04:42:38 +02:00
update: 优化记忆
This commit is contained in:
parent
847a79d822
commit
1e7f056918
1 changed files with 1 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ class BrainMemory(pydantic.BaseModel):
|
|||
historical_summary: str = ""
|
||||
last_history_id: str = ""
|
||||
is_dirty: bool = False
|
||||
last_talk: str = ""
|
||||
|
||||
def add_talk(self, msg: Message):
|
||||
msg.add_tag(MessageType.Talk.value)
|
||||
|
|
@ -65,15 +66,6 @@ class BrainMemory(pydantic.BaseModel):
|
|||
|
||||
return "\n".join(texts)
|
||||
|
||||
@property
|
||||
def last_talk(self):
|
||||
if len(self.history) == 0:
|
||||
return None
|
||||
last_msg = Message(**self.history[-1])
|
||||
if not last_msg.is_contain(MessageType.Talk.value):
|
||||
return None
|
||||
return last_msg.content
|
||||
|
||||
@staticmethod
|
||||
async def loads(redis_key: str, redis_conf: Dict = None) -> "BrainMemory":
|
||||
redis = Redis(conf=redis_conf)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue