From f32d26240da55daba074a9bede27675d2ce9f497 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:03:05 -0700 Subject: [PATCH] UI: Fix the chat "stop" event --- modules/chat.py | 10 +--------- modules/ui_chat.py | 5 +++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index c744defc..18fee9fa 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -26,8 +26,7 @@ from modules.logging_colors import logger from modules.text_generation import ( generate_reply, get_encoded_length, - get_max_prompt_length, - stop_everything_event + get_max_prompt_length ) from modules.utils import delete_file, get_available_characters, save_file @@ -1036,13 +1035,6 @@ def handle_remove_last_click(state): return [history, html, last_input] -def handle_stop_click(state): - stop_everything_event() - html = redraw_html(state['history'], state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu']) - - return html - - def handle_unique_id_select(state): history = load_history(state['unique_id'], state['character_menu'], state['mode']) html = redraw_html(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu']) diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 7ef8df4d..cce1cc49 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -7,6 +7,7 @@ from PIL import Image from modules import chat, shared, ui, utils from modules.html_generator import chat_html_wrapper +from modules.text_generation import stop_everything_event from modules.utils import gradio inputs = ('Chat input', 'interface_state') @@ -221,8 +222,8 @@ def create_event_handlers(): chat.handle_remove_last_click, gradio('interface_state'), gradio('history', 'display', 'textbox'), show_progress=False) shared.gradio['Stop'].click( - ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( - chat.handle_stop_click, gradio('interface_state'), gradio('display'), show_progress=False) + stop_everything_event, None, None, queue=False).then( + chat.redraw_html, gradio(reload_arr), gradio('display')) if not shared.args.multi_user: shared.gradio['unique_id'].select(