File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -1920,13 +1920,22 @@ common_chat_templates common_chat_templates_from_model(const struct llama_model
19201920 token_bos = get_token(llama_vocab_bos(vocab), "BOS", "bos_token");
19211921 token_eos = get_token(llama_vocab_eos(vocab), "EOS", "eos_token");
19221922#endif
1923- return {
1924- has_explicit_template,
1925- std::make_unique<minja::chat_template>(default_template_src, token_bos, token_eos),
1926- template_tool_use_src.empty ()
1927- ? nullptr
1928- : std::make_unique<minja::chat_template>(template_tool_use_src, token_bos, token_eos)
1929- };
1923+ try {
1924+ return {
1925+ has_explicit_template,
1926+ std::make_unique<minja::chat_template>(default_template_src, token_bos, token_eos),
1927+ template_tool_use_src.empty ()
1928+ ? nullptr
1929+ : std::make_unique<minja::chat_template>(template_tool_use_src, token_bos, token_eos),
1930+ };
1931+ } catch (const std::exception & e) {
1932+ LOG_ERR (" %s: failed to parse chat template: %s\n " , __func__, e.what ());
1933+ return {
1934+ has_explicit_template,
1935+ std::make_unique<minja::chat_template>(CHATML_TEMPLATE_SRC, token_bos, token_eos),
1936+ nullptr ,
1937+ };
1938+ }
19301939}
19311940
19321941//
You can’t perform that action at this time.
0 commit comments