json: don't complain about unknown format type in server if unset

This commit is contained in:
ochafik 2024-03-19 01:45:23 +00:00
parent e7de6433cb
commit 02e3bde6b4

View file

@ -378,10 +378,12 @@ static json oaicompat_completion_params_parse(
if (body.contains("response_format")) {
auto response_format = json_value(body, "response_format", json::object());
if (response_format.contains("type") && response_format["type"] == "json_object") {
llama_params["json_schema"] = json_value(response_format, "schema", json::object());
} else {
throw std::runtime_error("response_format type not supported: " + response_format["type"].dump());
if (response_format.contains("type")) {
if (response_format["type"] == "json_object") {
llama_params["json_schema"] = json_value(response_format, "schema", json::object());
} else {
throw std::runtime_error("response_format type not supported: " + response_format["type"].dump());
}
}
}