mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Do not use empty user messages in chat mode
This allows the bot to send messages by clicking on Generate with empty inputs.
This commit is contained in:
commit
507db0929d
@ -33,11 +33,13 @@ def generate_chat_prompt(user_input, max_new_tokens, name1, name2, context, chat
|
||||
i = len(shared.history['internal'])-1
|
||||
while i >= 0 and len(encode(''.join(rows), max_new_tokens)[0]) < max_length:
|
||||
rows.insert(1, f"{name2}: {shared.history['internal'][i][1].strip()}\n")
|
||||
if not (shared.history['internal'][i][0] == '<|BEGIN-VISIBLE-CHAT|>'):
|
||||
rows.insert(1, f"{name1}: {shared.history['internal'][i][0].strip()}\n")
|
||||
prev_user_input = shared.history['internal'][i][0]
|
||||
if len(prev_user_input) > 0 and prev_user_input != '<|BEGIN-VISIBLE-CHAT|>':
|
||||
rows.insert(1, f"{name1}: {prev_user_input.strip()}\n")
|
||||
i -= 1
|
||||
|
||||
if not impersonate:
|
||||
if len(user_input) > 0:
|
||||
rows.append(f"{name1}: {user_input}\n")
|
||||
rows.append(apply_extensions(f"{name2}:", "bot_prefix"))
|
||||
limit = 3
|
||||
|
@ -142,7 +142,9 @@ def generate_chat_html(history, name1, name2, character):
|
||||
</div>
|
||||
"""
|
||||
|
||||
if not (i == len(history)-1 and len(row[0]) == 0):
|
||||
if len(row[0]) == 0: # don't display empty user messages
|
||||
continue
|
||||
|
||||
output += f"""
|
||||
<div class="message">
|
||||
<div class="circle-you">
|
||||
|
Loading…
Reference in New Issue
Block a user