mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-26 01:30:20 +01:00
Fix some regexes
This commit is contained in:
parent
e61138bdad
commit
11c3214981
@ -236,8 +236,8 @@ def generate_chat_html(history, name1, name2, character):
|
|||||||
for i,row in enumerate(history[::-1]):
|
for i,row in enumerate(history[::-1]):
|
||||||
row[0] = re.sub(r"[\\]*\*", r"*", row[0])
|
row[0] = re.sub(r"[\\]*\*", r"*", row[0])
|
||||||
row[1] = re.sub(r"[\\]*\*", r"*", row[1])
|
row[1] = re.sub(r"[\\]*\*", r"*", row[1])
|
||||||
row[0] = re.sub(r"(\*)([^\*]*)(\*)", r"<em>\2</em>", row[0])
|
row[0] = re.sub(r"(\*)([^\*\\n]*)(\*)", r"<em>\2</em>", row[0])
|
||||||
row[1] = re.sub(r"(\*)([^\*]*)(\*)", r"<em>\2</em>", row[1])
|
row[1] = re.sub(r"(\*)([^\*\\n]*)(\*)", r"<em>\2</em>", row[1])
|
||||||
p = '\n'.join([f"<p>{x}</p>" for x in row[1].split('\n')])
|
p = '\n'.join([f"<p>{x}</p>" for x in row[1].split('\n')])
|
||||||
output += f"""
|
output += f"""
|
||||||
<div class="message">
|
<div class="message">
|
||||||
|
@ -256,9 +256,10 @@ if args.chat or args.cai_chat:
|
|||||||
for reply in generate_reply(question, tokens, inference_settings, selected_model, eos_token=eos_token):
|
for reply in generate_reply(question, tokens, inference_settings, selected_model, eos_token=eos_token):
|
||||||
next_character_found = False
|
next_character_found = False
|
||||||
|
|
||||||
previous_idx = [m.start() for m in re.finditer(f"\n{name2}:", question)]
|
previous_idx = [m.start() for m in re.finditer(f"(^|\n){name2}:", question)]
|
||||||
idx = [m.start() for m in re.finditer(f"(^|\n){name2}:", reply)]
|
idx = [m.start() for m in re.finditer(f"(^|\n){name2}:", reply)]
|
||||||
idx = idx[len(previous_idx)-1]
|
idx = idx[len(previous_idx)-1]
|
||||||
|
|
||||||
reply = reply[idx + len(f"\n{name2}:"):]
|
reply = reply[idx + len(f"\n{name2}:"):]
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
|
Loading…
Reference in New Issue
Block a user