From da01384cb621c9e8af03c1feda29f3db6ab19be2 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:24:49 +0300 Subject: [PATCH] Itemization: Deduct chat injects from total chat messages --- public/script.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 4b9b7d42b..b329c2c56 100644 --- a/public/script.js +++ b/public/script.js @@ -4027,7 +4027,8 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu ...thisPromptBits[currentArrayEntry], rawPrompt: generate_data.prompt || generate_data.input, mesId: getNextMessageId(type), - allAnchors: '', + allAnchors: getAllExtensionPrompts(), + chatInjects: injectedIndices?.map(index => arrMes[arrMes.length - index - 1])?.join('') || '', summarizeString: (extension_prompts['1_memory']?.value || ''), authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''), smartContextString: (extension_prompts['chromadb']?.value || ''), @@ -4651,8 +4652,13 @@ function promptItemize(itemizedPrompts, requestedMesId) { zeroDepthAnchorTokens: getTokenCount(itemizedPrompts[thisPromptSet].zeroDepthAnchor), // TODO: unused thisPrompt_padding: itemizedPrompts[thisPromptSet].padding, this_main_api: itemizedPrompts[thisPromptSet].main_api, + chatInjects: getTokenCount(itemizedPrompts[thisPromptSet].chatInjects), }; + if (params.chatInjects){ + params.ActualChatHistoryTokens = params.ActualChatHistoryTokens - params.chatInjects; + } + if (params.this_main_api == 'openai') { //for OAI API //console.log('-- Counting OAI Tokens');