Skip to content

Commit

Permalink
SimpleChat:DU: Bring in both trim garbage logics to try trim
Browse files Browse the repository at this point in the history
  • Loading branch information
hanishkvc committed May 27, 2024
1 parent 4a7be33 commit 8f55ca7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/server/public_simplechat/datautils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,17 @@ export function trim_hist_garbage_at_end_loop(sIn, maxType, maxUniq, maxMatchLen
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;
}
2 changes: 1 addition & 1 deletion examples/server/public_simplechat/simplechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class SimpleChat {
}
if (gMe.bTrimGarbage) {
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);
}
return theResp;
Expand Down

0 comments on commit 8f55ca7

Please sign in to comment.