Fix metadata leaking into branched chats

This commit is contained in:
oobabooga 2025-10-11 14:12:05 -07:00
parent 1831b3fb51
commit c7dd920dc8

View file

@ -1831,6 +1831,10 @@ def handle_branch_chat_click(state):
history = state['history']
history['visible'] = history['visible'][:branch_from_index + 1]
history['internal'] = history['internal'][:branch_from_index + 1]
# Prune the metadata dictionary to remove entries beyond the branch point
if 'metadata' in history:
history['metadata'] = {k: v for k, v in history['metadata'].items() if int(k.split('_')[-1]) <= branch_from_index}
new_unique_id = datetime.now().strftime('%Y%m%d-%H-%M-%S')
save_history(history, new_unique_id, state['character_menu'], state['mode'])