ChatON: meta-dump returns flag inturn returned by meta-ok

test-chat-template-chaton now tries to check if meta-ok is ok wrt
the template-id being looked into.

Log template-id info also, where it was previously missed out.
This commit is contained in:
HanishKVC 2024-04-29 12:02:03 +05:30
parent a108000cfd
commit a09571318a
2 changed files with 12 additions and 5 deletions

View file

@ -551,14 +551,18 @@ inline int32_t chaton_tmpl_apply_capi(
* * empty string, then dump the full loaded chaton-meta * * empty string, then dump the full loaded chaton-meta
* * chaton-template-id, then dump contents related to that specific chat-handshake-template-standard * * chaton-template-id, then dump contents related to that specific chat-handshake-template-standard
*/ */
inline void _chaton_meta_dump(std::string &tmpl) { inline bool _chaton_meta_dump(std::string &tmpl) {
json theJson; json theJson;
if (tmpl.empty()) { if (tmpl.empty()) {
theJson = conMeta; theJson = conMeta;
} else { } else {
theJson = conMeta[tmpl]; theJson = conMeta[tmpl];
if (theJson.empty()) {
LOGXLN("ERRR:%s:Specified template-id [%s] not found", __func__, tmpl.c_str());
return false;
}
} }
LOGXLN("\n\nINFO:%s:ChatOn Meta\n%s", __func__, theJson.dump(4).c_str()); LOGXLN("\n\nINFO:%s:ChatOn Meta:%s:\n%s", __func__, tmpl.c_str(), theJson.dump(4).c_str());
if (!tmpl.empty()) { if (!tmpl.empty()) {
std::string globalBegin = conMeta[tmpl][K_GLOBAL][K_BEGIN]; std::string globalBegin = conMeta[tmpl][K_GLOBAL][K_BEGIN];
std::string globalEnd = conMeta[tmpl][K_GLOBAL][K_END]; std::string globalEnd = conMeta[tmpl][K_GLOBAL][K_END];
@ -602,6 +606,7 @@ inline void _chaton_meta_dump(std::string &tmpl) {
LOG_TEELN("WARN:%s:Assistant->Begin seems to be set to [%s], do cross check if this is proper and needed", __func__, assistantBegin.c_str()); LOG_TEELN("WARN:%s:Assistant->Begin seems to be set to [%s], do cross check if this is proper and needed", __func__, assistantBegin.c_str());
} }
} }
return true;
} }
/** /**
@ -610,9 +615,8 @@ inline void _chaton_meta_dump(std::string &tmpl) {
*/ */
inline bool chaton_meta_ok(std::string &tmpl) { inline bool chaton_meta_ok(std::string &tmpl) {
if (conMeta == nullptr) { if (conMeta == nullptr) {
LOG_TEELN("ERRR:%s:ChatOn Meta: Not loaded yet...", __func__); LOG_TEELN("ERRR:%s:%s:ChatOn Meta: Not loaded yet...", __func__, tmpl.c_str());
return false; return false;
} }
_chaton_meta_dump(tmpl); return _chaton_meta_dump(tmpl);
return true;
} }

View file

@ -120,6 +120,9 @@ static void check_chaton(std::string &metaJson) {
for(auto tmplId: templateIds) { for(auto tmplId: templateIds) {
formatted_chat.resize(1024); formatted_chat.resize(1024);
std::cout << "\n----------" << tmplId << "---------------\n"; std::cout << "\n----------" << tmplId << "---------------\n";
if (!chaton_meta_ok(tmplId)) {
exit(1);
}
res = chaton_tmpl_apply_capi(tmplId.c_str(), conversation, message_count, true, formatted_chat.data(), formatted_chat.size()); res = chaton_tmpl_apply_capi(tmplId.c_str(), conversation, message_count, true, formatted_chat.data(), formatted_chat.size());
assert(res > 0); assert(res > 0);
formatted_chat.resize(res); formatted_chat.resize(res);