From ebe30795390a4a5818d5b7c7bf2156dc2fd0312a Mon Sep 17 00:00:00 2001 From: ngxson Date: Fri, 9 Feb 2024 17:00:53 +0100 Subject: [PATCH] server: validate "--chat-template" argument --- examples/server/server.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index d4161ed92..70baf8de4 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -2300,7 +2300,13 @@ static void server_params_parse(int argc, char **argv, server_params &sparams, invalid_param = true; break; } - sparams.chat_template = argv[i]; + std::string value(argv[i]); + if (value != "chatml" && value != "llama2") { + fprintf(stderr, "error: chat template can be \"llama2\" or \"chatml\", but got: %s\n", value.c_str()); + invalid_param = true; + break; + } + sparams.chat_template = value; } else if (arg == "--override-kv") {