瀏覽代碼

server : handle "logprobs" field with false value (#9871)

Co-authored-by: Gimling <huangjl@ruyi.ai>
VoidIsVoid 1 年之前
父節點
當前提交
a89f75e1b7
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      examples/server/utils.hpp

+ 2 - 2
examples/server/utils.hpp

@@ -360,9 +360,9 @@ static json oaicompat_completion_params_parse(
 
 
     // Handle "logprobs" field
     // 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
     // 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);
         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");
         throw std::runtime_error("top_logprobs requires logprobs to be set to true");
     }
     }