SimpleChat:DU: Bring in both trim garbage logics to try trim

This commit is contained in:
HanishKVC 2024-05-28 00:32:37 +05:30
parent 269cf3f596
commit f5f9a2b35e
2 changed files with 15 additions and 1 deletions

View file

@ -185,3 +185,17 @@ export function trim_hist_garbage_at_end_loop(sIn, maxType, maxUniq, maxMatchLen
sCur = got.data; sCur = got.data;
} }
} }
/**
* Try trim garbage at the end by using both the hist-driven-garbage-trimming as well as
* skip-a-bit-if-reqd-then-repeat-pattern-based-garbage-trimming, with blind retrying.
* @param {string} sIn
*/
export function trim_garbage_at_end(sIn) {
let sCur = sIn;
for(let i=0; i<2; i++) {
sCur = trim_hist_garbage_at_end_loop(sCur, 8, 24, 72);
sCur = trim_repeat_garbage_at_end_loop(sCur, 32, 72, 12);
}
return sCur;
}

View file

@ -228,7 +228,7 @@ class SimpleChat {
} }
if (gMe.bTrimGarbage) { if (gMe.bTrimGarbage) {
let origMsg = theResp.assistant; let origMsg = theResp.assistant;
theResp.assistant = du.trim_hist_garbage_at_end_loop(theResp.assistant, 8, 24, 72); theResp.assistant = du.trim_garbage_at_end(theResp.assistant);
theResp.trimmed = origMsg.substring(theResp.assistant.length); theResp.trimmed = origMsg.substring(theResp.assistant.length);
} }
return theResp; return theResp;