Skip to content

Commit

Permalink
server : fix OpenAI API stop field to be optional (#4299)
Browse files Browse the repository at this point in the history
(cherry picked from commit Mozilla-Ocho/llamafile@e8c92bc)
  • Loading branch information
Mardak authored Dec 3, 2023
1 parent 6949b50 commit 33e171d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,9 +2410,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<std::string>()});
} else {
llama_params["stop"] = json_value(body, "stop", json::array());
Expand Down

0 comments on commit 33e171d

Please sign in to comment.