mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-09-20 18:45:09 +02:00
Move the rstrips
This commit is contained in:
parent
1d8b8222e9
commit
c83210c460
1 changed files with 4 additions and 4 deletions
|
@ -56,8 +56,8 @@ def generate_chat_prompt(user_input, state, **kwargs):
|
||||||
|
|
||||||
user_turn = replace_all(template.split('<|bot|>')[0], replacements)
|
user_turn = replace_all(template.split('<|bot|>')[0], replacements)
|
||||||
bot_turn = replace_all('<|bot|>' + template.split('<|bot|>')[1], replacements)
|
bot_turn = replace_all('<|bot|>' + template.split('<|bot|>')[1], replacements)
|
||||||
user_turn_stripped = replace_all(user_turn.split('<|user-message|>')[0], replacements).rstrip(' ')
|
user_turn_stripped = replace_all(user_turn.split('<|user-message|>')[0], replacements)
|
||||||
bot_turn_stripped = replace_all(bot_turn.split('<|bot-message|>')[0], replacements).rstrip(' ')
|
bot_turn_stripped = replace_all(bot_turn.split('<|bot-message|>')[0], replacements)
|
||||||
|
|
||||||
# Building the prompt
|
# Building the prompt
|
||||||
i = len(shared.history['internal']) - 1
|
i = len(shared.history['internal']) - 1
|
||||||
|
@ -75,14 +75,14 @@ def generate_chat_prompt(user_input, state, **kwargs):
|
||||||
|
|
||||||
if impersonate:
|
if impersonate:
|
||||||
min_rows = 2
|
min_rows = 2
|
||||||
rows.append(user_turn_stripped)
|
rows.append(user_turn_stripped.rstrip(' '))
|
||||||
elif not _continue:
|
elif not _continue:
|
||||||
# Adding the user message
|
# Adding the user message
|
||||||
if len(user_input) > 0:
|
if len(user_input) > 0:
|
||||||
rows.append(replace_all(user_turn, {'<|user-message|>': user_input.strip(), '<|round|>': str(len(shared.history["internal"]))}))
|
rows.append(replace_all(user_turn, {'<|user-message|>': user_input.strip(), '<|round|>': str(len(shared.history["internal"]))}))
|
||||||
|
|
||||||
# Adding the Character prefix
|
# Adding the Character prefix
|
||||||
rows.append(apply_extensions("bot_prefix", bot_turn_stripped))
|
rows.append(apply_extensions("bot_prefix", bot_turn_stripped.rstrip(' ')))
|
||||||
|
|
||||||
while len(rows) > min_rows and len(encode(''.join(rows))[0]) >= max_length:
|
while len(rows) > min_rows and len(encode(''.join(rows))[0]) >= max_length:
|
||||||
rows.pop(1)
|
rows.pop(1)
|
||||||
|
|
Loading…
Reference in a new issue