From 589069e105840b520d5f6c1632bfef42a513b208 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 16 Feb 2023 12:32:35 -0300 Subject: [PATCH] Don't regenerate if no message has been sent --- server.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server.py b/server.py index 94c35f90..1d7eeafa 100644 --- a/server.py +++ b/server.py @@ -612,16 +612,22 @@ def cai_chatbot_wrapper(text, tokens, do_sample, max_new_tokens, temperature, to yield generate_chat_html(_history, name1, name2, character) def regenerate_wrapper(text, tokens, do_sample, max_new_tokens, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, name1, name2, context, check, chat_prompt_size, picture=None): - last_visible = history['visible'].pop() - last_internal = history['internal'].pop() - - for _history in chatbot_wrapper(last_internal[0], tokens, do_sample, max_new_tokens, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, name1, name2, context, check, chat_prompt_size, picture): + if character is not None and len(history['visible']) == 1: if args.cai_chat: - history['visible'][-1] = [last_visible[0], _history[-1][1]] yield generate_chat_html(history['visible'], name1, name2, character) else: - history['visible'][-1] = (last_visible[0], _history[-1][1]) yield history['visible'] + else: + last_visible = history['visible'].pop() + last_internal = history['internal'].pop() + + for _history in chatbot_wrapper(last_internal[0], tokens, do_sample, max_new_tokens, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, name1, name2, context, check, chat_prompt_size, picture): + if args.cai_chat: + history['visible'][-1] = [last_visible[0], _history[-1][1]] + yield generate_chat_html(history['visible'], name1, name2, character) + else: + history['visible'][-1] = (last_visible[0], _history[-1][1]) + yield history['visible'] def remove_last_message(name1, name2): if not history['internal'][-1][0] == '<|BEGIN-VISIBLE-CHAT|>':