fixbug: exceed length

This commit is contained in:
莘权 马 2023-09-01 21:30:38 +08:00
parent 8c943dd8e9
commit f7ebd2a374

View file

@ -45,7 +45,16 @@ class BrainMemory(pydantic.BaseModel):
def history_text(self):
if len(self.history) == 0:
return ""
texts = [Message(**m).content for m in self.history[:-1]]
texts = []
for m in self.history[:-1]:
if isinstance(m, Dict):
t = Message(**m).content
elif isinstance(m, Message):
t = m.content
else:
continue
texts.append(t)
return "\n".join(texts)
def move_to_solution(self, history_summary):