File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -245,9 +245,18 @@ def _try_load_from_tokenizer_json(self, path: Path) -> bool:
245245 if not tokenizer_config :
246246 return True
247247 chat_template_alt = None
248- chat_template_file = path / 'chat_template.json'
249- if chat_template_file .is_file ():
250- with open (chat_template_file , encoding = 'utf-8' ) as f :
248+ chat_template_json = path / 'chat_template.json'
249+ chat_template_jinja = path / 'chat_template.jinja'
250+ if chat_template_jinja .is_file ():
251+ with open (chat_template_jinja , encoding = 'utf-8' ) as f :
252+ chat_template_alt = f .read ()
253+ if additional_templates := list ((path / 'additional_chat_templates' ).glob ('*.jinja' )):
254+ chat_template_alt = [{'name' : 'default' , 'template' : chat_template_alt }]
255+ for template_path in additional_templates :
256+ with open (template_path , encoding = 'utf-8' ) as fp :
257+ chat_template_alt .append ({'name' : template_path .stem , 'template' : fp .read ()})
258+ elif chat_template_json .is_file ():
259+ with open (chat_template_json , encoding = 'utf-8' ) as f :
251260 chat_template_alt = json .load (f ).get ('chat_template' )
252261 chat_template = tokenizer_config .get ('chat_template' , chat_template_alt )
253262 if chat_template is None or isinstance (chat_template , (str , list )):
You can’t perform that action at this time.
0 commit comments