浏览代码

Fix clear history

oobabooga 2 年之前
父节点
当前提交
f24b6e78a3
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      modules/chat.py

+ 5 - 0
modules/chat.py

@@ -216,11 +216,16 @@ def clear_html():
 
 
 def clear_chat_log(name1, name2):
 def clear_chat_log(name1, name2):
     if shared.character != 'None':
     if shared.character != 'None':
+        found = False
         for i in range(len(shared.history['internal'])):
         for i in range(len(shared.history['internal'])):
             if '<|BEGIN-VISIBLE-CHAT|>' in shared.history['internal'][i][0]:
             if '<|BEGIN-VISIBLE-CHAT|>' in shared.history['internal'][i][0]:
                 shared.history['visible'] = [['', apply_extensions(shared.history['internal'][i][1], "output")]]
                 shared.history['visible'] = [['', apply_extensions(shared.history['internal'][i][1], "output")]]
                 shared.history['internal'] = shared.history['internal'][:i+1]
                 shared.history['internal'] = shared.history['internal'][:i+1]
+                found = True
                 break
                 break
+        if not found:
+            shared.history['visible'] = []
+            shared.history['internal'] = []
     else:
     else:
         shared.history['internal'] = []
         shared.history['internal'] = []
         shared.history['visible'] = []
         shared.history['visible'] = []