mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
fixbug: exceed length
This commit is contained in:
parent
ae414fccfa
commit
3454761f95
2 changed files with 4 additions and 3 deletions
|
|
@ -8,7 +8,7 @@
|
|||
"""
|
||||
|
||||
from enum import Enum
|
||||
from typing import List, Dict
|
||||
from typing import Dict, List
|
||||
|
||||
import pydantic
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ class BrainMemory(pydantic.BaseModel):
|
|||
texts = [Message(**m).content for m in self.history[:-1]]
|
||||
return "\n".join(texts)
|
||||
|
||||
def move_to_solution(self):
|
||||
def move_to_solution(self, history_summary):
|
||||
if len(self.history) < 2:
|
||||
return
|
||||
msgs = self.history[:-1]
|
||||
|
|
@ -58,6 +58,7 @@ class BrainMemory(pydantic.BaseModel):
|
|||
self.history = []
|
||||
else:
|
||||
self.history = self.history[-1:]
|
||||
self.history.insert(0, Message(content=history_summary))
|
||||
|
||||
@property
|
||||
def last_talk(self):
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class Assistant(Role):
|
|||
last_talk = await self._llm.rewrite(sentence=last_talk, context=history_text)
|
||||
return last_talk
|
||||
|
||||
self.memory.move_to_solution() # Promptly clear memory after the issue is resolved.
|
||||
self.memory.move_to_solution(history_summary) # Promptly clear memory after the issue is resolved.
|
||||
return last_talk
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue