Просмотр исходного кода

Don't export include the example dialogue in the export json

oobabooga 3 лет назад
Родитель
Сommit
27e2d932b0
1 измененных файлов с 8 добавлено и 1 удалено
  1. 8 1
      server.py

+ 8 - 1
server.py

@@ -327,10 +327,17 @@ if args.chat or args.cai_chat:
         return generate_chat_html(history, name1, name2, character)
 
     def save_history():
+        _history = copy.deepcopy(history)
+        for i in range(len(_history)):
+            if '<|BEGIN-VISIBLE-CHAT|>' in history[i][0]:
+                _history[i][0] = _history[i][0].replace('<|BEGIN-VISIBLE-CHAT|>', '')
+                _history = _history[i:]
+                break
+
         if not Path('logs').exists():
             Path('logs').mkdir()
         with open(Path('logs/conversation.json'), 'w') as f:
-            f.write(json.dumps({'data': history}))
+            f.write(json.dumps({'data': _history}))
         return Path('logs/conversation.json')
 
     def load_history(file):