Spaces:
Sleeping
Sleeping
File size: 586 Bytes
0523803 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import re
# ========== 适配 SillyTavern 的模版 ==========
def text_format(text: str, _env=None, **env):
if _env is not None:
for k, v in _env.items():
text = text.replace(r'{{' + k + r'}}', v)
for k, v in env.items():
text = text.replace(r'{{' + k + r'}}', v)
return text
# ========== 给引号加粗 ==========
reg_q = re.compile(r'“(.+?)”')
def chat_display_format(text: str):
return reg_q.sub(r' **\g<0>** ', text)
def init(cfg):
cfg['text_format'] = text_format
cfg['chat_display_format'] = chat_display_format
|