From 06a46648053b3cb3da19b75b0149b3b6df651be1 Mon Sep 17 00:00:00 2001 From: Martin J Date: Sun, 5 Feb 2023 07:42:57 +0100 Subject: [PATCH] Fix a regex issue in `tokenize_dialogue`. The existing regex would fail if using character names that start with numbers, for example: 9S or 2B. --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 74a09731..79ef8973 100644 --- a/server.py +++ b/server.py @@ -532,7 +532,7 @@ if args.chat or args.cai_chat: dialogue = re.sub('', '', dialogue) dialogue = re.sub('', '', dialogue) dialogue = re.sub('(\n|^)[Aa]non:', '\\1You:', dialogue) - dialogue = re.sub('(\n|^)\[CHARACTER\]:', f'\\1{name2}:', dialogue) + dialogue = re.sub('(\n|^)\[CHARACTER\]:', f'\\g<1>{name2}:', dialogue) idx = [m.start() for m in re.finditer(f"(^|\n)({name1}|{name2}):", dialogue)] if len(idx) == 0: return _history