server : fix OpenAI API stop field to be optional

(cherry picked from commit Mozilla-Ocho/llamafile@e8c92bcb84)
This commit is contained in:
Ed Lee 2023-12-02 11:31:53 -08:00
parent 5a7d3125e7
commit 502bb38770
No known key found for this signature in database
GPG key ID: 40B7250312F03605

View file

@ -2410,9 +2410,7 @@ json oaicompat_completion_params_parse(
} }
// Handle 'stop' field // Handle 'stop' field
if (body["stop"].is_null()) { if (body.contains("stop") && body["stop"].is_string()) {
llama_params["stop"] = json::array({});
} else if (body["stop"].is_string()) {
llama_params["stop"] = json::array({body["stop"].get<std::string>()}); llama_params["stop"] = json::array({body["stop"].get<std::string>()});
} else { } else {
llama_params["stop"] = json_value(body, "stop", json::array()); llama_params["stop"] = json_value(body, "stop", json::array());