diff --git a/common/json-schema-to-grammar.cpp b/common/json-schema-to-grammar.cpp index dc6d30ef1..f344e8bc9 100644 --- a/common/json-schema-to-grammar.cpp +++ b/common/json-schema-to-grammar.cpp @@ -9,7 +9,7 @@ #include #include -using json = nlohmann::json; +using json = nlohmann::ordered_json; const std::string SPACE_RULE = "\" \"?"; @@ -137,7 +137,7 @@ private: std::function _fetch_json; bool _dotall; std::map _rules; - std::unordered_map _refs; + std::unordered_map _refs; std::unordered_set _refs_being_resolved; std::vector _errors; std::vector _warnings; @@ -495,7 +495,7 @@ public: _rules["space"] = SPACE_RULE; } - void resolve_refs(nlohmann::json & schema, const std::string & url) { + void resolve_refs(json & schema, const std::string & url) { /* * Resolves all $ref fields in the given schema, fetching any remote schemas, * replacing each $ref with absolute reference URL and populates _refs with the diff --git a/common/json-schema-to-grammar.h b/common/json-schema-to-grammar.h index 2e4c6ade3..e1abed303 100644 --- a/common/json-schema-to-grammar.h +++ b/common/json-schema-to-grammar.h @@ -1,4 +1,4 @@ #pragma once #include "json.hpp" -std::string json_schema_to_grammar(const nlohmann::json& schema); +std::string json_schema_to_grammar(const nlohmann::ordered_json& schema); diff --git a/examples/server/server.cpp b/examples/server/server.cpp index cf075d6c4..a5c3078e6 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -30,7 +30,7 @@ #include #include -using json = nlohmann::json; +using json = nlohmann::ordered_json; bool server_verbose = false; bool server_log_json = true; diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index ff146893d..d7eef556a 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -12,7 +12,7 @@ #define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo-0613" -using json = nlohmann::json; +using json = nlohmann::ordered_json; // https://community.openai.com/t/openai-chat-list-of-error-codes-and-types/357791/11 enum error_type { diff --git a/tests/test-json-schema-to-grammar.cpp b/tests/test-json-schema-to-grammar.cpp index 3c40e7563..ff7f0378f 100755 --- a/tests/test-json-schema-to-grammar.cpp +++ b/tests/test-json-schema-to-grammar.cpp @@ -378,20 +378,18 @@ static void test_all(const std::string & lang, std::function