@@ -1745,8 +1745,9 @@ struct server_context {
17451745
17461746 if (use_jinja) {
17471747 auto templates = llama_chat_templates_from_model (model, " " );
1748+ GGML_ASSERT (templates.default_template );
17481749 try {
1749- templates.default_template . apply ({{
1750+ templates.default_template -> apply ({{
17501751 {" role" , " user" },
17511752 {" content" , " test" },
17521753 }}, json (), true );
@@ -3630,6 +3631,7 @@ int main(int argc, char ** argv) {
36303631 std::lock_guard<std::mutex> lock (chat_templates_mutex);
36313632 if (!chat_templates) {
36323633 chat_templates = llama_chat_templates_from_model (ctx_server.model , ctx_server.params_base .chat_template );
3634+ GGML_ASSERT (chat_templates->default_template );
36333635 }
36343636 return *chat_templates;
36353637 };
@@ -3641,7 +3643,7 @@ int main(int argc, char ** argv) {
36413643 { " default_generation_settings" , ctx_server.default_generation_settings_for_props },
36423644 { " total_slots" , ctx_server.params_base .n_parallel },
36433645 { " model_path" , ctx_server.params_base .model },
3644- { " chat_template" , templates.default_template . source () },
3646+ { " chat_template" , templates.default_template -> source () },
36453647 { " build_info" , build_info },
36463648 };
36473649 if (ctx_server.params_base .use_jinja && templates.tool_use_template ) {
@@ -3868,7 +3870,7 @@ int main(int argc, char ** argv) {
38683870
38693871 auto body = json::parse (req.body );
38703872 const auto & templates = get_chat_templates ();
3871- const auto & chat_template = body.contains (" tools" ) && templates.tool_use_template ? *templates.tool_use_template : templates.default_template ;
3873+ const auto & chat_template = body.contains (" tools" ) && templates.tool_use_template ? *templates.tool_use_template : * templates.default_template ;
38723874 json data = oaicompat_completion_params_parse (body, chat_template, params.use_jinja );
38733875
38743876 return handle_completions_impl (
@@ -4287,8 +4289,8 @@ int main(int argc, char ** argv) {
42874289
42884290 // print sample chat example to make it clear which template is used
42894291 LOG_INF (" %s: chat template, chat_template: %s, example_format: '%s'\n " , __func__,
4290- get_chat_templates ().default_template . source ().c_str (),
4291- common_chat_format_example (get_chat_templates ().default_template , ctx_server.params_base .use_jinja ).c_str ());
4292+ get_chat_templates ().default_template -> source ().c_str (),
4293+ common_chat_format_example (* get_chat_templates ().default_template , ctx_server.params_base .use_jinja ).c_str ());
42924294
42934295 ctx_server.queue_tasks .on_new_task (std::bind (
42944296 &server_context::process_single_task, &ctx_server, std::placeholders::_1));
0 commit comments