Skip to content

Commit 65b8d7c

Browse files
committed
Revert change
1 parent 9894626 commit 65b8d7c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

gguf-py/gguf/vocab.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,18 @@ def _try_load_from_tokenizer_json(self, path: Path) -> bool:
260260
if not tokenizer_config:
261261
return True
262262
chat_template_alt = None
263-
chat_template_file = path / 'chat_template.json'
264-
if chat_template_file.is_file():
265-
with open(chat_template_file, encoding = 'utf-8') as f:
263+
chat_template_json = path / 'chat_template.json'
264+
chat_template_jinja = path / 'chat_template.jinja'
265+
if chat_template_jinja.is_file():
266+
with open(chat_template_jinja, encoding = 'utf-8') as f:
267+
chat_template_alt = f.read()
268+
if additional_templates := list((path / 'additional_chat_templates').glob('*.jinja')):
269+
chat_template_alt = [{'name': 'default', 'template': chat_template_alt}]
270+
for template_path in additional_templates:
271+
with open(template_path, encoding = 'utf-8') as fp:
272+
chat_template_alt.append({'name': template_path.stem, 'template': fp.read()})
273+
elif chat_template_json.is_file():
274+
with open(chat_template_json, encoding = 'utf-8') as f:
266275
chat_template_alt = json.load(f).get('chat_template')
267276
chat_template = tokenizer_config.get('chat_template', chat_template_alt)
268277
if chat_template is None or isinstance(chat_template, (str, list)):

0 commit comments

Comments
 (0)