ChatON:ChatTemplateApplySingle: update begin+prefix, suffix+end

This commit is contained in:
HanishKVC 2024-04-25 06:32:24 +05:30
parent 5d76f08d37
commit f8ae21cec7

View file

@ -182,20 +182,13 @@ inline bool chaton_tmpl_apply_single_ex(
) { ) {
ChatParts cp = {}; ChatParts cp = {};
std::stringstream ss; std::stringstream ss;
std::string begin = ""; std::string beginPrefix = chaton_tmpl_role_kv(tmpl, role, {K_BEGIN, K_PREFIX});
try { std::string suffixEnd = chaton_tmpl_role_kv(tmpl, role, {K_SUFFIX, K_END});
begin = conMeta[tmpl][role][K_BEGIN]; cp.add_part(ChatParts::S, beginPrefix);
} catch (json::exception &err) {
}
std::string prefix = conMeta[tmpl][role][K_PREFIX];
std::string suffix = conMeta[tmpl][role][K_SUFFIX];
cp.add_part(ChatParts::S, begin);
cp.add_part(ChatParts::S, prefix);
cp.add_part(ChatParts::N, content); cp.add_part(ChatParts::N, content);
cp.add_part(ChatParts::S, suffix); cp.add_part(ChatParts::S, suffixEnd);
cp.dump(); cp.dump();
ss << begin << prefix << content << suffix; ss << beginPrefix << content << suffixEnd;
tagged = ss.str(); tagged = ss.str();
std::string cpStr = cp.str(); std::string cpStr = cp.str();
if (tagged != cpStr) { if (tagged != cpStr) {