From 9f0c2300d2d36e43c609fbf75d97e9d68a872c1e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:24:40 +0300 Subject: [PATCH 1/6] Add connection map aliases --- public/script.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/script.js b/public/script.js index 6d93bc03b..2e8b8d736 100644 --- a/public/script.js +++ b/public/script.js @@ -8476,12 +8476,22 @@ const CONNECT_API_MAP = { selected: 'novel', button: '#api_button_novel', }, + 'koboldcpp': { + selected: 'textgenerationwebui', + button: '#api_button_textgenerationwebui', + type: textgen_types.KOBOLDCPP, + }, // KoboldCpp alias 'kcpp': { selected: 'textgenerationwebui', button: '#api_button_textgenerationwebui', type: textgen_types.KOBOLDCPP, }, + 'openai': { + selected: 'openai', + button: '#api_button_openai', + source: chat_completion_sources.OPENAI, + }, // OpenAI alias 'oai': { selected: 'openai', From 2f43c8e227205a31bb8adb1110ea9d549e4cef17 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:12:26 +0300 Subject: [PATCH 2/6] Fix /ask in neutral chats --- public/scripts/slash-commands.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index d9bdd4e7a..eb81a0218 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -2530,8 +2530,13 @@ async function askCharacter(args, text) { return; } - setCharacterId(prevChId); - setCharacterName(characters[prevChId].name); + if (prevChId !== undefined) { + setCharacterId(prevChId); + setCharacterName(characters[prevChId].name); + } else { + setCharacterId(undefined); + setCharacterName(neutralCharacterName); + } // Only force the new avatar if the character name is the same // This skips if an error was fired From 8061f453687bfc95edb3de7a3d6702dd48c42bd8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 29 Sep 2024 19:13:19 +0300 Subject: [PATCH 3/6] RossMods: Debounce online status display --- public/scripts/RossAscends-mods.js | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index 92278f35c..1a9e2d7d2 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -56,22 +56,25 @@ let counterNonce = Date.now(); const observerConfig = { childList: true, subtree: true }; const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed); +const countTokensShortDebounced = debounce(RA_CountCharTokens, debounce_timeout.short); +const checkStatusDebounced = debounce(RA_checkOnlineStatus, debounce_timeout.short); const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { + if (!(mutation.target instanceof HTMLElement)) { + return; + } if (mutation.target.classList.contains('online_status_text')) { - RA_checkOnlineStatus(); + checkStatusDebounced(); } else if (mutation.target.parentNode === SelectedCharacterTab) { - setTimeout(RA_CountCharTokens, 200); + countTokensShortDebounced(); } else if (mutation.target.classList.contains('mes_text')) { - if (mutation.target instanceof HTMLElement) { - for (const element of mutation.target.getElementsByTagName('math')) { - element.childNodes.forEach(function (child) { - if (child.nodeType === Node.TEXT_NODE) { - child.textContent = ''; - } - }); - } + for (const element of mutation.target.getElementsByTagName('math')) { + element.childNodes.forEach(function (child) { + if (child.nodeType === Node.TEXT_NODE) { + child.textContent = ''; + } + }); } } }); @@ -159,8 +162,8 @@ export function shouldSendOnEnter() { export function humanizedDateTime() { const now = new Date(Date.now()); const dt = { - year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), - hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), + year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), + hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), }; for (const key in dt) { dt[key] = dt[key].toString().padStart(2, '0'); @@ -725,9 +728,7 @@ export function addSafariPatch() { export function initRossMods() { // initial status check - setTimeout(() => { - RA_checkOnlineStatus(); - }, 100); + checkStatusDebounced(); if (power_user.auto_load_chat) { RA_autoloadchat(); @@ -752,7 +753,7 @@ export function initRossMods() { setTimeout(() => RA_autoconnect(PrevAPI), 100); }); - $('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); }); + $('#api_button').on('click', () => checkStatusDebounced()); //toggle pin class when lock toggle clicked $(RPanelPin).on('click', function () { From 020741d78b403f302c5f6ee7cc7c928463e040f1 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Mon, 30 Sep 2024 21:49:39 +0900 Subject: [PATCH 4/6] make AF panel toggles red and opaque when disabled --- public/index.html | 69 ++++++++++++++++++++++++----------------------- public/style.css | 23 +++++++++++++--- 2 files changed, 56 insertions(+), 36 deletions(-) diff --git a/public/index.html b/public/index.html index 13f59da05..0aed22dc3 100644 --- a/public/index.html +++ b/public/index.html @@ -3248,25 +3248,26 @@
+

+
+ Instruct Template + + + +
+
+ + +
+

-

-
- Instruct Template - - - -
-
- - -
-

+
@@ -3431,21 +3432,22 @@
+

+
+ System Prompt + + + +
+
+ +
+

-

-
- System Prompt - - - -
-
- -
-

+
@@ -5939,7 +5941,8 @@
- diff --git a/public/style.css b/public/style.css index 1c8096d86..fc5ab520e 100644 --- a/public/style.css +++ b/public/style.css @@ -978,13 +978,21 @@ body .panelControlBar { justify-content: center; z-index: 9999; grid-row-start: 2; - grid-column-start: 4; - flex-flow: column; font-size: 30px; cursor: pointer; align-self: center; + +} +.swipe_left{ +position: absolute; +bottom: 15px; +flex-flow: column; +} + +.swipeRightBlock { position: absolute; - bottom: 15px; + right: 0; + bottom: 0; } .swipes-counter { @@ -994,6 +1002,9 @@ body .panelControlBar { font-family: var(--mainFontFamily); font-weight: 400; align-self: center; + min-width: 40px; + display: flex; + justify-content: center; } .swipe_left { @@ -1003,6 +1014,7 @@ body .panelControlBar { .swipe_right { right: 5px; + align-self:end; } .ui-settings { @@ -2634,6 +2646,11 @@ select option:not(:checked) { color: var(--active) !important; } +#instruct_enabled_label .menu_button:not(.toggleEnabled), +#sysprompt_enabled_label .menu_button:not(.toggleEnabled) { + color: Red; +} + .displayBlock { display: block !important; } From 8cb4aa6a495d4056d9c6d9997d35b0dbc33319f8 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:00:38 +0900 Subject: [PATCH 5/6] whoopsie daisey --- public/index.html | 7 +++---- public/style.css | 10 +--------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/public/index.html b/public/index.html index 0aed22dc3..741871edd 100644 --- a/public/index.html +++ b/public/index.html @@ -5941,10 +5941,9 @@
-
- -
-
+
diff --git a/public/style.css b/public/style.css index fc5ab520e..7d55cf832 100644 --- a/public/style.css +++ b/public/style.css @@ -981,19 +981,11 @@ body .panelControlBar { font-size: 30px; cursor: pointer; align-self: center; - -} -.swipe_left{ -position: absolute; + position: absolute; bottom: 15px; flex-flow: column; } -.swipeRightBlock { - position: absolute; - right: 0; - bottom: 0; -} .swipes-counter { color: var(--SmartThemeBodyColor); From dedb96ec8d6f99c1ff8742ca4ae039e43b913926 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:05:15 +0000 Subject: [PATCH 6/6] Don't trim on whitespace user prefix sequence --- public/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 2e8b8d736..cda7adea3 100644 --- a/public/script.js +++ b/public/script.js @@ -5427,6 +5427,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>')); } const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; + const isNotEmpty = (str) => str && str.trim() !== ''; if (isInstruct && power_user.instruct.stop_sequence) { if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) { getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.stop_sequence)); @@ -5434,7 +5435,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc } // Hana: Only use the first sequence (should be <|model|>) // of the prompt before <|user|> (as KoboldAI Lite does it). - if (isInstruct && power_user.instruct.input_sequence) { + if (isInstruct && isNotEmpty(power_user.instruct.input_sequence)) { if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) { getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence)); }