Spaces:
Sleeping
Sleeping
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 | |