llama-python-streamingllm / mods /text_display.py
Limour's picture
Upload 11 files
0523803 verified
raw
history blame contribute delete
586 Bytes
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