Fix last prompt line not counted toward token limit
| @@ -3769,10 +3769,10 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3769 | 3769 | storyString, |
| 3770 | 3770 | afterScenarioAnchor, |
| 3771 | 3771 | examplesString, |
| 3772 | + userAlignmentMessage, | |
| 3772 | 3773 | chatString, |
| 3773 | - quiet_prompt, | |
| 3774 | + modifyLastPromptLine(''), | |
| 3774 | 3775 | cyclePrompt, |
| 3775 | - userAlignmentMessage, | |
| 3776 | 3776 | ].join('').replace(/\r/gm, ''); |
| 3777 | 3777 | return getTokenCountAsync(encodeString, power_user.token_padding); |
| 3778 | 3778 | } |
| @@ -3803,8 +3803,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3803 | 3803 | } |
| 3804 | 3804 | |
| 3805 | 3805 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); |
| 3806 | - chatString = item + chatString; | |
| 3807 | 3806 | if (tokenCount < this_max_context) { |
| 3807 | + chatString = chatString + item; | |
| 3808 | 3808 | arrMes[index] = item; |
| 3809 | 3809 | lastAddedIndex = Math.max(lastAddedIndex, index); |
| 3810 | 3810 | } else { |
| @@ -3830,8 +3830,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3830 | 3830 | } |
| 3831 | 3831 | |
| 3832 | 3832 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); |
| 3833 | - chatString = item + chatString; | |
| 3834 | 3833 | if (tokenCount < this_max_context) { |
| 3834 | + chatString = chatString + item; | |
| 3835 | 3835 | arrMes[i] = item; |
| 3836 | 3836 | lastAddedIndex = Math.max(lastAddedIndex, i); |
| 3837 | 3837 | } else { |
| @@ -4036,8 +4036,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 4036 | 4036 | mesExmString, |
| 4037 | 4037 | addChatsPreamble(addChatsSeparator(jointMessages)), |
| 4038 | 4038 | '\n', |
| 4039 | + modifyLastPromptLine(''), | |
| 4039 | 4040 | generatedPromptCache, |
| 4040 | - quiet_prompt, | |
| 4041 | 4041 | ].join('').replace(/\r/gm, ''); |
| 4042 | 4042 | let thisPromptContextSize = await getTokenCountAsync(prompt, power_user.token_padding); |
| 4043 | 4043 | |