From 563ff44ed97d6c93e1096cd98430ffae4e3fbb85 Mon Sep 17 00:00:00 2001 From: Gimling Date: Sun, 13 Oct 2024 09:41:20 +0800 Subject: [PATCH] server: Handle "logprobs" field with false value --- examples/server/utils.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index ad99e95742525..1f1bac7a1c21b 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -360,9 +360,9 @@ static json oaicompat_completion_params_parse( // 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 (body.contains("logprobs")) { + if (json_value(body, "logprobs", false)) { llama_params["n_probs"] = json_value(body, "top_logprobs", 20); - } else if (body.contains("top_logprobs")) { + } else if (body.contains("top_logprobs") && !body.at("top_logprobs").is_null()) { throw std::runtime_error("top_logprobs requires logprobs to be set to true"); }