Fix shrink history for short path case.

This commit is contained in:
OK 2023-04-12 19:59:27 +02:00
parent b1a38d5e86
commit 536930d426

View File

@ -156,8 +156,8 @@ class AIResponder(object):
user_ma = re.match(user_re, message.user) user_ma = re.match(user_re, message.user)
if chan_ma and user_ma: if chan_ma and user_ma:
self.history.append({"role": "user", "content": str(message)}) self.history.append({"role": "user", "content": str(message)})
if len(self.history) > limit: while len(self.history) > limit:
self.history = self.history[-limit:] self.shrink_history_by_one()
if self.history_file is not None: if self.history_file is not None:
with open(self.history_file, 'wb') as fd: with open(self.history_file, 'wb') as fd:
pickle.dump(self.history, fd) pickle.dump(self.history, fd)