mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-31 19:45:35 +01:00
Fix last prompt line not counted toward token limit
This commit is contained in:
parent
b21ba850c0
commit
9010880b64
@ -3769,10 +3769,10 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
storyString,
|
||||
afterScenarioAnchor,
|
||||
examplesString,
|
||||
chatString,
|
||||
quiet_prompt,
|
||||
cyclePrompt,
|
||||
userAlignmentMessage,
|
||||
chatString,
|
||||
modifyLastPromptLine(''),
|
||||
cyclePrompt,
|
||||
].join('').replace(/\r/gm, '');
|
||||
return getTokenCountAsync(encodeString, power_user.token_padding);
|
||||
}
|
||||
@ -3803,8 +3803,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
}
|
||||
|
||||
tokenCount += await getTokenCountAsync(item.replace(/\r/gm, ''));
|
||||
chatString = item + chatString;
|
||||
if (tokenCount < this_max_context) {
|
||||
chatString = chatString + item;
|
||||
arrMes[index] = item;
|
||||
lastAddedIndex = Math.max(lastAddedIndex, index);
|
||||
} else {
|
||||
@ -3830,8 +3830,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
}
|
||||
|
||||
tokenCount += await getTokenCountAsync(item.replace(/\r/gm, ''));
|
||||
chatString = item + chatString;
|
||||
if (tokenCount < this_max_context) {
|
||||
chatString = chatString + item;
|
||||
arrMes[i] = item;
|
||||
lastAddedIndex = Math.max(lastAddedIndex, i);
|
||||
} else {
|
||||
@ -4036,8 +4036,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
mesExmString,
|
||||
addChatsPreamble(addChatsSeparator(jointMessages)),
|
||||
'\n',
|
||||
modifyLastPromptLine(''),
|
||||
generatedPromptCache,
|
||||
quiet_prompt,
|
||||
].join('').replace(/\r/gm, '');
|
||||
let thisPromptContextSize = await getTokenCountAsync(prompt, power_user.token_padding);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user