Use current input for Impersonate (continue impersonate feature) (#1147)

This commit is contained in:
Kamil Szurant 2023-05-09 07:37:42 +02:00 committed by GitHub
parent a5bb278631
commit 641500dcb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -229,11 +229,11 @@ def impersonate_wrapper(text, state):
# Defining some variables # Defining some variables
cumulative_reply = '' cumulative_reply = ''
eos_token = '\n' if state['stop_at_newline'] else None 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) stopping_strings = get_stopping_strings(state)
# Yield *Is typing...* yield text + '...'
yield shared.processing_message cumulative_reply = text
for i in range(state['chat_generation_attempts']): for i in range(state['chat_generation_attempts']):
reply = None 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): for reply in generate_reply(f"{prompt}{' ' if len(cumulative_reply) > 0 else ''}{cumulative_reply}", state, eos_token=eos_token, stopping_strings=stopping_strings):

View File

@ -714,6 +714,7 @@ def create_interface():
gen_events.append(shared.gradio['Impersonate'].click( 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( 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) chat.impersonate_wrapper, shared.input_params, shared.gradio['textbox'], show_progress=False)
) )