ChatON+:RenameTo chaton_meta_load_json to match semantic

Also add simple note wrt itself and its helper.
This commit is contained in:
HanishKVC 2024-05-14 21:34:53 +05:30
parent bd5c39e0f0
commit f8c0b474ec
3 changed files with 8 additions and 4 deletions

View file

@ -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 <typename SupportedType>
inline SupportedType json_get(json &j, const std::vector<std::string_view> &keys, const std::string &msgTag) {
json curJ = j;
@ -540,7 +543,8 @@ inline SupportedType json_get(json &j, const std::vector<std::string_view> &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) {

View file

@ -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);

View file

@ -116,7 +116,7 @@ static void check_chaton(std::string &metaJson) {
std::vector<char> 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<char> 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";