From 4e4cd672239748e19d8d73f76f210a6ccc4d1774 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 3 Feb 2023 09:02:35 -0300 Subject: [PATCH] Save chat history with name/date in filename closes #50 --- server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 7135633..fcbda1c 100644 --- a/server.py +++ b/server.py @@ -9,6 +9,7 @@ import io import base64 import sys import os +from datetime import datetime from pathlib import Path from PIL import Image import copy @@ -563,11 +564,12 @@ if args.chat or args.cai_chat: return _history def save_history(): + fname = f"{character or ''}{'_' if character else ''}{datetime.now().strftime('%Y%m%d-%H:%M:%S')}.json" if not Path('logs').exists(): Path('logs').mkdir() - with open(Path('logs/conversation.json'), 'w') as f: + with open(Path(f'logs/{fname}'), 'w') as f: f.write(json.dumps({'data': history['internal'], 'data_visible': history['visible']})) - return Path('logs/conversation.json') + return Path(f'logs/{fname}') def upload_history(file, name1, name2): global history