From 70e034589f4573b2fe84435850c0a0c97a61cc13 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 27 Jan 2023 02:16:05 -0300 Subject: [PATCH] Update the export/load chat history functions --- server.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index b51425db..fd6f8b87 100644 --- a/server.py +++ b/server.py @@ -443,7 +443,7 @@ if args.chat or args.cai_chat: if not Path('logs').exists(): Path('logs').mkdir() with open(Path('logs/conversation.json'), 'w') as f: - f.write(json.dumps({'data': history['internal']}, indent=2)) + f.write(json.dumps({'data': history['internal'], 'data_visible': history['visible']})) return Path('logs/conversation.json') def upload_history(file, name1, name2): @@ -453,6 +453,10 @@ if args.chat or args.cai_chat: j = json.loads(file) if 'data' in j: history['internal'] = j['data'] + if 'data_visible' in j: + history['visible'] = j['data_visible'] + else: + history['visible'] = history['internal'] # Compatibility with Pygmalion AI's official web UI elif 'chat' in j: history['internal'] = [':'.join(x.split(':')[1:]).strip() for x in j['chat']] @@ -462,6 +466,7 @@ if args.chat or args.cai_chat: history['internal'] = [[history['internal'][i], history['internal'][i+1]] for i in range(0, len(history['internal'])-1, 2)] except: history['internal'] = tokenize_dialogue(file, name1, name2) + history['visible'] = history['internal'] def load_character(_character, name1, name2): global history, character