diff --git a/common/chat-parser.cpp b/common/chat-parser.cpp index d740dac065..9791332c02 100644 --- a/common/chat-parser.cpp +++ b/common/chat-parser.cpp @@ -15,6 +15,7 @@ using json = nlohmann::ordered_json; + static void parse_prefixed_json_tool_call_array(common_chat_msg_parser & builder, const common_regex & prefix, size_t rstrip_prefix = 0) { diff --git a/tools/server/server-common.cpp b/tools/server/server-common.cpp index ab6b3aa7ce..33e383d6fa 100644 --- a/tools/server/server-common.cpp +++ b/tools/server/server-common.cpp @@ -1058,6 +1058,12 @@ json oaicompat_chat_params_parse( llama_params["chat_parser"] = chat_params.parser; } + // Handle "n" field + int n_choices = json_value(body, "n", 1); + if (n_choices != 1) { + throw std::invalid_argument("Only one completion choice is allowed"); + } + // Handle "logprobs" field // TODO: The response format of this option is not yet OAI-compatible, but seems like no one really using it; We may need to fix it in the future if (json_value(body, "logprobs", false)) {