]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : handle "logprobs" field with false value (#9871)
authorVoidIsVoid <redacted>
Mon, 14 Oct 2024 07:04:36 +0000 (15:04 +0800)
committerGitHub <redacted>
Mon, 14 Oct 2024 07:04:36 +0000 (10:04 +0300)
Co-authored-by: Gimling <redacted>
examples/server/utils.hpp

index 37999604d11b39a9f935e47e5b5370688e9cd63c..69519ef95b2d913bea680d8ba00eb246daca95d8 100644 (file)
@@ -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");
     }