Merge branch 'staging' into char-find-and-sendas-extended
| @@ -3248,7 +3248,6 @@ | ||
| 3248 | 3248 | </div> |
| 3249 | 3249 | </div> |
| 3250 | 3250 | <div id="InstructSettingsColumn" class="flex-container flexNoGap flexFlowColumn flex1"> |
| 3251 | - <div id="instructSettingsBlock"> | |
| 3252 | 3251 | <h4 class="standoutHeader title_restorable justifySpaceBetween"> |
| 3253 | 3252 | <div class="flex-container"> |
| 3254 | 3253 | <span data-i18n="Instruct Template">Instruct Template</span> |
| @@ -3261,12 +3260,14 @@ | ||
| 3261 | 3260 | <input id="instruct_bind_to_context" type="checkbox" style="display:none;" /> |
| 3262 | 3261 | <small><i class="fa-solid fa-link menu_button margin0"></i></small> |
| 3263 | 3262 | </label> |
| 3264 | 3263 | <label id="instruct_enabled_label"for="instruct_enabled" class="checkbox_label flex1" title="Enable Instruct Mode" data-i18n="[title]instruct_enabled"> |
| 3265 | 3264 | <input id="instruct_enabled" type="checkbox" style="display:none;" /> |
| 3266 | 3265 | <small><i class="fa-solid fa-power-off menu_button margin0"></i></small> |
| 3267 | 3266 | </label> |
| 3268 | 3267 | </div> |
| 3269 | 3268 | </h4> |
| 3269 | + <div id="instructSettingsBlock"> | |
| 3270 | + | |
| 3270 | 3271 | |
| 3271 | 3272 | <div class="flex-container" title="Select your current Instruct Template" data-i18n="[title]Select your current Instruct Template"> |
| 3272 | 3273 | <select id="instruct_presets" data-preset-manager-for="instruct" class="flex1 text_pole"></select> |
| @@ -3431,7 +3432,6 @@ | ||
| 3431 | 3432 | </div> |
| 3432 | 3433 | </div> |
| 3433 | 3434 | <div id="SystemPromptColumn" class="flex-container flexNoGap flexFlowColumn flex1"> |
| 3434 | - <div id="SystemPromptBlock"> | |
| 3435 | 3435 | <h4 class="standoutHeader title_restorable justifySpaceBetween"> |
| 3436 | 3436 | <div class="flex-container"> |
| 3437 | 3437 | <span data-i18n="System Prompt">System Prompt</span> |
| @@ -3440,12 +3440,14 @@ | ||
| 3440 | 3440 | </a> |
| 3441 | 3441 | </div> |
| 3442 | 3442 | <div class="flex-container"> |
| 3443 | 3443 | <label id="sysprompt_enabled_label" for="sysprompt_enabled" class="checkbox_label flex1" title="Enable System Prompt" data-i18n="[title]sysprompt_enabled"> |
| 3444 | 3444 | <input id="sysprompt_enabled" type="checkbox" style="display:none;" /> |
| 3445 | 3445 | <small><i class="fa-solid fa-power-off menu_button margin0"></i></small> |
| 3446 | 3446 | </label> |
| 3447 | 3447 | </div> |
| 3448 | 3448 | </h4> |
| 3449 | + <div id="SystemPromptBlock"> | |
| 3450 | + | |
| 3449 | 3451 | |
| 3450 | 3452 | <div class="flex-container" title="Select your current System Prompt" data-i18n="[title]Select your current System Prompt"> |
| 3451 | 3453 | <select id="sysprompt_select" data-preset-manager-for="sysprompt" class="flex1 text_pole"></select> |
| @@ -5428,6 +5428,7 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc | ||
| 5428 | 5428 | getMessage = getMessage.substring(0, getMessage.indexOf('<|endoftext|>')); |
| 5429 | 5429 | } |
| 5430 | 5430 | const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; |
| 5431 | + const isNotEmpty = (str) => str && str.trim() !== ''; | |
| 5431 | 5432 | if (isInstruct && power_user.instruct.stop_sequence) { |
| 5432 | 5433 | if (getMessage.indexOf(power_user.instruct.stop_sequence) != -1) { |
| 5433 | 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 | 5437 | // Hana: Only use the first sequence (should be <|model|>) |
| 5437 | 5438 | // of the prompt before <|user|> (as KoboldAI Lite does it). |
| 5438 | 5439 | if (isInstruct && isNotEmpty(power_user.instruct.input_sequence)) { |
| 5439 | 5440 | if (getMessage.indexOf(power_user.instruct.input_sequence) != -1) { |
| 5440 | 5441 | getMessage = getMessage.substring(0, getMessage.indexOf(power_user.instruct.input_sequence)); |
| 5441 | 5442 | } |
| @@ -8477,12 +8478,22 @@ const CONNECT_API_MAP = { | ||
| 8477 | 8478 | selected: 'novel', |
| 8478 | 8479 | button: '#api_button_novel', |
| 8479 | 8480 | }, |
| 8481 | + 'koboldcpp': { | |
| 8482 | + selected: 'textgenerationwebui', | |
| 8483 | + button: '#api_button_textgenerationwebui', | |
| 8484 | + type: textgen_types.KOBOLDCPP, | |
| 8485 | + }, | |
| 8480 | 8486 | // KoboldCpp alias |
| 8481 | 8487 | 'kcpp': { |
| 8482 | 8488 | selected: 'textgenerationwebui', |
| 8483 | 8489 | button: '#api_button_textgenerationwebui', |
| 8484 | 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 | 8497 | // OpenAI alias |
| 8487 | 8498 | 'oai': { |
| 8488 | 8499 | selected: 'openai', |
| @@ -56,15 +56,19 @@ let counterNonce = Date.now(); | ||
| 56 | 56 | |
| 57 | 57 | const observerConfig = { childList: true, subtree: true }; |
| 58 | 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 | 62 | const observer = new MutationObserver(function (mutations) { |
| 61 | 63 | mutations.forEach(function (mutation) { |
| 64 | + if (!(mutation.target instanceof HTMLElement)) { | |
| 65 | + return; | |
| 66 | + } | |
| 62 | 67 | if (mutation.target.classList.contains('online_status_text')) { |
| 63 | 68 | RA_checkOnlineStatuscheckStatusDebounced(); |
| 64 | 69 | } else if (mutation.target.parentNode === SelectedCharacterTab) { |
| 65 | 70 | setTimeoutcountTokensShortDebounced(RA_CountCharTokens, 200); |
| 66 | 71 | } else if (mutation.target.classList.contains('mes_text')) { |
| 67 | - if (mutation.target instanceof HTMLElement) { | |
| 68 | 72 | for (const element of mutation.target.getElementsByTagName('math')) { |
| 69 | 73 | element.childNodes.forEach(function (child) { |
| 70 | 74 | if (child.nodeType === Node.TEXT_NODE) { |
| @@ -73,7 +77,6 @@ const observer = new MutationObserver(function (mutations) { | ||
| 73 | 77 | }); |
| 74 | 78 | } |
| 75 | 79 | } |
| 76 | - } | |
| 77 | 80 | }); |
| 78 | 81 | }); |
| 79 | 82 | |
| @@ -725,9 +728,7 @@ export function addSafariPatch() { | ||
| 725 | 728 | |
| 726 | 729 | export function initRossMods() { |
| 727 | 730 | // initial status check |
| 728 | - setTimeout(() => { | |
| 731 | + checkStatusDebounced(); | |
| 729 | - RA_checkOnlineStatus(); | |
| 730 | - }, 100); | |
| 731 | 732 | |
| 732 | 733 | if (power_user.auto_load_chat) { |
| 733 | 734 | RA_autoloadchat(); |
| @@ -752,7 +753,7 @@ export function initRossMods() { | ||
| 752 | 753 | setTimeout(() => RA_autoconnect(PrevAPI), 100); |
| 753 | 754 | }); |
| 754 | 755 | |
| 755 | 756 | $('#api_button').clickon(function'click', () {=> setTimeoutcheckStatusDebounced(RA_checkOnlineStatus, 100); }); |
| 756 | 757 | |
| 757 | 758 | //toggle pin class when lock toggle clicked |
| 758 | 759 | $(RPanelPin).on('click', function () { |
| @@ -2598,8 +2598,13 @@ async function askCharacter(args, text) { | ||
| 2598 | 2598 | return; |
| 2599 | 2599 | } |
| 2600 | 2600 | |
| 2601 | + if (prevChId !== undefined) { | |
| 2601 | 2602 | setCharacterId(prevChId); |
| 2602 | 2603 | setCharacterName(characters[prevChId].name); |
| 2604 | + } else { | |
| 2605 | + setCharacterId(undefined); | |
| 2606 | + setCharacterName(neutralCharacterName); | |
| 2607 | + } | |
| 2603 | 2608 | |
| 2604 | 2609 | // Only force the new avatar if the character name is the same |
| 2605 | 2610 | // This skips if an error was fired |
| @@ -978,15 +978,15 @@ body .panelControlBar { | ||
| 978 | 978 | justify-content: center; |
| 979 | 979 | z-index: 9999; |
| 980 | 980 | grid-row-start: 2; |
| 981 | - grid-column-start: 4; | |
| 982 | - flex-flow: column; | |
| 983 | 981 | font-size: 30px; |
| 984 | 982 | cursor: pointer; |
| 985 | 983 | align-self: center; |
| 986 | 984 | position: absolute; |
| 987 | 985 | bottom: 15px; |
| 986 | +flex-flow: column; | |
| 988 | 987 | } |
| 989 | 988 | |
| 989 | + | |
| 990 | 990 | .swipes-counter { |
| 991 | 991 | color: var(--SmartThemeBodyColor); |
| 992 | 992 | font-size: 12px; |
| @@ -994,6 +994,9 @@ body .panelControlBar { | ||
| 994 | 994 | font-family: var(--mainFontFamily); |
| 995 | 995 | font-weight: 400; |
| 996 | 996 | align-self: center; |
| 997 | + min-width: 40px; | |
| 998 | + display: flex; | |
| 999 | + justify-content: center; | |
| 997 | 1000 | } |
| 998 | 1001 | |
| 999 | 1002 | .swipe_left { |
| @@ -1003,6 +1006,7 @@ body .panelControlBar { | ||
| 1003 | 1006 | |
| 1004 | 1007 | .swipe_right { |
| 1005 | 1008 | right: 5px; |
| 1009 | + align-self:end; | |
| 1006 | 1010 | } |
| 1007 | 1011 | |
| 1008 | 1012 | .ui-settings { |
| @@ -2634,6 +2638,11 @@ select option:not(:checked) { | ||
| 2634 | 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 | 2646 | .displayBlock { |
| 2638 | 2647 | display: block !important; |
| 2639 | 2648 | } |