|
@@ -84,7 +84,7 @@ def extract_message_from_reply(question, reply, current, other, check, extension
|
|
|
def stop_everything_event():
|
|
def stop_everything_event():
|
|
|
shared.stop_everything = True
|
|
shared.stop_everything = True
|
|
|
|
|
|
|
|
-def chatbot_wrapper(text, max_new_tokens, do_sample, 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, greed=1):
|
|
|
|
|
|
|
+def chatbot_wrapper(text, max_new_tokens, do_sample, 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, chat_generation_attempts=1):
|
|
|
shared.stop_everything = False
|
|
shared.stop_everything = False
|
|
|
just_started = True
|
|
just_started = True
|
|
|
eos_token = '\n' if check else None
|
|
eos_token = '\n' if check else None
|
|
@@ -113,7 +113,7 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
|
|
|
|
|
|
|
|
# Generate
|
|
# Generate
|
|
|
reply = ''
|
|
reply = ''
|
|
|
- for i in range(greed):
|
|
|
|
|
|
|
+ for i in range(chat_generation_attempts):
|
|
|
for reply in generate_reply(prompt+reply, max_new_tokens, do_sample, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, eos_token=eos_token, stopping_string=f"\n{name1}:"):
|
|
for reply in generate_reply(prompt+reply, max_new_tokens, do_sample, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, eos_token=eos_token, stopping_string=f"\n{name1}:"):
|
|
|
|
|
|
|
|
# Extracting the reply
|
|
# Extracting the reply
|
|
@@ -138,9 +138,8 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
|
|
|
if next_character_found:
|
|
if next_character_found:
|
|
|
break
|
|
break
|
|
|
yield shared.history['visible']
|
|
yield shared.history['visible']
|
|
|
- print(i, reply)
|
|
|
|
|
|
|
|
|
|
-def impersonate_wrapper(text, max_new_tokens, do_sample, 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):
|
|
|
|
|
|
|
+def impersonate_wrapper(text, max_new_tokens, do_sample, 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, generation_attempts=1):
|
|
|
eos_token = '\n' if check else None
|
|
eos_token = '\n' if check else None
|
|
|
|
|
|
|
|
if 'pygmalion' in shared.model_name.lower():
|
|
if 'pygmalion' in shared.model_name.lower():
|
|
@@ -148,19 +147,21 @@ def impersonate_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typ
|
|
|
|
|
|
|
|
prompt = generate_chat_prompt(text, max_new_tokens, name1, name2, context, chat_prompt_size, impersonate=True)
|
|
prompt = generate_chat_prompt(text, max_new_tokens, name1, name2, context, chat_prompt_size, impersonate=True)
|
|
|
|
|
|
|
|
- for reply in generate_reply(prompt, max_new_tokens, do_sample, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, eos_token=eos_token, stopping_string=f"\n{name2}:"):
|
|
|
|
|
- reply, next_character_found, substring_found = extract_message_from_reply(prompt, reply, name1, name2, check, extensions=False)
|
|
|
|
|
- if not substring_found:
|
|
|
|
|
- yield reply
|
|
|
|
|
- if next_character_found:
|
|
|
|
|
- break
|
|
|
|
|
- yield reply
|
|
|
|
|
|
|
+ reply = ''
|
|
|
|
|
+ for i in range(generation_attempts):
|
|
|
|
|
+ for reply in generate_reply(prompt+reply, max_new_tokens, do_sample, temperature, top_p, typical_p, repetition_penalty, top_k, min_length, no_repeat_ngram_size, num_beams, penalty_alpha, length_penalty, early_stopping, eos_token=eos_token, stopping_string=f"\n{name2}:"):
|
|
|
|
|
+ reply, next_character_found, substring_found = extract_message_from_reply(prompt, reply, name1, name2, check, extensions=False)
|
|
|
|
|
+ if not substring_found:
|
|
|
|
|
+ yield reply
|
|
|
|
|
+ if next_character_found:
|
|
|
|
|
+ break
|
|
|
|
|
+ yield reply
|
|
|
|
|
|
|
|
-def cai_chatbot_wrapper(text, max_new_tokens, do_sample, 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, greed=1):
|
|
|
|
|
- for _history in chatbot_wrapper(text, max_new_tokens, do_sample, 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, greed):
|
|
|
|
|
|
|
+def cai_chatbot_wrapper(text, max_new_tokens, do_sample, 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, chat_generation_attempts=1):
|
|
|
|
|
+ for _history in chatbot_wrapper(text, max_new_tokens, do_sample, 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, chat_generation_attempts):
|
|
|
yield generate_chat_html(_history, name1, name2, shared.character)
|
|
yield generate_chat_html(_history, name1, name2, shared.character)
|
|
|
|
|
|
|
|
-def regenerate_wrapper(text, max_new_tokens, do_sample, 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, greed=1):
|
|
|
|
|
|
|
+def regenerate_wrapper(text, max_new_tokens, do_sample, 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, chat_generation_attempts=1):
|
|
|
if shared.character != 'None' and len(shared.history['visible']) == 1:
|
|
if shared.character != 'None' and len(shared.history['visible']) == 1:
|
|
|
if shared.args.cai_chat:
|
|
if shared.args.cai_chat:
|
|
|
yield generate_chat_html(shared.history['visible'], name1, name2, shared.character)
|
|
yield generate_chat_html(shared.history['visible'], name1, name2, shared.character)
|
|
@@ -170,7 +171,7 @@ def regenerate_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typi
|
|
|
last_visible = shared.history['visible'].pop()
|
|
last_visible = shared.history['visible'].pop()
|
|
|
last_internal = shared.history['internal'].pop()
|
|
last_internal = shared.history['internal'].pop()
|
|
|
|
|
|
|
|
- for _history in chatbot_wrapper(last_internal[0], max_new_tokens, do_sample, 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, greed):
|
|
|
|
|
|
|
+ for _history in chatbot_wrapper(last_internal[0], max_new_tokens, do_sample, 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, chat_generation_attempts):
|
|
|
if shared.args.cai_chat:
|
|
if shared.args.cai_chat:
|
|
|
shared.history['visible'][-1] = [last_visible[0], _history[-1][1]]
|
|
shared.history['visible'][-1] = [last_visible[0], _history[-1][1]]
|
|
|
yield generate_chat_html(shared.history['visible'], name1, name2, shared.character)
|
|
yield generate_chat_html(shared.history['visible'], name1, name2, shared.character)
|