Explorar o código

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.
Martin J %!s(int64=3) %!d(string=hai) anos
pai
achega
06a4664805
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      server.py

+ 1 - 1
server.py

@@ -532,7 +532,7 @@ if args.chat or args.cai_chat:
         dialogue = re.sub('<START>', '', dialogue)
         dialogue = re.sub('<start>', '', 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