mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-01-27 19:04:51 +01:00
Try to avoid breaking jinja2 parsing for older models
This commit is contained in:
parent
7d98ca6195
commit
701048cf33
|
|
@ -91,6 +91,7 @@ def get_model_metadata(model):
|
|||
template = template.replace('bos_token', "'{}'".format(bos_token))
|
||||
|
||||
template = re.sub(r"\{\{-?\s*raise_exception\(.*?\)\s*-?\}\}", "", template, flags=re.DOTALL)
|
||||
template = re.sub(r'raise_exception\([^)]*\)', "''", template)
|
||||
template = re.sub(r'{% if add_generation_prompt %}.*', '', template, flags=re.DOTALL)
|
||||
model_settings['instruction_template'] = 'Custom (obtained from model metadata)'
|
||||
model_settings['instruction_template_str'] = template
|
||||
|
|
@ -150,6 +151,7 @@ def get_model_metadata(model):
|
|||
template = template.replace(k, "'{}'".format(value))
|
||||
|
||||
template = re.sub(r"\{\{-?\s*raise_exception\(.*?\)\s*-?\}\}", "", template, flags=re.DOTALL)
|
||||
template = re.sub(r'raise_exception\([^)]*\)', "''", template)
|
||||
template = re.sub(r'{% if add_generation_prompt %}.*', '', template, flags=re.DOTALL)
|
||||
model_settings['instruction_template'] = 'Custom (obtained from model metadata)'
|
||||
model_settings['instruction_template_str'] = template
|
||||
|
|
|
|||
Loading…
Reference in a new issue