Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging
| @@ -8476,12 +8476,22 @@ const CONNECT_API_MAP = { | ||
| 8476 | 8476 | selected: 'novel', |
| 8477 | 8477 | button: '#api_button_novel', |
| 8478 | 8478 | }, |
| 8479 | + 'koboldcpp': { | |
| 8480 | + selected: 'textgenerationwebui', | |
| 8481 | + button: '#api_button_textgenerationwebui', | |
| 8482 | + type: textgen_types.KOBOLDCPP, | |
| 8483 | + }, | |
| 8479 | 8484 | // KoboldCpp alias |
| 8480 | 8485 | 'kcpp': { |
| 8481 | 8486 | selected: 'textgenerationwebui', |
| 8482 | 8487 | button: '#api_button_textgenerationwebui', |
| 8483 | 8488 | type: textgen_types.KOBOLDCPP, |
| 8484 | 8489 | }, |
| 8490 | + 'openai': { | |
| 8491 | + selected: 'openai', | |
| 8492 | + button: '#api_button_openai', | |
| 8493 | + source: chat_completion_sources.OPENAI, | |
| 8494 | + }, | |
| 8485 | 8495 | // OpenAI alias |
| 8486 | 8496 | 'oai': { |
| 8487 | 8497 | selected: 'openai', |
| @@ -56,22 +56,25 @@ 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) { | |
| 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 | 162 | export function humanizedDateTime() { |
| 160 | 163 | const now = new Date(Date.now()); |
| 161 | 164 | const dt = { |
| 162 | 165 | year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), |
| 163 | 166 | hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), |
| 164 | 167 | }; |
| 165 | 168 | for (const key in dt) { |
| 166 | 169 | dt[key] = dt[key].toString().padStart(2, '0'); |
| @@ -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 () { |
| @@ -2530,8 +2530,13 @@ async function askCharacter(args, text) { | ||
| 2530 | 2530 | return; |
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | - setCharacterId(prevChId); | |
| 2533 | + if (prevChId !== undefined) { | |
| 2534 | - setCharacterName(characters[prevChId].name); | |
| 2534 | + setCharacterId(prevChId); | |
| 2535 | + setCharacterName(characters[prevChId].name); | |
| 2536 | + } else { | |
| 2537 | + setCharacterId(undefined); | |
| 2538 | + setCharacterName(neutralCharacterName); | |
| 2539 | + } | |
| 2535 | 2540 | |
| 2536 | 2541 | // Only force the new avatar if the character name is the same |
| 2537 | 2542 | // This skips if an error was fired |