Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(py): chat message reference deletion index (#16436)

Hz_a10a2d8769ab
diff --git a/api/apps/restful_apis/chat_api.py b/api/apps/restful_apis/chat_api.py
index 5ea6bd3fcc..605b473137 100644
--- a/api/apps/restful_apis/chat_api.py
+++ b/api/apps/restful_apis/chat_api.py
@@ -929,7 +929,8 @@ async def delete_session_message(chat_id, session_id, msg_id):
assert conv["message"][i + 1]["id"] == msg_id
conv["message"].pop(i)
conv["message"].pop(i)
- conv["reference"].pop(max(0, i // 2 - 1))
+ ref_index = (i - 1) // 2
+ conv["reference"].pop(ref_index)
break
ConversationService.update_by_id(conv["id"], conv)
return get_json_result(data=_build_session_response(conv))