@@ -2378,6 +2378,10 @@ static void server_print_usage(const char * argv0, const gpt_params & params, co
2378
2378
printf (" set custom jinja chat template (default: template taken from model's metadata)\n " );
2379
2379
printf (" only commonly used templates are accepted:\n " );
2380
2380
printf (" https://github.com/ggerganov/llama.cpp/wiki/Templates-supported-by-llama_chat_apply_template\n " );
2381
+ printf (" --chaton-meta-json JsonFile\n " );
2382
+ printf (" specify the json file containing chat-handshake-template-standard(s)" );
2383
+ printf (" --chaton-template-id ChatHandshakeTemplateId\n " );
2384
+ printf (" specify the specific template standard to use from loaded json file" );
2381
2385
printf (" \n " );
2382
2386
}
2383
2387
@@ -2839,6 +2843,24 @@ static void server_params_parse(int argc, char ** argv, server_params & sparams,
2839
2843
break ;
2840
2844
}
2841
2845
params.kv_overrides .push_back (kvo);
2846
+ }else if (arg == " --chaton-meta-json" ) {
2847
+ if (++i >= argc) {
2848
+ invalid_param = true ;
2849
+ break ;
2850
+ }
2851
+ params.chaton_meta_json = argv[i];
2852
+ } else if (arg == " --chaton-template-id" ) {
2853
+ if (++i >= argc) {
2854
+ invalid_param = true ;
2855
+ break ;
2856
+ }
2857
+ std::string got = argv[i];
2858
+ std::regex whitespaces (R"( \s+)" );
2859
+ std::string trimmed = std::regex_replace (got, whitespaces, " " );
2860
+ if (!trimmed.empty ()) {
2861
+ params.chaton_template_id = trimmed;
2862
+ params.chaton = true ;
2863
+ }
2842
2864
} else {
2843
2865
fprintf (stderr, " error: unknown argument: %s\n " , arg.c_str ());
2844
2866
server_print_usage (argv[0 ], default_params, default_sparams);
@@ -2929,6 +2951,14 @@ int main(int argc, char ** argv) {
2929
2951
{" system_info" , llama_print_system_info ()},
2930
2952
});
2931
2953
2954
+ if (params.chaton ) {
2955
+ chaton_meta_load (params.chaton_meta_json );
2956
+ if (!chaton_meta_ok (params.chaton_template_id )) {
2957
+ exit (2 );
2958
+ }
2959
+ sparams.chat_template = params.chaton_template_id ;
2960
+ }
2961
+
2932
2962
std::unique_ptr<httplib::Server> svr;
2933
2963
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
2934
2964
if (sparams.ssl_key_file != " " && sparams.ssl_cert_file != " " ) {
0 commit comments