From cc3df3f388feb00fb5077e25c9f975d154d4126a Mon Sep 17 00:00:00 2001 From: Kuriko Moe Date: Fri, 10 May 2024 19:43:41 +0800 Subject: [PATCH] Fix(server): stopped_word always true `bool stopped_word` is always true, thus `finish_reason` will never be `length`, which makes the anti-degeneration failed to detect the repeating words. --- examples/server/utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index d872b63f5..12a6a8f57 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -431,7 +431,7 @@ static json oaicompat_completion_params_parse( } static json format_final_response_oaicompat(const json & request, json result, const std::string & completion_id, bool streaming = false) { - bool stopped_word = result.count("stopped_word") != 0; + bool stopped_word = json_value(result, "stopped_word", false); bool stopped_eos = json_value(result, "stopped_eos", false); int num_tokens_predicted = json_value(result, "tokens_predicted", 0); int num_prompt_tokens = json_value(result, "tokens_evaluated", 0);