diff --git a/common/chaton.hpp b/common/chaton.hpp index b7132e61d..cc8380d5a 100644 --- a/common/chaton.hpp +++ b/common/chaton.hpp @@ -515,11 +515,14 @@ public: }; +// The compiled-in configurable template data (the meta) #include "chaton_meta.hpp" //ChatTemplates gCT = {{}}; #ifdef CHATON_JSON +// Get value corresponding to the specified hierarchy/chain of keys. +// Also throw a more informative exception, if it is not found. template inline SupportedType json_get(json &j, const std::vector &keys, const std::string &msgTag) { json curJ = j; @@ -540,7 +543,8 @@ inline SupportedType json_get(json &j, const std::vector &keys return curJ; } -inline bool chaton_meta_load(const std::string &fname) { +// Update/Extend the compiled-in configurable template data (the meta) from the specified json file. +inline bool chaton_meta_load_json(const std::string &fname) { std::ifstream f(fname); json conMeta = json::parse(f); for(auto it=conMeta.begin(); it != conMeta.end(); ++it) { diff --git a/examples/main/main.cpp b/examples/main/main.cpp index f86592fc7..39fdcdc54 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -144,7 +144,7 @@ int main(int argc, char ** argv) { if (params.chaton) { if (!params.chaton_meta_json.empty()) { - chaton_meta_load(params.chaton_meta_json); + chaton_meta_load_json(params.chaton_meta_json); } if (!chaton_meta_ok(params.chaton_template_id)) { exit(1); diff --git a/tests/test-chat-template-chaton.cpp b/tests/test-chat-template-chaton.cpp index ce65cc31e..e14266ad5 100644 --- a/tests/test-chat-template-chaton.cpp +++ b/tests/test-chat-template-chaton.cpp @@ -116,7 +116,7 @@ static void check_chaton(std::string &metaJson) { std::vector formatted_chat(1024); int32_t res; - chaton_meta_load(metaJson); + chaton_meta_load_json(metaJson); for(auto tmplId: templateIds) { formatted_chat.resize(1024); std::cout << "\n----------" << tmplId << "---------------\n"; @@ -137,7 +137,7 @@ static void check_chaton_ex(std::string &metaJson) { std::vector formatted_chat(1024); int32_t res; - chaton_meta_load(metaJson); + chaton_meta_load_json(metaJson); for(auto tmplId: templateIds) { formatted_chat.resize(1024); std::cout << "\n----------" << tmplId << "---------------\n";