Skip to content

Commit

Permalink
fix: remove the latest message from the user that does not have any a…
Browse files Browse the repository at this point in the history
…nswer yet (langgenius#9297)
  • Loading branch information
kurokobo authored and JunXu01 committed Nov 9, 2024
1 parent 4bc764c commit e5d8fe8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/core/memory/token_buffer_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def get_history_prompt_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
if thread_messages and not thread_messages[-1].answer:
thread_messages.pop()
if thread_messages and not thread_messages[0].answer:
thread_messages.pop(0)

messages = list(reversed(thread_messages))

Expand Down

0 comments on commit e5d8fe8

Please sign in to comment.