@@ -111,6 +111,7 @@ def main() -> None:
111
111
parser .add_argument ("--general-description" , type = str , help = "The models general.description" , metavar = '"Description ..."' )
112
112
parser .add_argument ("--chat-template" , type = str , help = "Chat template string (or JSON string containing templates)" , metavar = '"{% ... %} ..."' )
113
113
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' )
114
115
parser .add_argument ("--pre-tokenizer" , type = str , help = "The models tokenizer.ggml.pre" , metavar = '"pre tokenizer"' )
115
116
parser .add_argument ("--remove-metadata" , action = "append" , type = str , help = "Remove metadata (by key name) from output model" , metavar = 'general.url' )
116
117
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:
134
135
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 )
135
136
136
137
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 :
138
139
config = json .load (fp )
139
140
template = config .get ('chat_template' )
140
141
if template :
141
142
new_metadata [gguf .Keys .Tokenizer .CHAT_TEMPLATE ] = MetadataDetails (gguf .GGUFValueType .STRING , template )
142
143
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
+
143
149
if args .pre_tokenizer :
144
150
new_metadata [gguf .Keys .Tokenizer .PRE ] = MetadataDetails (gguf .GGUFValueType .STRING , args .pre_tokenizer )
145
151
0 commit comments