From 73ee6af993dffed8d511b964dc7597365fa4ebe5 Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 12 Aug 2022 21:39:07 -0400 Subject: [PATCH] Token Usage Highlighting Fix --- static/koboldai.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/koboldai.js b/static/koboldai.js index adbd8a98..7762aa85 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1962,13 +1962,14 @@ function update_token_lengths() { } //go backwards through the text chunks and tag them if we still have space + passed_token_limit = false; for (var chunk=max_chunk;chunk >= 0;chunk--) { if (document.getElementById("Selected Text Chunk "+chunk).getAttribute("token_length") == null) { current_chunk_length = 999999999999; } else { current_chunk_length = parseInt(document.getElementById("Selected Text Chunk "+chunk).getAttribute("token_length")); } - if ((current_chunk_length != 0) && (token_length+current_chunk_length < max_token_length)) { + if ((current_chunk_length != 0) && (token_length+current_chunk_length < max_token_length)&& (!(passed_token_limit))) { token_length += current_chunk_length; document.getElementById("Selected Text Chunk "+chunk).classList.add("within_max_length"); uids = document.getElementById("Selected Text Chunk "+chunk).getAttribute("world_info_uids") @@ -1979,6 +1980,9 @@ function update_token_lengths() { document.getElementById("world_info_"+uid).classList.add("world_info_included"); } } + } else if (!(passed_token_limit) && (current_chunk_length != 0)) { + passed_token_limit = true; + document.getElementById("Selected Text Chunk "+chunk).classList.remove("within_max_length"); } else { document.getElementById("Selected Text Chunk "+chunk).classList.remove("within_max_length"); }