CoolFace
Apppublic

Limour/llama-python-streamingllm

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
1likes
text_display.py25 linesDownload Raw Back to mods
1import re2 3 4#  ========== 适配 SillyTavern 的模版 ==========5def text_format(text: str, _env=None, **env):6    if _env is not None:7        for k, v in _env.items():8            text = text.replace(r'{{' + k + r'}}', v)9    for k, v in env.items():10        text = text.replace(r'{{' + k + r'}}', v)11    return text12 13 14#  ========== 给引号加粗 ==========15reg_q = re.compile(r'“(.+?)”')16 17 18def chat_display_format(text: str):19    return reg_q.sub(r' **\g<0>** ', text)20 21 22def init(cfg):23    cfg['text_format'] = text_format24    cfg['chat_display_format'] = chat_display_format25