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

Fix the reference index used when deleting a chat message pair.

Each user/assistant message pair shares one reference entry, while the
first assistant prologue has no reference. Using `i // 2` correctly
removes the reference for the deleted pair and avoids deleting the
previous turn's reference.
This commit is contained in:
Hz_
2026-06-29 19:05:25 +08:00
committed by GitHub
parent 445a13ee9a
commit a10a2d8769

View File

@@ -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))