From f92249790f86cde976cb5dba9f08f87c572c66b1 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 10 Sep 2023 00:58:37 +0300 Subject: [PATCH] The return of permanent tokens display --- public/index.html | 21 ++++++++++++++------- public/scripts/RossAscends-mods.js | 5 +++++ public/style.css | 11 +++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index 890be2906..2ca5ebac5 100644 --- a/public/index.html +++ b/public/index.html @@ -3233,9 +3233,16 @@
diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 0bbd92665..758abcaeb 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -210,10 +210,12 @@ $("#character_popup").on("input", function () { countTokensDebounced(); }); //function: export function RA_CountCharTokens() { let total_tokens = 0; + let permanent_tokens = 0; $('[data-token-counter]').each(function () { const counter = $(this); const input = $(document.getElementById(counter.data('token-counter'))); + const isPermanent = counter.data('token-permanent') === true; const value = String(input.val()); if (input.length === 0) { @@ -230,10 +232,12 @@ export function RA_CountCharTokens() { if (input.data('last-value-hash') === valueHash) { total_tokens += Number(counter.text()); + permanent_tokens += isPermanent ? Number(counter.text()) : 0; } else { const tokens = getTokenCount(value); counter.text(tokens); total_tokens += tokens; + permanent_tokens += isPermanent ? tokens : 0; input.data('last-value-hash', valueHash); } }); @@ -242,6 +246,7 @@ export function RA_CountCharTokens() { const tokenLimit = Math.max(((main_api !== 'openai' ? max_context : oai_settings.openai_max_context) / 2), 1024); const showWarning = (total_tokens > tokenLimit); $('#result_info_total_tokens').text(total_tokens); + $('#result_info_permanent_tokens').text(permanent_tokens); $('#result_info_text').toggleClass('neutral_warning', showWarning); $('#chartokenwarning').toggle(showWarning); } diff --git a/public/style.css b/public/style.css index ef21e17c7..daa55b596 100644 --- a/public/style.css +++ b/public/style.css @@ -1172,7 +1172,7 @@ input[type="file"] { #rm_ch_create_block { display: none; overflow-y: auto; - padding: 0 5px; + padding: 5px; height: 100%; } @@ -1767,10 +1767,17 @@ grammarly-extension { #result_info { font-size: calc(var(--mainFontSize) * 0.9); display: flex; - align-items: baseline; + align-items: center; gap: 10px; } +#result_info_text { + display: flex; + flex-direction: column; + line-height: 1; + text-align: right; +} + .rm_stats_button { cursor: pointer; }