Skip to content

Commit

Permalink
Show progress on impersonate
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Sep 13, 2023
1 parent 7cd437e commit 8ce94b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions modules/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,21 @@ def chatbot_wrapper(text, state, regenerate=False, _continue=False, loading_mess


def impersonate_wrapper(text, state):

static_output = chat_html_wrapper(state['history'], state['name1'], state['name2'], state['mode'], state['chat_style'])

if shared.model_name == 'None' or shared.model is None:
logger.error("No model is loaded! Select one in the Model tab.")
yield ''
yield '', static_output
return

prompt = generate_chat_prompt('', state, impersonate=True)
stopping_strings = get_stopping_strings(state)

yield text + '...'
yield text + '...', static_output
reply = None
for reply in generate_reply(prompt + text, state, stopping_strings=stopping_strings, is_chat=True):
yield (text + reply).lstrip(' ')
yield (text + reply).lstrip(' '), static_output
if shared.stop_everything:
return

Expand Down
2 changes: 1 addition & 1 deletion modules/ui_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def create_event_handlers():
shared.gradio['Impersonate'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x: x, gradio('textbox'), gradio('Chat input'), show_progress=False).then(
chat.impersonate_wrapper, gradio(inputs), gradio('textbox'), show_progress=False).then(
chat.impersonate_wrapper, gradio(inputs), gradio('textbox', 'display'), show_progress=False).then(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda: None, None, None, _js=f'() => {{{ui.audio_notification_js}}}')

Expand Down

0 comments on commit 8ce94b7

Please sign in to comment.