mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-29 10:59:32 +01:00
Move code back into the chatbot wrapper
This commit is contained in:
parent
fe1771157f
commit
0817fe1beb
@ -92,17 +92,6 @@ def generate_chat_picture(picture, name1, name2):
|
|||||||
visible_text = f'<img src="data:image/jpeg;base64,{img_str}">'
|
visible_text = f'<img src="data:image/jpeg;base64,{img_str}">'
|
||||||
return text, visible_text
|
return text, visible_text
|
||||||
|
|
||||||
def preprocess_chat_input(text, tokens, name1, name2, context, chat_prompt_size):
|
|
||||||
if shared.args.picture and picture is not None:
|
|
||||||
text, visible_text = generate_chat_picture(picture, name1, name2)
|
|
||||||
else:
|
|
||||||
visible_text = text
|
|
||||||
if shared.args.chat:
|
|
||||||
visible_text = visible_text.replace('\n', '<br>')
|
|
||||||
text = apply_extensions(text, "input")
|
|
||||||
prompt = generate_chat_prompt(text, tokens, name1, name2, context, chat_prompt_size)
|
|
||||||
return text, visible_text, prompt
|
|
||||||
|
|
||||||
def stop_everything_event():
|
def stop_everything_event():
|
||||||
shared.stop_everything = True
|
shared.stop_everything = True
|
||||||
|
|
||||||
@ -114,7 +103,14 @@ def chatbot_wrapper(text, tokens, do_sample, max_new_tokens, temperature, top_p,
|
|||||||
if 'pygmalion' in shared.model_name.lower():
|
if 'pygmalion' in shared.model_name.lower():
|
||||||
name1 = "You"
|
name1 = "You"
|
||||||
|
|
||||||
text, visible_text, prompt = preprocess_chat_input(text, tokens, name1, name2, context, chat_prompt_size)
|
if shared.args.picture and picture is not None:
|
||||||
|
text, visible_text = generate_chat_picture(picture, name1, name2)
|
||||||
|
else:
|
||||||
|
visible_text = text
|
||||||
|
if shared.args.chat:
|
||||||
|
visible_text = visible_text.replace('\n', '<br>')
|
||||||
|
text = apply_extensions(text, "input")
|
||||||
|
prompt = generate_chat_prompt(text, tokens, name1, name2, context, chat_prompt_size)
|
||||||
|
|
||||||
# Generate
|
# Generate
|
||||||
for reply in generate_reply(prompt, 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, eos_token=eos_token, stopping_string=f"\n{name1}:"):
|
for reply in generate_reply(prompt, 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, eos_token=eos_token, stopping_string=f"\n{name1}:"):
|
||||||
|
Loading…
Reference in New Issue
Block a user