From 641500dcb94c92e5b0872cdf2cf299458421d756 Mon Sep 17 00:00:00 2001 From: Kamil Szurant Date: Tue, 9 May 2023 07:37:42 +0200 Subject: [PATCH] Use current input for Impersonate (continue impersonate feature) (#1147) --- modules/chat.py | 6 +++--- server.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index a19eb0e9..bb7c3c6e 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -229,11 +229,11 @@ def impersonate_wrapper(text, state): # Defining some variables cumulative_reply = '' eos_token = '\n' if state['stop_at_newline'] else None - prompt = generate_chat_prompt(text, state, impersonate=True) + prompt = generate_chat_prompt('', state, impersonate=True) stopping_strings = get_stopping_strings(state) - # Yield *Is typing...* - yield shared.processing_message + yield text + '...' + cumulative_reply = text for i in range(state['chat_generation_attempts']): reply = None for reply in generate_reply(f"{prompt}{' ' if len(cumulative_reply) > 0 else ''}{cumulative_reply}", state, eos_token=eos_token, stopping_strings=stopping_strings): diff --git a/server.py b/server.py index 7382ffcd..6c94738a 100644 --- a/server.py +++ b/server.py @@ -714,6 +714,7 @@ def create_interface(): gen_events.append(shared.gradio['Impersonate'].click( ui.gather_interface_values, [shared.gradio[k] for k in shared.input_elements], shared.gradio['interface_state']).then( + lambda x: x, shared.gradio['textbox'], shared.gradio['Chat input'], show_progress=False).then( chat.impersonate_wrapper, shared.input_params, shared.gradio['textbox'], show_progress=False) )