Merge branch 'staging' into char-find-and-sendas-extended

0d83480e90064b22beced18df76094f6363d5d5e

Cohee <18619528+Cohee1207@users.noreply.github.com>

5 files changed, +85 -57Ignore whitespace
public/index.html+37 -35
@@ -3248,25 +3248,26 @@
32483248 </div>
32493249 </div>
32503250 <div id="InstructSettingsColumn" class="flex-container flexNoGap flexFlowColumn flex1">
3251+ <h4 class="standoutHeader title_restorable justifySpaceBetween">
3252+ <div class="flex-container">
3253+ <span data-i18n="Instruct Template">Instruct Template</span>
3254+ <a href="https://docs.sillytavern.app/usage/core-concepts/instructmode/" class="notes-link" target="_blank">
3255+ <span class="fa-solid fa-circle-question note-link-span"></span>
3256+ </a>
3257+ </div>
3258+ <div class="flex-container">
3259+ <label for="instruct_bind_to_context" class="checkbox_label flex1" title="Bind to Context&#10If enabled, Context templates will be automatically selected based on selected Instruct template name or by preference." data-i18n="[title]instruct_bind_to_context">
3260+ <input id="instruct_bind_to_context" type="checkbox" style="display:none;" />
3261+ <small><i class="fa-solid fa-link menu_button margin0"></i></small>
3262+ </label>
3263+ <label id="instruct_enabled_label"for="instruct_enabled" class="checkbox_label flex1" title="Enable Instruct Mode" data-i18n="[title]instruct_enabled">
3264+ <input id="instruct_enabled" type="checkbox" style="display:none;" />
3265+ <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
3266+ </label>
3267+ </div>
3268+ </h4>
32513269 <div id="instructSettingsBlock">
3252- <h4 class="standoutHeader title_restorable justifySpaceBetween">
3270+
3253- <div class="flex-container">
3254- <span data-i18n="Instruct Template">Instruct Template</span>
3255- <a href="https://docs.sillytavern.app/usage/core-concepts/instructmode/" class="notes-link" target="_blank">
3256- <span class="fa-solid fa-circle-question note-link-span"></span>
3257- </a>
3258- </div>
3259- <div class="flex-container">
3260- <label for="instruct_bind_to_context" class="checkbox_label flex1" title="Bind to Context&#10If enabled, Context templates will be automatically selected based on selected Instruct template name or by preference." data-i18n="[title]instruct_bind_to_context">
3261- <input id="instruct_bind_to_context" type="checkbox" style="display:none;" />
3262- <small><i class="fa-solid fa-link menu_button margin0"></i></small>
3263- </label>
3264- <label for="instruct_enabled" class="checkbox_label flex1" title="Enable Instruct Mode" data-i18n="[title]instruct_enabled">
3265- <input id="instruct_enabled" type="checkbox" style="display:none;" />
3266- <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
3267- </label>
3268- </div>
3269- </h4>
32703271
32713272 <div class="flex-container" title="Select your current Instruct Template" data-i18n="[title]Select your current Instruct Template">
32723273 <select id="instruct_presets" data-preset-manager-for="instruct" class="flex1 text_pole"></select>
@@ -3431,21 +3432,22 @@
34313432 </div>
34323433 </div>
34333434 <div id="SystemPromptColumn" class="flex-container flexNoGap flexFlowColumn flex1">
3435+ <h4 class="standoutHeader title_restorable justifySpaceBetween">
3436+ <div class="flex-container">
3437+ <span data-i18n="System Prompt">System Prompt</span>
3438+ <a href="https://docs.sillytavern.app/usage/core-concepts/advancedformatting/#system-prompt" class="notes-link" target="_blank">
3439+ <span class="fa-solid fa-circle-question note-link-span"></span>
3440+ </a>
3441+ </div>
3442+ <div class="flex-container">
3443+ <label id="sysprompt_enabled_label" for="sysprompt_enabled" class="checkbox_label flex1" title="Enable System Prompt" data-i18n="[title]sysprompt_enabled">
3444+ <input id="sysprompt_enabled" type="checkbox" style="display:none;" />
3445+ <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
3446+ </label>
3447+ </div>
3448+ </h4>
34343449 <div id="SystemPromptBlock">
3435- <h4 class="standoutHeader title_restorable justifySpaceBetween">
3450+
3436- <div class="flex-container">
3437- <span data-i18n="System Prompt">System Prompt</span>
3438- <a href="https://docs.sillytavern.app/usage/core-concepts/advancedformatting/#system-prompt" class="notes-link" target="_blank">
3439- <span class="fa-solid fa-circle-question note-link-span"></span>
3440- </a>
3441- </div>
3442- <div class="flex-container">
3443- <label for="sysprompt_enabled" class="checkbox_label flex1" title="Enable System Prompt" data-i18n="[title]sysprompt_enabled">
3444- <input id="sysprompt_enabled" type="checkbox" style="display:none;" />
3445- <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
3446- </label>
3447- </div>
3448- </h4>
34493451
34503452 <div class="flex-container" title="Select your current System Prompt" data-i18n="[title]Select your current System Prompt">
34513453 <select id="sysprompt_select" data-preset-manager-for="sysprompt" class="flex1 text_pole"></select>
@@ -5939,9 +5941,9 @@
59395941 </div>
59405942 <div class="mes_bias"></div>
59415943 </div>
59425944 <div class="swipe_right fa-solid fa-chevron-right" style="display: none;">
59435945 <div class="swipes-counter"></div>
59445946 </div>
59455947 </div>
59465948 </div>
59475949 <div id="group_avatars_template" class="template_element">
public/script.js+12 -1
@@ -5428,6 +5428,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
54285428 getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>'));
54295429 }
54305430 const isInstruct = power_user.instruct.enabled && main_api !== 'openai';
5431+ const isNotEmpty = (str) => str && str.trim() !== '';
54315432 if (isInstruct && power_user.instruct.stop_sequence) {
54325433 if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) {
54335434 getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.stop_sequence));
@@ -5435,7 +5436,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
54355436 }
54365437 // Hana: Only use the first sequence (should be <|model|>)
54375438 // of the prompt before <|user|> (as KoboldAI Lite does it).
54385439 if (isInstruct && isNotEmpty(power_user.instruct.input_sequence)) {
54395440 if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) {
54405441 getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence));
54415442 }
@@ -8477,12 +8478,22 @@ const CONNECT_API_MAP = {
84778478 selected: 'novel',
84788479 button: '#api_button_novel',
84798480 },
8481+ 'koboldcpp': {
8482+ selected: 'textgenerationwebui',
8483+ button: '#api_button_textgenerationwebui',
8484+ type: textgen_types.KOBOLDCPP,
8485+ },
84808486 // KoboldCpp alias
84818487 'kcpp': {
84828488 selected: 'textgenerationwebui',
84838489 button: '#api_button_textgenerationwebui',
84848490 type: textgen_types.KOBOLDCPP,
84858491 },
8492+ 'openai': {
8493+ selected: 'openai',
8494+ button: '#api_button_openai',
8495+ source: chat_completion_sources.OPENAI,
8496+ },
84868497 // OpenAI alias
84878498 'oai': {
84888499 selected: 'openai',
public/scripts/RossAscends-mods.js+17 -16
@@ -56,22 +56,25 @@ let counterNonce = Date.now();
5656
5757const observerConfig = { childList: true, subtree: true };
5858const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed);
59+const countTokensShortDebounced = debounce(RA_CountCharTokens, debounce_timeout.short);
60+const checkStatusDebounced = debounce(RA_checkOnlineStatus, debounce_timeout.short);
5961
6062const observer = new MutationObserver(function (mutations) {
6163 mutations.forEach(function (mutation) {
64+ if (!(mutation.target instanceof HTMLElement)) {
65+ return;
66+ }
6267 if (mutation.target.classList.contains('online_status_text')) {
6368 RA_checkOnlineStatuscheckStatusDebounced();
6469 } else if (mutation.target.parentNode === SelectedCharacterTab) {
6570 setTimeoutcountTokensShortDebounced(RA_CountCharTokens, 200);
6671 } else if (mutation.target.classList.contains('mes_text')) {
67- if (mutation.target instanceof HTMLElement) {
72+ for (const element of mutation.target.getElementsByTagName('math')) {
68- for (const element of mutation.target.getElementsByTagName('math')) {
73+ element.childNodes.forEach(function (child) {
69- element.childNodes.forEach(function (child) {
74+ if (child.nodeType === Node.TEXT_NODE) {
70- if (child.nodeType === Node.TEXT_NODE) {
75+ child.textContent = '';
71- child.textContent = '';
76+ }
72- }
77+ });
73- });
74- }
7578 }
7679 }
7780 });
@@ -159,8 +162,8 @@ export function shouldSendOnEnter() {
159162export function humanizedDateTime() {
160163 const now = new Date(Date.now());
161164 const dt = {
162165 year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(),
163166 hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(),
164167 };
165168 for (const key in dt) {
166169 dt[key] = dt[key].toString().padStart(2, '0');
@@ -725,9 +728,7 @@ export function addSafariPatch() {
725728
726729export function initRossMods() {
727730 // initial status check
728- setTimeout(() => {
731+ checkStatusDebounced();
729- RA_checkOnlineStatus();
730- }, 100);
731732
732733 if (power_user.auto_load_chat) {
733734 RA_autoloadchat();
@@ -752,7 +753,7 @@ export function initRossMods() {
752753 setTimeout(() => RA_autoconnect(PrevAPI), 100);
753754 });
754755
755756 $('#api_button').clickon(function'click', () {=> setTimeoutcheckStatusDebounced(RA_checkOnlineStatus, 100); });
756757
757758 //toggle pin class when lock toggle clicked
758759 $(RPanelPin).on('click', function () {
public/scripts/slash-commands.js+7 -2
@@ -2598,8 +2598,13 @@ async function askCharacter(args, text) {
25982598 return;
25992599 }
26002600
2601- setCharacterId(prevChId);
2601+ if (prevChId !== undefined) {
2602- setCharacterName(characters[prevChId].name);
2602+ setCharacterId(prevChId);
2603+ setCharacterName(characters[prevChId].name);
2604+ } else {
2605+ setCharacterId(undefined);
2606+ setCharacterName(neutralCharacterName);
2607+ }
26032608
26042609 // Only force the new avatar if the character name is the same
26052610 // This skips if an error was fired
public/style.css+12 -3
@@ -978,15 +978,15 @@ body .panelControlBar {
978978 justify-content: center;
979979 z-index: 9999;
980980 grid-row-start: 2;
981- grid-column-start: 4;
982- flex-flow: column;
983981 font-size: 30px;
984982 cursor: pointer;
985983 align-self: center;
986984 position: absolute;
987985 bottom: 15px;
986+flex-flow: column;
988987}
989988
989+
990990.swipes-counter {
991991 color: var(--SmartThemeBodyColor);
992992 font-size: 12px;
@@ -994,6 +994,9 @@ body .panelControlBar {
994994 font-family: var(--mainFontFamily);
995995 font-weight: 400;
996996 align-self: center;
997+ min-width: 40px;
998+ display: flex;
999+ justify-content: center;
9971000}
9981001
9991002.swipe_left {
@@ -1003,6 +1006,7 @@ body .panelControlBar {
10031006
10041007.swipe_right {
10051008 right: 5px;
1009+ align-self:end;
10061010}
10071011
10081012.ui-settings {
@@ -2634,6 +2638,11 @@ select option:not(:checked) {
26342638 color: var(--active) !important;
26352639}
26362640
2641+#instruct_enabled_label .menu_button:not(.toggleEnabled),
2642+#sysprompt_enabled_label .menu_button:not(.toggleEnabled) {
2643+ color: Red;
2644+}
2645+
26372646.displayBlock {
26382647 display: block !important;
26392648}