From f8ae21cec71f1ed5739eed322d01a954e25a7b0b Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Thu, 25 Apr 2024 06:32:24 +0530 Subject: [PATCH] ChatON:ChatTemplateApplySingle: update begin+prefix, suffix+end --- common/chaton.hpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/common/chaton.hpp b/common/chaton.hpp index 9c5a9b6e7..d2db60ba8 100644 --- a/common/chaton.hpp +++ b/common/chaton.hpp @@ -182,20 +182,13 @@ inline bool chaton_tmpl_apply_single_ex( ) { ChatParts cp = {}; std::stringstream ss; - std::string begin = ""; - try { - begin = conMeta[tmpl][role][K_BEGIN]; - } 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); + std::string beginPrefix = chaton_tmpl_role_kv(tmpl, role, {K_BEGIN, K_PREFIX}); + std::string suffixEnd = chaton_tmpl_role_kv(tmpl, role, {K_SUFFIX, K_END}); + cp.add_part(ChatParts::S, beginPrefix); cp.add_part(ChatParts::N, content); - cp.add_part(ChatParts::S, suffix); + cp.add_part(ChatParts::S, suffixEnd); cp.dump(); - ss << begin << prefix << content << suffix; + ss << beginPrefix << content << suffixEnd; tagged = ss.str(); std::string cpStr = cp.str(); if (tagged != cpStr) {