From b77473ed7637939704a78ed7e59bfb1311f65a50 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Tue, 2 May 2023 18:54:19 +0900 Subject: [PATCH 1/2] indicator for last message in chat context (WIP) --- public/script.js | 13 +++++++++++-- public/style.css | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index d3b98da6d..5c41080f9 100644 --- a/public/script.js +++ b/public/script.js @@ -1726,8 +1726,14 @@ async function Generate(type, automatic_trigger, force_name2) { if (canFitMessages()) { //(The number of tokens in the entire promt) need fix, it must count correctly (added +120, so that the description of the character does not hide) //if (is_pygmalion && i == chat2.length-1) item='\n'+item; arrMes[arrMes.length] = item; + } else { + $("#chat").children().removeClass('lastInContext'); + console.log(arrMes.length); + + $(`#chat .mes:nth-last-of-type(${arrMes.length + 1})`).addClass('lastInContext'); break; + } await delay(1); //For disable slow down (encode gpt-2 need fix) } @@ -1821,6 +1827,7 @@ async function Generate(type, automatic_trigger, force_name2) { let mesSendString = ''; function setPromtString() { + console.log('--setting Prompt string'); mesExmString = pinExmString ?? mesExamplesArray.slice(0, count_exm_add).join(''); mesSendString = ''; for (let j = 0; j < mesSend.length; j++) { @@ -1844,6 +1851,7 @@ async function Generate(type, automatic_trigger, force_name2) { } function checkPromtSize() { + console.log('---checking Prompt size'); setPromtString(); const prompt = [ worldInfoString, @@ -1868,15 +1876,16 @@ async function Generate(type, automatic_trigger, force_name2) { checkPromtSize(); // and check size again.. } else { //end + console.log(`---mesSend.length = ${mesSend.length}`); } } } if (generatedPromtCache.length > 0) { - //console.log('Generated Prompt Cache length: '+generatedPromtCache.length); + console.log('---Generated Prompt Cache length: ' + generatedPromtCache.length); checkPromtSize(); } else { - //console.log('calling setPromtString') + console.log('---calling setPromtString ' + generatedPromtCache.length) setPromtString(); } diff --git a/public/style.css b/public/style.css index 72f9406b9..fd2a54b23 100644 --- a/public/style.css +++ b/public/style.css @@ -3956,6 +3956,10 @@ body.waifuMode #avatar_zoom_popup { } } +.lastInContext { + border-top: 5px dashed var(--SmartThemeQuoteColor) !important; +} + @media screen and (max-width: 1000px) and (orientation: landscape) { body.waifuMode img.expression { object-fit: contain; From 4ad659bb766e2015dc72064a9077fab9a2c70074 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Tue, 2 May 2023 19:58:52 +0900 Subject: [PATCH 2/2] better? message selection for last-in-context --- public/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index 5c41080f9..52abed152 100644 --- a/public/script.js +++ b/public/script.js @@ -1731,7 +1731,7 @@ async function Generate(type, automatic_trigger, force_name2) { $("#chat").children().removeClass('lastInContext'); console.log(arrMes.length); - $(`#chat .mes:nth-last-of-type(${arrMes.length + 1})`).addClass('lastInContext'); + $(`#chat .mes:nth-last-child(${arrMes.length})`).addClass('lastInContext'); break; } @@ -1937,7 +1937,7 @@ async function Generate(type, automatic_trigger, force_name2) { if (power_user.collapse_newlines) { finalPromt = collapseNewlines(finalPromt); } - + //console.log(`---Calculated Prompt Tokens: ${getTokenCount(finalPromt, padding_tokens)}`); let this_amount_gen = parseInt(amount_gen); // how many tokens the AI will be requested to generate let this_settings = koboldai_settings[koboldai_setting_names[preset_settings]];