fixbug: exceed length

This commit is contained in:
莘权 马 2023-09-01 21:16:56 +08:00
parent ae414fccfa
commit 3454761f95
2 changed files with 4 additions and 3 deletions

View file

@ -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):

View file

@ -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