From 444cd69c676c01b3df611f9d5cf6d7b35f083253 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 20 Feb 2023 19:38:19 -0300 Subject: [PATCH] Fix regex bug in loading character jsons with special characters --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 6d0b49c9..4d411ea6 100644 --- a/server.py +++ b/server.py @@ -733,7 +733,7 @@ def tokenize_dialogue(dialogue, name1, name2): dialogue = re.sub('', '', dialogue) dialogue = re.sub('(\n|^)[Aa]non:', '\\1You:', dialogue) dialogue = re.sub('(\n|^)\[CHARACTER\]:', f'\\g<1>{name2}:', dialogue) - idx = [m.start() for m in re.finditer(f"(^|\n)({name1}|{name2}):", dialogue)] + idx = [m.start() for m in re.finditer(f"(^|\n)({re.escape(name1)}|{re.escape(name2)}):", dialogue)] if len(idx) == 0: return _history