From 02e3bde6b47b947e2613d2447fcebe0f07ad7011 Mon Sep 17 00:00:00 2001 From: ochafik Date: Tue, 19 Mar 2024 01:45:23 +0000 Subject: [PATCH] json: don't complain about unknown format type in server if unset --- examples/server/utils.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index c783233e8..926f1fd85 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -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()); + } } }