From 05fd7e3020891eae6c7577de1542746cf3b0f63e Mon Sep 17 00:00:00 2001 From: ochafik Date: Mon, 18 Mar 2024 20:46:57 +0000 Subject: [PATCH] json: fix json handling in server when there's no response_format --- examples/server/utils.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index e976ebda6..c783233e8 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -376,9 +376,9 @@ static json oaicompat_completion_params_parse( llama_params["grammar"] = json_value(body, "grammar", json::object()); } - if (!body["response_format"].is_null()) { + if (body.contains("response_format")) { auto response_format = json_value(body, "response_format", json::object()); - if (response_format["type"] == "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());