UI: Fix the chat "stop" event

This commit is contained in:
oobabooga 2024-07-26 23:03:05 -07:00
parent 9e82f8c394
commit f32d26240d
2 changed files with 4 additions and 11 deletions

View File

@ -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'])

View File

@ -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(