From ae1fe45bc0115a415f1299f4f401306c6ac9f9c6 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 4 Apr 2023 23:15:57 -0300 Subject: [PATCH] One more cache reset --- modules/chat.py | 7 ++++++- server.py | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index 1fbda6b6..21d9d16d 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -423,7 +423,7 @@ def upload_tavern_character(img, name1, name2): _json = {"char_name": _json['name'], "char_persona": _json['description'], "char_greeting": _json["first_mes"], "example_dialogue": _json['mes_example'], "world_scenario": _json['scenario']} return upload_character(json.dumps(_json), img, tavern=True) -def upload_your_profile_picture(img): +def upload_your_profile_picture(img, name1, name2): cache_folder = Path("cache") if not cache_folder.exists(): cache_folder.mkdir() @@ -435,3 +435,8 @@ def upload_your_profile_picture(img): img = make_thumbnail(img) img.save(Path('cache/pfp_me.png')) print('Profile picture saved to "cache/pfp_me.png"') + + if shared.args.cai_chat: + return generate_chat_html(shared.history['visible'], name1, name2, reset_cache=True) + else: + return shared.history['visible'] diff --git a/server.py b/server.py index f9bf3d76..a34c86f7 100644 --- a/server.py +++ b/server.py @@ -406,12 +406,11 @@ def create_interface(): shared.gradio['character_menu'].change(chat.load_character, [shared.gradio[k] for k in ['character_menu', 'name1', 'name2']], [shared.gradio[k] for k in ['name1', 'name2', 'character_picture', 'greeting', 'context', 'display']]) shared.gradio['upload_chat_history'].upload(chat.load_history, [shared.gradio['upload_chat_history'], shared.gradio['name1'], shared.gradio['name2']], []) shared.gradio['upload_img_tavern'].upload(chat.upload_tavern_character, [shared.gradio['upload_img_tavern'], shared.gradio['name1'], shared.gradio['name2']], [shared.gradio['character_menu']]) - shared.gradio['your_picture'].change(chat.upload_your_profile_picture, shared.gradio['your_picture'], None) + shared.gradio['your_picture'].change(chat.upload_your_profile_picture, [shared.gradio[k] for k in ['your_picture', 'name1', 'name2']], shared.gradio['display']) reload_func = chat.redraw_html if shared.args.cai_chat else lambda : shared.history['visible'] reload_inputs = [shared.gradio['name1'], shared.gradio['name2']] if shared.args.cai_chat else [] shared.gradio['upload_chat_history'].upload(reload_func, reload_inputs, [shared.gradio['display']]) - shared.gradio['your_picture'].change(reload_func, reload_inputs, [shared.gradio['display']]) shared.gradio['Stop'].click(reload_func, reload_inputs, [shared.gradio['display']]) shared.gradio['interface'].load(None, None, None, _js=f"() => {{{ui.main_js+ui.chat_js}}}")