From e8c92bcb84ae3bcbf0d617b7ee6a5413bcbd58af Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Sat, 2 Dec 2023 11:31:53 -0800 Subject: [PATCH] Make OpenAI API `stop` field optional (#36) Fixes #30 --- llama.cpp/server/server.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/llama.cpp/server/server.cpp b/llama.cpp/server/server.cpp index 26e8730e86..dc2123ceab 100644 --- a/llama.cpp/server/server.cpp +++ b/llama.cpp/server/server.cpp @@ -2400,9 +2400,7 @@ json oaicompat_completion_params_parse( } // Handle 'stop' field - if (body["stop"].is_null()) { - llama_params["stop"] = json::array({}); - } else if (body["stop"].is_string()) { + if (body.contains("stop") && body["stop"].is_string()) { llama_params["stop"] = json::array({body["stop"].get()}); } else { llama_params["stop"] = json_value(body, "stop", json::array());