@@ -111,6 +111,7 @@ def main() -> None:
111111 parser .add_argument ("--general-description" , type = str , help = "The models general.description" , metavar = '"Description ..."' )
112112 parser .add_argument ("--chat-template" , type = str , help = "Chat template string (or JSON string containing templates)" , metavar = '"{% ... %} ..."' )
113113 parser .add_argument ("--chat-template-config" , type = Path , help = "Config file containing chat template(s)" , metavar = 'tokenizer_config.json' )
114+ parser .add_argument ("--chat-template-file" , type = Path , help = "Jinja file containing chat template" , metavar = 'chat_template.jinja' )
114115 parser .add_argument ("--pre-tokenizer" , type = str , help = "The models tokenizer.ggml.pre" , metavar = '"pre tokenizer"' )
115116 parser .add_argument ("--remove-metadata" , action = "append" , type = str , help = "Remove metadata (by key name) from output model" , metavar = 'general.url' )
116117 parser .add_argument ("--special-token" , action = "append" , type = str , help = "Special token by value" , nargs = 2 , metavar = (' | ' .join (token_names .keys ()), '"<token>"' ))
@@ -134,12 +135,17 @@ def main() -> None:
134135 new_metadata [gguf .Keys .Tokenizer .CHAT_TEMPLATE ] = MetadataDetails (gguf .GGUFValueType .STRING , json .loads (args .chat_template ) if args .chat_template .startswith ('[' ) else args .chat_template )
135136
136137 if args .chat_template_config :
137- with open (args .chat_template_config , 'r' ) as fp :
138+ with open (args .chat_template_config , 'r' , encoding = 'utf-8' ) as fp :
138139 config = json .load (fp )
139140 template = config .get ('chat_template' )
140141 if template :
141142 new_metadata [gguf .Keys .Tokenizer .CHAT_TEMPLATE ] = MetadataDetails (gguf .GGUFValueType .STRING , template )
142143
144+ if args .chat_template_file :
145+ with open (args .chat_template_file , 'r' , encoding = 'utf-8' ) as fp :
146+ template = fp .read ()
147+ new_metadata [gguf .Keys .Tokenizer .CHAT_TEMPLATE ] = MetadataDetails (gguf .GGUFValueType .STRING , template )
148+
143149 if args .pre_tokenizer :
144150 new_metadata [gguf .Keys .Tokenizer .PRE ] = MetadataDetails (gguf .GGUFValueType .STRING , args .pre_tokenizer )
145151
0 commit comments