From 11c3214981b5b2b39ecbbfbda3d391a0d9caecc4 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 19 Jan 2023 19:59:34 -0300 Subject: [PATCH] Fix some regexes --- html_generator.py | 4 ++-- server.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/html_generator.py b/html_generator.py index 839aa762..ce2189e5 100644 --- a/html_generator.py +++ b/html_generator.py @@ -236,8 +236,8 @@ def generate_chat_html(history, name1, name2, character): for i,row in enumerate(history[::-1]): row[0] = re.sub(r"[\\]*\*", r"*", row[0]) row[1] = re.sub(r"[\\]*\*", r"*", row[1]) - row[0] = re.sub(r"(\*)([^\*]*)(\*)", r"\2", row[0]) - row[1] = re.sub(r"(\*)([^\*]*)(\*)", r"\2", row[1]) + row[0] = re.sub(r"(\*)([^\*\\n]*)(\*)", r"\2", row[0]) + row[1] = re.sub(r"(\*)([^\*\\n]*)(\*)", r"\2", row[1]) p = '\n'.join([f"

{x}

" for x in row[1].split('\n')]) output += f"""
diff --git a/server.py b/server.py index 11796fec..1fb986f5 100644 --- a/server.py +++ b/server.py @@ -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): 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 = idx[len(previous_idx)-1] + reply = reply[idx + len(f"\n{name2}:"):] if check: