ChatON: Option for a fallback tmpl to use wrt chat-tmpl-apply-ex
This commit is contained in:
parent
1a0df950eb
commit
0cbfd40f18
1 changed files with 16 additions and 2 deletions
|
@ -326,6 +326,8 @@ class ChatTemplates : public GroupKV {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
std::string tmplFallback;
|
||||||
|
|
||||||
ChatTemplates(GroupKVMapMapVariant defaultMap) : GroupKV(defaultMap) {}
|
ChatTemplates(GroupKVMapMapVariant defaultMap) : GroupKV(defaultMap) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,7 +452,7 @@ public:
|
||||||
* cntUserMsgCnt arguments.
|
* cntUserMsgCnt arguments.
|
||||||
*/
|
*/
|
||||||
bool chaton_tmpl_apply_ex(
|
bool chaton_tmpl_apply_ex(
|
||||||
const std::string &tmpl,
|
const std::string &tmplId,
|
||||||
const std::vector<const llama_chat_message *> &msgs,
|
const std::vector<const llama_chat_message *> &msgs,
|
||||||
bool alertAssistantAtEnd,
|
bool alertAssistantAtEnd,
|
||||||
bool applyGlobalIfAny,
|
bool applyGlobalIfAny,
|
||||||
|
@ -460,8 +462,13 @@ public:
|
||||||
int curSystemMsgCnt = 0,
|
int curSystemMsgCnt = 0,
|
||||||
int curUserMsgCnt = 0
|
int curUserMsgCnt = 0
|
||||||
) {
|
) {
|
||||||
|
std::string tmpl = tmplId;
|
||||||
if (!tmpl_exists(tmpl)) {
|
if (!tmpl_exists(tmpl)) {
|
||||||
return false;
|
tmpl = tmplFallback;
|
||||||
|
LDBUG_LN("DBUG:%s:Tmpl [%s] missing, fallback to [%s]", __func__, tmplId, tmpl);
|
||||||
|
if (!tmpl_exists(tmpl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ChatParts cp = {};
|
ChatParts cp = {};
|
||||||
if (applyGlobalIfAny) {
|
if (applyGlobalIfAny) {
|
||||||
|
@ -772,6 +779,13 @@ inline std::vector<llama_token> chaton_llama_tokenize_ex(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void chaton_meta_fallback(std::string &tmpl, ChatTemplates *ct=nullptr) {
|
||||||
|
if (ct == nullptr) {
|
||||||
|
ct = &gCT;
|
||||||
|
}
|
||||||
|
ct->tmplFallback = tmpl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate specified chaton-template-id and inturn dump the contents related to that
|
* Validate specified chaton-template-id and inturn dump the contents related to that
|
||||||
* specific chat-handshake-template-standard, wrt the specified ChatTemplates.
|
* specific chat-handshake-template-standard, wrt the specified ChatTemplates.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue