From 3f28be16d49eb715f01243f39ebc8c13ca03d676 Mon Sep 17 00:00:00 2001 From: ebolam Date: Sun, 3 Jul 2022 16:57:41 -0400 Subject: [PATCH] Fix for token length --- static/koboldai.js | 22 ++++++++++++++++++---- templates/story flyout.html | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index 1ab2d307..48909160 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -903,11 +903,25 @@ function upload_file(file_box) { //--------------------------------------------General UI Functions------------------------------------ function update_token_lengths() { max_token_length = parseInt(document.getElementById("model_max_length_cur").value); - token_length = 0; - token_length += parseInt(document.getElementById("memory").getAttribute("story_memory_length")); - token_length += parseInt(document.getElementById("authors_nodes").getAttribute("story_authornote_length")); + if ((document.getElementById("memory").getAttribute("story_memory_length") == null) || (document.getElementById("memory").getAttribute("story_memory_length") == "")) { + memory_length = 0; + } else { + memory_length = parseInt(document.getElementById("memory").getAttribute("story_memory_length")); + } + if ((document.getElementById("authors_notes").getAttribute("story_authornote_length") == null) || (document.getElementById("authors_notes").getAttribute("story_authornote_length") == "")) { + authors_notes = 0; + } else { + authors_notes = parseInt(document.getElementById("authors_notes").getAttribute("story_authornote_length")); + } + if ((document.getElementById("story_prompt").getAttribute("story_prompt_length") == null) || (document.getElementById("story_prompt").getAttribute("story_prompt_length") == "")) { + prompt_length = 0; + } else { + prompt_length = parseInt(document.getElementById("story_prompt").getAttribute("story_prompt_length")); + } + + token_length = memory_length + authors_notes; + always_prompt = document.getElementById("story_useprompt").value == "true"; - prompt_length = parseInt(document.getElementById("story_prompt").getAttribute("story_prompt_length")); if (always_prompt) { token_length += prompt_length document.getElementById("story_prompt").classList.add("within_max_length"); diff --git a/templates/story flyout.html b/templates/story flyout.html index 2b0deb91..b2c3ad56 100644 --- a/templates/story flyout.html +++ b/templates/story flyout.html @@ -14,7 +14,7 @@ Status:

Author's Notes:
-
+
Template:

andepth