Merge branch 'staging' into char-find-and-sendas-extended
| @@ -3248,25 +3248,26 @@ | |||
| 3248 | </div> | 3248 | </div> |
| 3249 | </div> | 3249 | </div> |
| 3250 | <div id="InstructSettingsColumn" class="flex-container flexNoGap flexFlowColumn flex1"> | 3250 | <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
If 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> | ||
| 3251 | <div id="instructSettingsBlock"> | 3269 | <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
If 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> | ||
| 3270 | 3271 | ||
| 3271 | <div class="flex-container" title="Select your current Instruct Template" data-i18n="[title]Select your current Instruct Template"> | 3272 | <div class="flex-container" title="Select your current Instruct Template" data-i18n="[title]Select your current Instruct Template"> |
| 3272 | <select id="instruct_presets" data-preset-manager-for="instruct" class="flex1 text_pole"></select> | 3273 | <select id="instruct_presets" data-preset-manager-for="instruct" class="flex1 text_pole"></select> |
| @@ -3431,21 +3432,22 @@ | |||
| 3431 | </div> | 3432 | </div> |
| 3432 | </div> | 3433 | </div> |
| 3433 | <div id="SystemPromptColumn" class="flex-container flexNoGap flexFlowColumn flex1"> | 3434 | <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> | ||
| 3434 | <div id="SystemPromptBlock"> | 3449 | <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> | ||
| 3449 | 3451 | ||
| 3450 | <div class="flex-container" title="Select your current System Prompt" data-i18n="[title]Select your current System Prompt"> | 3452 | <div class="flex-container" title="Select your current System Prompt" data-i18n="[title]Select your current System Prompt"> |
| 3451 | <select id="sysprompt_select" data-preset-manager-for="sysprompt" class="flex1 text_pole"></select> | 3453 | <select id="sysprompt_select" data-preset-manager-for="sysprompt" class="flex1 text_pole"></select> |
| @@ -5939,9 +5941,9 @@ | |||
| 5939 | </div> | 5941 | </div> |
| 5940 | <div class="mes_bias"></div> | 5942 | <div class="mes_bias"></div> |
| 5941 | </div> | 5943 | </div> |
| 5942 | <div class="swipe_right fa-solid fa-chevron-right" style="display: none;"> | 5944 | <div class="swipe_right fa-solid fa-chevron-right" style="display: none;"> |
| 5943 | <div class="swipes-counter"></div> | 5945 | <div class="swipes-counter"></div> |
| 5944 | </div> | 5946 | </div> |
| 5945 | </div> | 5947 | </div> |
| 5946 | </div> | 5948 | </div> |
| 5947 | <div id="group_avatars_template" class="template_element"> | 5949 | <div id="group_avatars_template" class="template_element"> |
| @@ -5428,6 +5428,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc | |||
| 5428 | getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>')); | 5428 | getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>')); |
| 5429 | } | 5429 | } |
| 5430 | const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; | 5430 | const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; |
| 5431 | const isNotEmpty = (str) => str && str.trim() !== ''; | ||
| 5431 | if (isInstruct && power_user.instruct.stop_sequence) { | 5432 | if (isInstruct && power_user.instruct.stop_sequence) { |
| 5432 | if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) { | 5433 | if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) { |
| 5433 | getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.stop_sequence)); | 5434 | getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.stop_sequence)); |
| @@ -5435,7 +5436,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc | |||
| 5435 | } | 5436 | } |
| 5436 | // Hana: Only use the first sequence (should be <|model|>) | 5437 | // Hana: Only use the first sequence (should be <|model|>) |
| 5437 | // of the prompt before <|user|> (as KoboldAI Lite does it). | 5438 | // of the prompt before <|user|> (as KoboldAI Lite does it). |
| 5438 | if (isInstruct && power_user.instruct.input_sequence) { | 5439 | if (isInstruct && isNotEmpty(power_user.instruct.input_sequence)) { |
| 5439 | if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) { | 5440 | if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) { |
| 5440 | getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence)); | 5441 | getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence)); |
| 5441 | } | 5442 | } |
| @@ -8477,12 +8478,22 @@ const CONNECT_API_MAP = { | |||
| 8477 | selected: 'novel', | 8478 | selected: 'novel', |
| 8478 | button: '#api_button_novel', | 8479 | button: '#api_button_novel', |
| 8479 | }, | 8480 | }, |
| 8481 | 'koboldcpp': { | ||
| 8482 | selected: 'textgenerationwebui', | ||
| 8483 | button: '#api_button_textgenerationwebui', | ||
| 8484 | type: textgen_types.KOBOLDCPP, | ||
| 8485 | }, | ||
| 8480 | // KoboldCpp alias | 8486 | // KoboldCpp alias |
| 8481 | 'kcpp': { | 8487 | 'kcpp': { |
| 8482 | selected: 'textgenerationwebui', | 8488 | selected: 'textgenerationwebui', |
| 8483 | button: '#api_button_textgenerationwebui', | 8489 | button: '#api_button_textgenerationwebui', |
| 8484 | type: textgen_types.KOBOLDCPP, | 8490 | type: textgen_types.KOBOLDCPP, |
| 8485 | }, | 8491 | }, |
| 8492 | 'openai': { | ||
| 8493 | selected: 'openai', | ||
| 8494 | button: '#api_button_openai', | ||
| 8495 | source: chat_completion_sources.OPENAI, | ||
| 8496 | }, | ||
| 8486 | // OpenAI alias | 8497 | // OpenAI alias |
| 8487 | 'oai': { | 8498 | 'oai': { |
| 8488 | selected: 'openai', | 8499 | selected: 'openai', |
| @@ -56,22 +56,25 @@ let counterNonce = Date.now(); | |||
| 56 | 56 | ||
| 57 | const observerConfig = { childList: true, subtree: true }; | 57 | const observerConfig = { childList: true, subtree: true }; |
| 58 | const countTokensDebounced = debounce(RA_CountCharTokens, debounce_timeout.relaxed); | 58 | const 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); | ||
| 59 | 61 | ||
| 60 | const observer = new MutationObserver(function (mutations) { | 62 | const observer = new MutationObserver(function (mutations) { |
| 61 | mutations.forEach(function (mutation) { | 63 | mutations.forEach(function (mutation) { |
| 64 | if (!(mutation.target instanceof HTMLElement)) { | ||
| 65 | return; | ||
| 66 | } | ||
| 62 | if (mutation.target.classList.contains('online_status_text')) { | 67 | if (mutation.target.classList.contains('online_status_text')) { |
| 63 | RA_checkOnlineStatus(); | 68 | checkStatusDebounced(); |
| 64 | } else if (mutation.target.parentNode === SelectedCharacterTab) { | 69 | } else if (mutation.target.parentNode === SelectedCharacterTab) { |
| 65 | setTimeout(RA_CountCharTokens, 200); | 70 | countTokensShortDebounced(); |
| 66 | } else if (mutation.target.classList.contains('mes_text')) { | 71 | } 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 | } | ||
| 75 | } | 78 | } |
| 76 | } | 79 | } |
| 77 | }); | 80 | }); |
| @@ -159,8 +162,8 @@ export function shouldSendOnEnter() { | |||
| 159 | export function humanizedDateTime() { | 162 | export function humanizedDateTime() { |
| 160 | const now = new Date(Date.now()); | 163 | const now = new Date(Date.now()); |
| 161 | const dt = { | 164 | const dt = { |
| 162 | year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), | 165 | year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), |
| 163 | hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), | 166 | hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), |
| 164 | }; | 167 | }; |
| 165 | for (const key in dt) { | 168 | for (const key in dt) { |
| 166 | dt[key] = dt[key].toString().padStart(2, '0'); | 169 | dt[key] = dt[key].toString().padStart(2, '0'); |
| @@ -725,9 +728,7 @@ export function addSafariPatch() { | |||
| 725 | 728 | ||
| 726 | export function initRossMods() { | 729 | export function initRossMods() { |
| 727 | // initial status check | 730 | // initial status check |
| 728 | setTimeout(() => { | 731 | checkStatusDebounced(); |
| 729 | RA_checkOnlineStatus(); | ||
| 730 | }, 100); | ||
| 731 | 732 | ||
| 732 | if (power_user.auto_load_chat) { | 733 | if (power_user.auto_load_chat) { |
| 733 | RA_autoloadchat(); | 734 | RA_autoloadchat(); |
| @@ -752,7 +753,7 @@ export function initRossMods() { | |||
| 752 | setTimeout(() => RA_autoconnect(PrevAPI), 100); | 753 | setTimeout(() => RA_autoconnect(PrevAPI), 100); |
| 753 | }); | 754 | }); |
| 754 | 755 | ||
| 755 | $('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); }); | 756 | $('#api_button').on('click', () => checkStatusDebounced()); |
| 756 | 757 | ||
| 757 | //toggle pin class when lock toggle clicked | 758 | //toggle pin class when lock toggle clicked |
| 758 | $(RPanelPin).on('click', function () { | 759 | $(RPanelPin).on('click', function () { |
| @@ -2598,8 +2598,13 @@ async function askCharacter(args, text) { | |||
| 2598 | return; | 2598 | return; |
| 2599 | } | 2599 | } |
| 2600 | 2600 | ||
| 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 | } | ||
| 2603 | 2608 | ||
| 2604 | // Only force the new avatar if the character name is the same | 2609 | // Only force the new avatar if the character name is the same |
| 2605 | // This skips if an error was fired | 2610 | // This skips if an error was fired |
| @@ -978,15 +978,15 @@ body .panelControlBar { | |||
| 978 | justify-content: center; | 978 | justify-content: center; |
| 979 | z-index: 9999; | 979 | z-index: 9999; |
| 980 | grid-row-start: 2; | 980 | grid-row-start: 2; |
| 981 | grid-column-start: 4; | ||
| 982 | flex-flow: column; | ||
| 983 | font-size: 30px; | 981 | font-size: 30px; |
| 984 | cursor: pointer; | 982 | cursor: pointer; |
| 985 | align-self: center; | 983 | align-self: center; |
| 986 | position: absolute; | 984 | position: absolute; |
| 987 | bottom: 15px; | 985 | bottom: 15px; |
| 986 | flex-flow: column; | ||
| 988 | } | 987 | } |
| 989 | 988 | ||
| 989 | |||
| 990 | .swipes-counter { | 990 | .swipes-counter { |
| 991 | color: var(--SmartThemeBodyColor); | 991 | color: var(--SmartThemeBodyColor); |
| 992 | font-size: 12px; | 992 | font-size: 12px; |
| @@ -994,6 +994,9 @@ body .panelControlBar { | |||
| 994 | font-family: var(--mainFontFamily); | 994 | font-family: var(--mainFontFamily); |
| 995 | font-weight: 400; | 995 | font-weight: 400; |
| 996 | align-self: center; | 996 | align-self: center; |
| 997 | min-width: 40px; | ||
| 998 | display: flex; | ||
| 999 | justify-content: center; | ||
| 997 | } | 1000 | } |
| 998 | 1001 | ||
| 999 | .swipe_left { | 1002 | .swipe_left { |
| @@ -1003,6 +1006,7 @@ body .panelControlBar { | |||
| 1003 | 1006 | ||
| 1004 | .swipe_right { | 1007 | .swipe_right { |
| 1005 | right: 5px; | 1008 | right: 5px; |
| 1009 | align-self:end; | ||
| 1006 | } | 1010 | } |
| 1007 | 1011 | ||
| 1008 | .ui-settings { | 1012 | .ui-settings { |
| @@ -2634,6 +2638,11 @@ select option:not(:checked) { | |||
| 2634 | color: var(--active) !important; | 2638 | color: var(--active) !important; |
| 2635 | } | 2639 | } |
| 2636 | 2640 | ||
| 2641 | #instruct_enabled_label .menu_button:not(.toggleEnabled), | ||
| 2642 | #sysprompt_enabled_label .menu_button:not(.toggleEnabled) { | ||
| 2643 | color: Red; | ||
| 2644 | } | ||
| 2645 | |||
| 2637 | .displayBlock { | 2646 | .displayBlock { |
| 2638 | display: block !important; | 2647 | display: block !important; |
| 2639 | } | 2648 | } |