Fix continue token count overflow

This commit is contained in:
Cohee 2023-08-31 00:16:58 +03:00
parent a5aadd936c
commit c6bbbf1c25

View File

@ -2545,6 +2545,8 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
let examplesString = '';
let chatString = '';
let cyclePrompt = '';
function getMessagesTokenCount() {
const encodeString = [
storyString,
@ -2552,6 +2554,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
chatString,
allAnchors,
quiet_prompt,
cyclePrompt,
].join('').replace(/\r/gm, '');
return getTokenCount(encodeString, power_user.token_padding);
}
@ -2562,7 +2565,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
pinExmString = examplesString = mesExamplesArray.join('');
}
let cyclePrompt = '';
if (isContinue) {
cyclePrompt = chat2.shift();
}