Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging

da161b962863f9eccec32d1c426804a241af3a22

RossAscends <124905043+RossAscends@users.noreply.github.com>

3 files changed, +24 -8Showing whitespace changes
public/script.js+10 -0
@@ -8476,12 +8476,22 @@ const CONNECT_API_MAP = {
84768476 selected: 'novel',
84778477 button: '#api_button_novel',
84788478 },
8479+ 'koboldcpp': {
8480+ selected: 'textgenerationwebui',
8481+ button: '#api_button_textgenerationwebui',
8482+ type: textgen_types.KOBOLDCPP,
8483+ },
84798484 // KoboldCpp alias
84808485 'kcpp': {
84818486 selected: 'textgenerationwebui',
84828487 button: '#api_button_textgenerationwebui',
84838488 type: textgen_types.KOBOLDCPP,
84848489 },
8490+ 'openai': {
8491+ selected: 'openai',
8492+ button: '#api_button_openai',
8493+ source: chat_completion_sources.OPENAI,
8494+ },
84858495 // OpenAI alias
84868496 'oai': {
84878497 selected: 'openai',
public/scripts/RossAscends-mods.js+9 -8
@@ -56,15 +56,19 @@ 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) {
6872 for (const element of mutation.target.getElementsByTagName('math')) {
6973 element.childNodes.forEach(function (child) {
7074 if (child.nodeType === Node.TEXT_NODE) {
@@ -73,7 +77,6 @@ const observer = new MutationObserver(function (mutations) {
7377 });
7478 }
7579 }
76- }
7780 });
7881});
7982
@@ -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+5 -0
@@ -2530,8 +2530,13 @@ async function askCharacter(args, text) {
25302530 return;
25312531 }
25322532
2533+ if (prevChId !== undefined) {
25332534 setCharacterId(prevChId);
25342535 setCharacterName(characters[prevChId].name);
2536+ } else {
2537+ setCharacterId(undefined);
2538+ setCharacterName(neutralCharacterName);
2539+ }
25352540
25362541 // Only force the new avatar if the character name is the same
25372542 // This skips if an error was fired