fix: remove the latest message from the user that does not have any answer yet (#9297)

This commit is contained in:
kurokobo 2024-10-14 00:25:50 +09:00 committed by GitHub
parent d15ba3939d
commit 857055b797
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,8 +60,8 @@ class TokenBufferMemory:
thread_messages = extract_thread_messages(messages) thread_messages = extract_thread_messages(messages)
# for newly created message, its answer is temporarily empty, we don't need to add it to memory # for newly created message, its answer is temporarily empty, we don't need to add it to memory
if thread_messages and not thread_messages[-1].answer: if thread_messages and not thread_messages[0].answer:
thread_messages.pop() thread_messages.pop(0)
messages = list(reversed(thread_messages)) messages = list(reversed(thread_messages))