Skip to content

Commit d1e1ec5

Browse files
authored
Support chat_template.json
1 parent d84635b commit d1e1ec5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gguf-py/gguf/vocab.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ def _try_load_from_tokenizer_json(self, path: Path) -> bool:
154154
return True
155155
with open(tokenizer_config_file, encoding = 'utf-8') as f:
156156
tokenizer_config = json.load(f)
157-
chat_template = tokenizer_config.get('chat_template')
157+
chat_template_alt = None
158+
chat_template_file = path / 'chat_template.json'
159+
if chat_template_file.is_file():
160+
with open(chat_template_file, encoding = 'utf-8') as f:
161+
chat_template_alt = json.load(f).get('chat_template')
162+
chat_template = tokenizer_config.get('chat_template', chat_template_alt)
158163
if chat_template is None or isinstance(chat_template, (str, list)):
159164
self.chat_template = chat_template
160165
else:

0 commit comments

Comments
 (0)