Skip to content

Commit ebf9df0

Browse files
committed
fix: reverse chat history order for chronological display
1 parent afe3ff5 commit ebf9df0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

apps/application/long_term_memory/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _run_extract(workspace_id, application_id, chat_user_id, config, history_lim
132132
QuerySet(ChatRecord).filter(
133133
chat__application_id=application_id,
134134
chat__chat_user_id=chat_user_id,
135-
).order_by('create_time').only('problem_text', 'answer_text')[:history_limit]
135+
).order_by('-create_time').only('problem_text', 'answer_text')[:history_limit]
136136
)
137137
if len(history_chat_record) <= 1:
138138
return
@@ -149,6 +149,8 @@ def _run_extract(workspace_id, application_id, chat_user_id, config, history_lim
149149

150150
existing_memory = long_term_memory.memory if long_term_memory else ''
151151

152+
# 反转为时间正序(旧→新)
153+
history_chat_record = list(reversed(history_chat_record))
152154

153155
new_conversation = '\n'.join(
154156
line

0 commit comments

Comments
 (0)