From 27e2d932b0c931a92981b2841b250ba3021a19fb Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sat, 21 Jan 2023 02:55:13 -0300 Subject: [PATCH] Don't export include the example dialogue in the export json --- server.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 69234eda..5bb6cce6 100644 --- a/server.py +++ b/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):