Fix not counting chat separator and preamble toward token limit

This commit is contained in:
Cohee
2024-08-29 23:36:07 +03:00
parent 2b904bb170
commit b21ba850c0

View File

@@ -3760,7 +3760,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
} }
let examplesString = ''; let examplesString = '';
let chatString = ''; let chatString = addChatsPreamble(addChatsSeparator(''));
let cyclePrompt = ''; let cyclePrompt = '';
async function getMessagesTokenCount() { async function getMessagesTokenCount() {
@@ -4028,12 +4028,13 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
async function checkPromptSize() { async function checkPromptSize() {
console.debug('---checking Prompt size'); console.debug('---checking Prompt size');
setPromptString(); setPromptString();
const jointMessages = mesSend.map((e) => `${e.extensionPrompts.join('')}${e.message}`).join('');
const prompt = [ const prompt = [
beforeScenarioAnchor, beforeScenarioAnchor,
storyString, storyString,
afterScenarioAnchor, afterScenarioAnchor,
mesExmString, mesExmString,
mesSend.map((e) => `${e.extensionPrompts.join('')}${e.message}`).join(''), addChatsPreamble(addChatsSeparator(jointMessages)),
'\n', '\n',
generatedPromptCache, generatedPromptCache,
quiet_prompt, quiet_prompt,