瀏覽代碼

Merge pull request #57 from martinnj/fix/tokenize-dialogue-regex-backref

Fix a regex issue in `tokenize_dialogue`.
oobabooga 3 年之前
父節點
當前提交
a2519ede90
共有 1 個文件被更改,包括 1 次插入1 次删除
  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