Enable no-unused-vars lint

This is the big one. Probably needs thorough review to make sure I
didn't accidentally remove any setInterval or fetch calls.
This commit is contained in:
valadaptive
2023-12-02 11:25:30 -05:00
parent 39bbef376f
commit 518bb58d5a
29 changed files with 25 additions and 113 deletions

View File

@ -50,7 +50,7 @@ module.exports = {
// Most, if not all, of these rules should eventually be enabled and the code changed. They're disabled so that // Most, if not all, of these rules should eventually be enabled and the code changed. They're disabled so that
// linting passes. // linting passes.
rules: { rules: {
'no-unused-vars': 'off', 'no-unused-vars': ['error', {args: 'none'}],
'no-control-regex': 'off', 'no-control-regex': 'off',
'no-async-promise-executor': 'off', 'no-async-promise-executor': 'off',
'no-inner-declarations': 'off', 'no-inner-declarations': 'off',

View File

@ -62,7 +62,6 @@ import {
renameGroupChat, renameGroupChat,
importGroupChat, importGroupChat,
getGroupBlock, getGroupBlock,
getGroupChatNames,
getGroupCharacterCards, getGroupCharacterCards,
getGroupDepthPrompts, getGroupDepthPrompts,
} from "./scripts/group-chats.js"; } from "./scripts/group-chats.js";
@ -130,8 +129,6 @@ import {
import { import {
debounce, debounce,
delay, delay,
restoreCaretPosition,
saveCaretPosition,
trimToEndSentence, trimToEndSentence,
countOccurrences, countOccurrences,
isOdd, isOdd,
@ -193,7 +190,7 @@ import { getFriendlyTokenizerName, getTokenCount, getTokenizerModel, initTokeniz
import { createPersona, initPersonas, selectCurrentPersona, setPersonaDescription } from "./scripts/personas.js"; import { createPersona, initPersonas, selectCurrentPersona, setPersonaDescription } from "./scripts/personas.js";
import { getBackgrounds, initBackgrounds } from "./scripts/backgrounds.js"; import { getBackgrounds, initBackgrounds } from "./scripts/backgrounds.js";
import { hideLoader, showLoader } from "./scripts/loader.js"; import { hideLoader, showLoader } from "./scripts/loader.js";
import { CharacterContextMenu, BulkEditOverlay } from "./scripts/BulkEditOverlay.js"; import { BulkEditOverlay } from "./scripts/BulkEditOverlay.js";
import { loadMancerModels } from "./scripts/mancer-settings.js"; import { loadMancerModels } from "./scripts/mancer-settings.js";
import { getFileAttachment, hasPendingFileAttachment, populateFileAttachment } from "./scripts/chats.js"; import { getFileAttachment, hasPendingFileAttachment, populateFileAttachment } from "./scripts/chats.js";
import { replaceVariableMacros } from "./scripts/variables.js"; import { replaceVariableMacros } from "./scripts/variables.js";
@ -327,7 +324,6 @@ eventSource.on(event_types.MESSAGE_SENT, processExtensionHelpers);
eventSource.on(event_types.CHAT_CHANGED, processChatSlashCommands); eventSource.on(event_types.CHAT_CHANGED, processChatSlashCommands);
const characterGroupOverlay = new BulkEditOverlay(); const characterGroupOverlay = new BulkEditOverlay();
const characterContextMenu = new CharacterContextMenu(characterGroupOverlay);
eventSource.on(event_types.CHARACTER_PAGE_LOADED, characterGroupOverlay.onPageLoad); eventSource.on(event_types.CHARACTER_PAGE_LOADED, characterGroupOverlay.onPageLoad);
hljs.addPlugin({ "before:highlightElement": ({ el }) => { el.textContent = el.innerText } }); hljs.addPlugin({ "before:highlightElement": ({ el }) => { el.textContent = el.innerText } });
@ -666,7 +662,6 @@ let is_send_press = false; //Send generation
let this_del_mes = -1; let this_del_mes = -1;
//message editing and chat scroll position persistence //message editing and chat scroll position persistence
var this_edit_mes_text = "";
var this_edit_mes_chname = ""; var this_edit_mes_chname = "";
var this_edit_mes_id; var this_edit_mes_id;
var scroll_holder = 0; var scroll_holder = 0;
@ -2224,7 +2219,6 @@ function getStoppingStrings(isImpersonate, isContinue) {
*/ */
export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, quietImage = null) { export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, quietImage = null) {
console.log('got into genQuietPrompt') console.log('got into genQuietPrompt')
const skipWIANvalue = skipWIAN
return await new Promise( return await new Promise(
async function promptPromise(resolve, reject) { async function promptPromise(resolve, reject) {
if (quietToLoud === true) { if (quietToLoud === true) {
@ -3855,7 +3849,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
//prevent custom depth WI entries (which have unique random key names) from duplicating //prevent custom depth WI entries (which have unique random key names) from duplicating
for (let key in extension_prompts) { for (let key in extension_prompts) {
if (key.includes('customDepthWI')) { if (key.includes('customDepthWI')) {
let keyname = extension_prompts[key]
delete extension_prompts[key]; delete extension_prompts[key];
} }
} }
@ -4108,6 +4101,8 @@ function addChatsSeparator(mesSendString) {
} }
} }
// There's a TODO related to zero-depth anchors; not removing this function until that's resolved
// eslint-disable-next-line no-unused-vars
function appendZeroDepthAnchor(force_name2, zeroDepthAnchor, finalPrompt) { function appendZeroDepthAnchor(force_name2, zeroDepthAnchor, finalPrompt) {
const trimBothEnds = !force_name2; const trimBothEnds = !force_name2;
let trimmedPrompt = (trimBothEnds ? zeroDepthAnchor.trim() : zeroDepthAnchor.trimEnd()); let trimmedPrompt = (trimBothEnds ? zeroDepthAnchor.trim() : zeroDepthAnchor.trimEnd());
@ -6754,7 +6749,6 @@ function addAlternateGreeting(template, greeting, index, getArray) {
async function createOrEditCharacter(e) { async function createOrEditCharacter(e) {
$("#rm_info_avatar").html(""); $("#rm_info_avatar").html("");
let save_name = create_save.name;
var formData = new FormData($("#form_create").get(0)); var formData = new FormData($("#form_create").get(0));
formData.set('fav', fav_ch_checked); formData.set('fav', fav_ch_checked);
if ($("#form_create").attr("actiontype") == "createcharacter") { if ($("#form_create").attr("actiontype") == "createcharacter") {
@ -7615,28 +7609,22 @@ jQuery(async function () {
$(document).on('click', '.api_loading', cancelStatusCheck); $(document).on('click', '.api_loading', cancelStatusCheck);
//////////INPUT BAR FOCUS-KEEPING LOGIC///////////// //////////INPUT BAR FOCUS-KEEPING LOGIC/////////////
let S_TAFocused = false;
let S_TAPreviouslyFocused = false; let S_TAPreviouslyFocused = false;
$('#send_textarea').on('focusin focus click', () => { $('#send_textarea').on('focusin focus click', () => {
S_TAFocused = true;
S_TAPreviouslyFocused = true; S_TAPreviouslyFocused = true;
}); });
$('#send_textarea').on('focusout blur', () => S_TAFocused = false);
$('#options_button, #send_but, #option_regenerate, #option_continue, #mes_continue').on('click', () => { $('#options_button, #send_but, #option_regenerate, #option_continue, #mes_continue').on('click', () => {
if (S_TAPreviouslyFocused) { if (S_TAPreviouslyFocused) {
$('#send_textarea').focus(); $('#send_textarea').focus();
S_TAFocused = true;
} }
}); });
$(document).click(event => { $(document).click(event => {
if ($(':focus').attr('id') !== 'send_textarea') { if ($(':focus').attr('id') !== 'send_textarea') {
var validIDs = ["options_button", "send_but", "mes_continue", "send_textarea", "option_regenerate", "option_continue"]; var validIDs = ["options_button", "send_but", "mes_continue", "send_textarea", "option_regenerate", "option_continue"];
if (!validIDs.includes($(event.target).attr('id'))) { if (!validIDs.includes($(event.target).attr('id'))) {
S_TAFocused = false;
S_TAPreviouslyFocused = false; S_TAPreviouslyFocused = false;
} }
} else { } else {
S_TAFocused = true;
S_TAPreviouslyFocused = true; S_TAPreviouslyFocused = true;
} }
}); });

View File

@ -1615,7 +1615,6 @@ PromptManagerModule.prototype.import = function (importData) {
this.setPrompts(prompts); this.setPrompts(prompts);
this.log('Prompt import succeeded'); this.log('Prompt import succeeded');
let promptOrder = [];
if ('global' === this.configuration.promptOrder.strategy) { if ('global' === this.configuration.promptOrder.strategy) {
const promptOrder = this.getPromptOrderForCharacter({ id: this.configuration.promptOrder.dummyId }); const promptOrder = this.getPromptOrderForCharacter({ id: this.configuration.promptOrder.dummyId });
Object.assign(promptOrder, importData.data.prompt_order); Object.assign(promptOrder, importData.data.prompt_order);

View File

@ -25,13 +25,13 @@ import {
send_on_enter_options, send_on_enter_options,
} from "./power-user.js"; } from "./power-user.js";
import { LoadLocal, SaveLocal, CheckLocal, LoadLocalBool } from "./f-localStorage.js"; import { LoadLocal, SaveLocal, LoadLocalBool } from "./f-localStorage.js";
import { selected_group, is_group_generating, getGroupAvatar, groups, openGroupById } from "./group-chats.js"; import { selected_group, is_group_generating, getGroupAvatar, groups, openGroupById } from "./group-chats.js";
import { import {
SECRET_KEYS, SECRET_KEYS,
secret_state, secret_state,
} from "./secrets.js"; } from "./secrets.js";
import { debounce, delay, getStringHash, isValidUrl, waitUntilCondition } from "./utils.js"; import { debounce, delay, getStringHash, isValidUrl } from "./utils.js";
import { chat_completion_sources, oai_settings } from "./openai.js"; import { chat_completion_sources, oai_settings } from "./openai.js";
import { getTokenCount } from "./tokenizers.js"; import { getTokenCount } from "./tokenizers.js";
import { isMancer } from "./textgen-settings.js"; import { isMancer } from "./textgen-settings.js";
@ -51,7 +51,6 @@ var AutoLoadChatCheckbox = document.getElementById("auto-load-chat-checkbox");
var connection_made = false; var connection_made = false;
var retry_delay = 500; var retry_delay = 500;
var RA_AC_retries = 1;
const observerConfig = { childList: true, subtree: true }; const observerConfig = { childList: true, subtree: true };
const countTokensDebounced = debounce(RA_CountCharTokens, 1000); const countTokensDebounced = debounce(RA_CountCharTokens, 1000);
@ -167,8 +166,6 @@ export function humanizedDateTime() {
(baseDate.getMinutes() < 10 ? "0" : "") + baseDate.getMinutes(); (baseDate.getMinutes() < 10 ? "0" : "") + baseDate.getMinutes();
let humanSecond = let humanSecond =
(baseDate.getSeconds() < 10 ? "0" : "") + baseDate.getSeconds(); (baseDate.getSeconds() < 10 ? "0" : "") + baseDate.getSeconds();
let humanMillisecond =
(baseDate.getMilliseconds() < 10 ? "0" : "") + baseDate.getMilliseconds();
let HumanizedDateTime = let HumanizedDateTime =
humanYear + "-" + humanMonth + "-" + humanDate + "@" + humanHour + "h" + humanMinute + "m" + humanSecond + "s"; humanYear + "-" + humanMonth + "-" + humanDate + "@" + humanHour + "h" + humanMinute + "m" + humanSecond + "s";
return HumanizedDateTime; return HumanizedDateTime;
@ -375,7 +372,6 @@ function RA_checkOnlineStatus() {
$("#API-status-top").addClass("fa-plug"); $("#API-status-top").addClass("fa-plug");
connection_made = true; connection_made = true;
retry_delay = 100; retry_delay = 100;
RA_AC_retries = 1;
if (!is_send_press && !(selected_group && is_group_generating)) { if (!is_send_press && !(selected_group && is_group_generating)) {
$("#send_but").removeClass("displayNone"); //on connect, send button shows $("#send_but").removeClass("displayNone"); //on connect, send button shows
@ -427,7 +423,6 @@ function RA_autoconnect(PrevApi) {
} }
if (!connection_made) { if (!connection_made) {
RA_AC_retries++;
retry_delay = Math.min(retry_delay * 2, 30000); // double retry delay up to to 30 secs retry_delay = Math.min(retry_delay * 2, 30000); // double retry delay up to to 30 secs
// console.log('connection attempts: ' + RA_AC_retries + ' delay: ' + (retry_delay / 1000) + 's'); // console.log('connection attempts: ' + RA_AC_retries + ' delay: ' + (retry_delay / 1000) + 's');
// setTimeout(RA_autoconnect, retry_delay); // setTimeout(RA_autoconnect, retry_delay);
@ -486,7 +481,7 @@ export function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
var height, width, top, left, right, bottom, var height, width, top, left, right, bottom,
maxX, maxY, winHeight, winWidth, maxX, maxY, winHeight, winWidth,
topbar, topbarWidth, topBarFirstX, topBarLastX, topBarLastY, sheldWidth; topbar, topBarFirstX, topBarLastY;
var elmntName = elmnt.attr('id'); var elmntName = elmnt.attr('id');
console.debug(`dragElement called for ${elmntName}`); console.debug(`dragElement called for ${elmntName}`);
@ -530,13 +525,10 @@ export function dragElement(elmnt) {
maxY = parseInt(height + top); maxY = parseInt(height + top);
winWidth = window.innerWidth; winWidth = window.innerWidth;
winHeight = window.innerHeight; winHeight = window.innerHeight;
sheldWidth = parseInt($('html').css('--sheldWidth').slice(0, -2));
topbar = document.getElementById("top-bar") topbar = document.getElementById("top-bar")
const topbarstyle = getComputedStyle(topbar) const topbarstyle = getComputedStyle(topbar)
topBarFirstX = parseInt(topbarstyle.marginInline) topBarFirstX = parseInt(topbarstyle.marginInline)
topbarWidth = parseInt(topbarstyle.width);
topBarLastX = topBarFirstX + topbarWidth;
topBarLastY = parseInt(topbarstyle.height); topBarLastY = parseInt(topbarstyle.height);
/*console.log(` /*console.log(`

View File

@ -8,7 +8,7 @@ import {
import { selected_group } from "./group-chats.js"; import { selected_group } from "./group-chats.js";
import { extension_settings, getContext, saveMetadataDebounced } from "./extensions.js"; import { extension_settings, getContext, saveMetadataDebounced } from "./extensions.js";
import { registerSlashCommand } from "./slash-commands.js"; import { registerSlashCommand } from "./slash-commands.js";
import { getCharaFilename, debounce, waitUntilCondition, delay } from "./utils.js"; import { getCharaFilename, debounce, delay } from "./utils.js";
import { getTokenCount } from "./tokenizers.js"; import { getTokenCount } from "./tokenizers.js";
export { MODULE_NAME as NOTE_MODULE_NAME }; export { MODULE_NAME as NOTE_MODULE_NAME };

View File

@ -398,7 +398,7 @@ async function setBackground(bg) {
} }
async function delBackground(bg) { async function delBackground(bg) {
const response = await fetch("/delbackground", { await fetch("/delbackground", {
method: "POST", method: "POST",
headers: getRequestHeaders(), headers: getRequestHeaders(),
body: JSON.stringify({ body: JSON.stringify({

View File

@ -28,7 +28,6 @@ import { createTagMapFromList } from "./tags.js";
import { import {
delay, delay,
getUniqueName, getUniqueName,
stringFormat,
} from "./utils.js"; } from "./utils.js";
export { export {

View File

@ -89,7 +89,6 @@ async function onDeleteButtonClick() {
*/ */
function enableBulkSelect() { function enableBulkSelect() {
$("#rm_print_characters_block .character_select").each((i, el) => { $("#rm_print_characters_block .character_select").each((i, el) => {
const character = $(el).text();
const checkbox = $("<input type='checkbox' class='bulk_select_checkbox'>"); const checkbox = $("<input type='checkbox' class='bulk_select_checkbox'>");
checkbox.on("change", () => { checkbox.on("change", () => {
// Do something when the checkbox is changed // Do something when the checkbox is changed

View File

@ -695,7 +695,7 @@ async function onDeleteClick() {
export async function deleteExtension(extensionName) { export async function deleteExtension(extensionName) {
try { try {
const response = await fetch('/api/extensions/delete', { await fetch('/api/extensions/delete', {
method: 'POST', method: 'POST',
headers: getRequestHeaders(), headers: getRequestHeaders(),
body: JSON.stringify({ extensionName }) body: JSON.stringify({ extensionName })

View File

@ -13,8 +13,6 @@ const DEBUG_PREFIX = "<Assets module> ";
let previewAudio = null; let previewAudio = null;
let ASSETS_JSON_URL = "https://raw.githubusercontent.com/SillyTavern/SillyTavern-Content/main/index.json" let ASSETS_JSON_URL = "https://raw.githubusercontent.com/SillyTavern/SillyTavern-Content/main/index.json"
const extensionName = "assets";
const extensionFolderPath = `scripts/extensions/${extensionName}`;
// DBG // DBG
//if (DEBUG_TONY_SAMA_FORK_MODE) //if (DEBUG_TONY_SAMA_FORK_MODE)
@ -26,9 +24,6 @@ let currentAssets = {};
// Extension UI and Settings // // Extension UI and Settings //
//#############################// //#############################//
const defaultSettings = {
}
function downloadAssetsList(url) { function downloadAssetsList(url) {
updateCurrentAssets().then(function () { updateCurrentAssets().then(function () {
fetch(url, { cache: "no-cache" }) fetch(url, { cache: "no-cache" })

View File

@ -1,4 +1,4 @@
import { callPopup, eventSource, event_types, getRequestHeaders, saveSettingsDebounced, this_chid } from "../../../script.js"; import { callPopup, eventSource, event_types, getRequestHeaders, saveSettingsDebounced } from "../../../script.js";
import { dragElement, isMobile } from "../../RossAscends-mods.js"; import { dragElement, isMobile } from "../../RossAscends-mods.js";
import { getContext, getApiUrl, modules, extension_settings, ModuleWorkerWrapper, doExtrasFetch, renderExtensionTemplate } from "../../extensions.js"; import { getContext, getApiUrl, modules, extension_settings, ModuleWorkerWrapper, doExtrasFetch, renderExtensionTemplate } from "../../extensions.js";
import { loadMovingUIState, power_user } from "../../power-user.js"; import { loadMovingUIState, power_user } from "../../power-user.js";
@ -393,7 +393,6 @@ async function unloadLiveChar() {
if (!loadResponse.ok) { if (!loadResponse.ok) {
throw new Error(loadResponse.statusText); throw new Error(loadResponse.statusText);
} }
const loadResponseText = await loadResponse.text();
//console.log(`Response: ${loadResponseText}`); //console.log(`Response: ${loadResponseText}`);
} catch (error) { } catch (error) {
//console.error(`Error unloading - ${error}`); //console.error(`Error unloading - ${error}`);

View File

@ -623,7 +623,6 @@ function generateQuickReplyElements() {
let quickReplyHtml = ''; let quickReplyHtml = '';
for (let i = 1; i <= extension_settings.quickReply.numberOfSlots; i++) { for (let i = 1; i <= extension_settings.quickReply.numberOfSlots; i++) {
let itemNumber = i + 1
quickReplyHtml += ` quickReplyHtml += `
<div class="flex-container alignitemscenter" data-order="${i}"> <div class="flex-container alignitemscenter" data-order="${i}">
<span class="drag-handle ui-sortable-handle">☰</span> <span class="drag-handle ui-sortable-handle">☰</span>

View File

@ -1,4 +1,6 @@
import { MenuItem } from "./MenuItem.js"; /**
* @typedef {import('./MenuItem.js').MenuItem} MenuItem
*/
export class ContextMenu { export class ContextMenu {
/**@type {MenuItem[]}*/ itemList = []; /**@type {MenuItem[]}*/ itemList = [];

View File

@ -1,4 +1,6 @@
import { MenuItem } from "./MenuItem.js"; /**
* @typedef {import('./MenuItem.js').MenuItem} MenuItem
*/
export class SubMenu { export class SubMenu {
/**@type {MenuItem[]}*/ itemList = []; /**@type {MenuItem[]}*/ itemList = [];

View File

@ -2362,7 +2362,6 @@ async function sdMessageButton(e) {
const $mes = $icon.closest('.mes'); const $mes = $icon.closest('.mes');
const message_id = $mes.attr('mesid'); const message_id = $mes.attr('mesid');
const message = context.chat[message_id]; const message = context.chat[message_id];
const characterName = message?.name || context.name2;
const characterFileName = context.characterId ? context.characters[context.characterId].name : context.groups[Object.keys(context.groups).filter(x => context.groups[x].id === context.groupId)[0]]?.id?.toString(); const characterFileName = context.characterId ? context.characters[context.characterId].name : context.groups[Object.keys(context.groups).filter(x => context.groups[x].id === context.groupId)[0]]?.id?.toString();
const messageText = message?.mes; const messageText = message?.mes;
const hasSavedImage = message?.extra?.image && message?.extra?.title; const hasSavedImage = message?.extra?.image && message?.extra?.title;

View File

@ -71,16 +71,6 @@ async function doTokenCounter() {
* @param {number[]} ids * @param {number[]} ids
*/ */
function drawChunks(chunks, ids) { function drawChunks(chunks, ids) {
const main_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBodyColor').trim()))
const italics_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeEmColor').trim()))
const quote_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeQuoteColor').trim()))
const blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBlurTintColor').trim()))
const chat_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeChatTintColor').trim()))
const user_mes_blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeUserMesBlurTintColor').trim()))
const bot_mes_blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBotMesBlurTintColor').trim()))
const shadow_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeShadowColor').trim()))
const border_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBorderColor').trim()))
const pastelRainbow = [ const pastelRainbow = [
//main_text_color, //main_text_color,
//italics_text_color, //italics_text_color,

View File

@ -4,17 +4,15 @@ TODO:
- Delete useless call - Delete useless call
*/ */
import { doExtrasFetch, extension_settings, getApiUrl, getContext, modules, ModuleWorkerWrapper } from "../../extensions.js" import { doExtrasFetch, extension_settings, getApiUrl, modules } from "../../extensions.js"
import { callPopup } from "../../../script.js" import { callPopup } from "../../../script.js"
import { initVoiceMap } from "./index.js" import { initVoiceMap } from "./index.js"
export { CoquiTtsProvider } export { CoquiTtsProvider }
const DEBUG_PREFIX = "<Coqui TTS module> "; const DEBUG_PREFIX = "<Coqui TTS module> ";
const UPDATE_INTERVAL = 1000;
let inApiCall = false; let inApiCall = false;
let voiceIdList = []; // Updated with module worker
let coquiApiModels = {}; // Initialized only once let coquiApiModels = {}; // Initialized only once
let coquiApiModelsFull = {}; // Initialized only once let coquiApiModelsFull = {}; // Initialized only once
let coquiLocalModels = []; // Initialized only once let coquiLocalModels = []; // Initialized only once

View File

@ -17,10 +17,7 @@ const UPDATE_INTERVAL = 1000
let voiceMapEntries = [] let voiceMapEntries = []
let voiceMap = {} // {charName:voiceid, charName2:voiceid2} let voiceMap = {} // {charName:voiceid, charName2:voiceid2}
let audioControl
let storedvalue = false; let storedvalue = false;
let lastCharacterId = null
let lastGroupId = null
let lastChatId = null let lastChatId = null
let lastMessageHash = null let lastMessageHash = null
@ -314,8 +311,6 @@ let currentAudioJob
let audioPaused = false let audioPaused = false
let audioQueueProcessorReady = true let audioQueueProcessorReady = true
let lastAudioPosition = 0
async function playAudioData(audioBlob) { async function playAudioData(audioBlob) {
// Since current audio job can be cancelled, don't playback if it is null // Since current audio job can be cancelled, don't playback if it is null
if (currentAudioJob == null) { if (currentAudioJob == null) {
@ -407,14 +402,12 @@ function addAudioControl() {
TTS Playback TTS Playback
</div>`) </div>`)
$('#ttsExtensionMenuItem').attr('title', 'TTS play/pause').on('click', onAudioControlClicked) $('#ttsExtensionMenuItem').attr('title', 'TTS play/pause').on('click', onAudioControlClicked)
audioControl = document.getElementById('tts_media_control')
updateUiAudioPlayState() updateUiAudioPlayState()
} }
function completeCurrentAudioJob() { function completeCurrentAudioJob() {
audioQueueProcessorReady = true audioQueueProcessorReady = true
currentAudioJob = null currentAudioJob = null
lastAudioPosition = 0
talkingAnimation(false) //stop lip animation talkingAnimation(false) //stop lip animation
// updateUiPlayState(); // updateUiPlayState();
} }
@ -463,8 +456,6 @@ function completeTtsJob() {
function saveLastValues() { function saveLastValues() {
const context = getContext() const context = getContext()
lastGroupId = context.groupId
lastCharacterId = context.characterId
lastChatId = context.chatId lastChatId = context.chatId
lastMessageHash = getStringHash( lastMessageHash = getStringHash(
(context.chat.length && context.chat[context.chat.length - 1].mes) ?? '' (context.chat.length && context.chat[context.chat.length - 1].mes) ?? ''

View File

@ -133,8 +133,7 @@ class XTTSTtsProvider {
// Perform a simple readiness check by trying to fetch voiceIds // Perform a simple readiness check by trying to fetch voiceIds
async checkReady() { async checkReady() {
await this.fetchTtsVoiceObjects()
const response = await this.fetchTtsVoiceObjects()
} }
async onRefreshClick() { async onRefreshClick() {

View File

@ -70,7 +70,7 @@ import {
depth_prompt_depth_default, depth_prompt_depth_default,
loadItemizedPrompts, loadItemizedPrompts,
} from "../script.js"; } from "../script.js";
import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect, tag_map, printTagFilters } from './tags.js'; import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect, tag_map } from './tags.js';
import { FILTER_TYPES, FilterHelper } from './filters.js'; import { FILTER_TYPES, FilterHelper } from './filters.js';
export { export {
@ -112,7 +112,7 @@ export const group_generation_mode = {
} }
export const groupCandidatesFilter = new FilterHelper(debounce(printGroupCandidates, 100)); export const groupCandidatesFilter = new FilterHelper(debounce(printGroupCandidates, 100));
const groupAutoModeInterval = setInterval(groupChatAutoModeWorker, 5000); setInterval(groupChatAutoModeWorker, 5000);
const saveGroupDebounced = debounce(async (group, reload) => await _save(group, reload), 500); const saveGroupDebounced = debounce(async (group, reload) => await _save(group, reload), 500);
async function _save(group, reload = true) { async function _save(group, reload = true) {

View File

@ -79,7 +79,6 @@ export {
} }
let openai_messages_count = 0; let openai_messages_count = 0;
let openai_narrator_messages_count = 0;
const default_main_prompt = "Write {{char}}'s next reply in a fictional chat between {{charIfNotGroup}} and {{user}}. Write 1 reply only in internet RP style, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Write at least 1 paragraph, up to 4. Always stay in character and avoid repetition."; const default_main_prompt = "Write {{char}}'s next reply in a fictional chat between {{charIfNotGroup}} and {{user}}. Write 1 reply only in internet RP style, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Write at least 1 paragraph, up to 4. Always stay in character and avoid repetition.";
const default_nsfw_prompt = "NSFW/Smut is allowed. Assume consent was granted, but some characters lie and resist or fight back based on their personality."; const default_nsfw_prompt = "NSFW/Smut is allowed. Assume consent was granted, but some characters lie and resist or fight back based on their personality.";
@ -406,7 +405,6 @@ function setOpenAIMessages(chat) {
let j = 0; let j = 0;
// clean openai msgs // clean openai msgs
const messages = []; const messages = [];
openai_narrator_messages_count = 0;
for (let i = chat.length - 1; i >= 0; i--) { for (let i = chat.length - 1; i >= 0; i--) {
let role = chat[j]['is_user'] ? 'user' : 'assistant'; let role = chat[j]['is_user'] ? 'user' : 'assistant';
let content = chat[j]['mes']; let content = chat[j]['mes'];
@ -414,7 +412,6 @@ function setOpenAIMessages(chat) {
// 100% legal way to send a message as system // 100% legal way to send a message as system
if (chat[j].extra?.type === system_message_types.NARRATOR) { if (chat[j].extra?.type === system_message_types.NARRATOR) {
role = 'system'; role = 'system';
openai_narrator_messages_count++;
} }
// for groups or sendas command - prepend a character's name // for groups or sendas command - prepend a character's name

View File

@ -3,7 +3,6 @@ import {
scrollChatToBottom, scrollChatToBottom,
characters, characters,
callPopup, callPopup,
getStatus,
reloadMarkdownProcessor, reloadMarkdownProcessor,
reloadCurrentChat, reloadCurrentChat,
getRequestHeaders, getRequestHeaders,
@ -416,7 +415,6 @@ function switchTokenCount() {
function switchMesIDDisplay() { function switchMesIDDisplay() {
const value = localStorage.getItem(storage_keys.mesIDDisplay_enabled); const value = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
let before = power_user.mesIDDisplay_enabled;
power_user.mesIDDisplay_enabled = value === null ? true : value == "true"; power_user.mesIDDisplay_enabled = value === null ? true : value == "true";
/* console.log(` /* console.log(`
localstorage value:${value}, localstorage value:${value},
@ -779,11 +777,9 @@ async function CreateZenSliders(elmnt) {
//console.log('clamping numVal to sliderMin') //console.log('clamping numVal to sliderMin')
numVal = sliderMin numVal = sliderMin
} }
var sliderValRange = sliderMax - sliderMin
var stepNumber = ((ui.value - sliderMin) / stepScale).toFixed(0); var stepNumber = ((ui.value - sliderMin) / stepScale).toFixed(0);
var handleText = (ui.value); var handleText = (ui.value);
var leftMargin = (stepNumber / numSteps) * 50 * -1; var leftMargin = (stepNumber / numSteps) * 50 * -1;
var percentOfMax = Number((ui.value / sliderMax)) //what % our value is of the max
var perStepPercent = 1 / numSteps //how far in % each step should be on the slider var perStepPercent = 1 / numSteps //how far in % each step should be on the slider
var leftPos = newSlider.width() * (stepNumber * perStepPercent) //how big of a left margin to give the slider for manual inputs var leftPos = newSlider.width() * (stepNumber * perStepPercent) //how big of a left margin to give the slider for manual inputs
/* console.log(` /* console.log(`
@ -2296,27 +2292,6 @@ function setAvgBG() {
return [r * 255, g * 255, b * 255]; return [r * 255, g * 255, b * 255];
} }
function rgbToLuminance(r, g, b) {
console.log(r, g, b)
const gammaCorrect = (color) => {
return color <= 0.03928
? color / 12.92
: Math.pow((color + 0.055) / 1.055, 2.4);
};
const rsRGB = r / 255;
const gsRGB = g / 255;
const bsRGB = b / 255;
const rLuminance = gammaCorrect(rsRGB).toFixed(2);
const gLuminance = gammaCorrect(gsRGB).toFixed(2);
const bLuminance = gammaCorrect(bsRGB).toFixed(2);
console.log(`rLum ${rLuminance}, gLum ${gLuminance}, bLum ${bLuminance}`)
return 0.2126 * Number(rLuminance) + 0.7152 * Number(gLuminance) + 0.0722 * Number(bLuminance);
}
//this version keeps BG and main text in same hue //this version keeps BG and main text in same hue
/* function getReadableTextColor(rgb) { /* function getReadableTextColor(rgb) {
const [r, g, b] = rgb; const [r, g, b] = rgb;

View File

@ -284,7 +284,7 @@ class PresetManager {
} }
async deleteCurrentPreset() { async deleteCurrentPreset() {
const { presets, preset_names } = this.getPresetList(); const { preset_names } = this.getPresetList();
const value = this.getSelectedPreset(); const value = this.getSelectedPreset();
const nameToDelete = this.getSelectedPresetName(); const nameToDelete = this.getSelectedPresetName();

View File

@ -8,7 +8,7 @@ import {
entitiesFilter, entitiesFilter,
printCharacters, printCharacters,
} from "../script.js"; } from "../script.js";
import { FILTER_TYPES, FilterHelper } from "./filters.js"; import { FILTER_TYPES } from "./filters.js";
import { groupCandidatesFilter, groups, selected_group } from "./group-chats.js"; import { groupCandidatesFilter, groups, selected_group } from "./group-chats.js";
import { download, onlyUnique, parseJsonFile, uuidv4 } from "./utils.js"; import { download, onlyUnique, parseJsonFile, uuidv4 } from "./utils.js";

View File

@ -1,4 +1,4 @@
import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPrompt, MAX_INJECTION_DEPTH, extension_prompt_types, getExtensionPromptByName, saveMetadata, getCurrentChatId } from "../script.js"; import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId } from "../script.js";
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean } from "./utils.js"; import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean } from "./utils.js";
import { extension_settings, getContext } from "./extensions.js"; import { extension_settings, getContext } from "./extensions.js";
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js"; import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js";
@ -1395,7 +1395,7 @@ function createWorldInfoEntry(name, data, fromSlashCommand = false) {
} }
async function _save(name, data) { async function _save(name, data) {
const response = await fetch("/editworldinfo", { await fetch("/editworldinfo", {
method: "POST", method: "POST",
headers: getRequestHeaders(), headers: getRequestHeaders(),
body: JSON.stringify({ name: name, data: data }), body: JSON.stringify({ name: name, data: data }),

View File

@ -1681,10 +1681,6 @@ function readAndParseFromDirectory(directoryPath, fileExtension = '.json') {
return parsedFiles; return parsedFiles;
} }
function sortByModifiedDate(directory) {
return (a, b) => +(new Date(fs.statSync(`${directory}/${b}`).mtime)) - +(new Date(fs.statSync(`${directory}/${a}`).mtime));
}
function sortByName(_) { function sortByName(_) {
return (a, b) => a.localeCompare(b); return (a, b) => a.localeCompare(b);
} }

View File

@ -2,7 +2,6 @@ const path = require('path');
const fs = require('fs'); const fs = require('fs');
const { default: simpleGit } = require('simple-git'); const { default: simpleGit } = require('simple-git');
const sanitize = require('sanitize-filename'); const sanitize = require('sanitize-filename');
const commandExistsSync = require('command-exists').sync;
const { DIRECTORIES } = require('./constants'); const { DIRECTORIES } = require('./constants');
/** /**

View File

@ -45,11 +45,6 @@ const logitBiasExp = [
{ "sequence": [21], "bias": -0.08, "ensure_sequence_finish": false, "generate_once": false } { "sequence": [21], "bias": -0.08, "ensure_sequence_finish": false, "generate_once": false }
] ]
const hypeBotLogitBiasExp = [
{ "sequence": [8162], "bias": -0.12, "ensure_sequence_finish": false, "generate_once": false },
{ "sequence": [46256, 224], "bias": -0.12, "ensure_sequence_finish": false, "generate_once": false }
];
function getBadWordsList(model) { function getBadWordsList(model) {
let list = [] let list = []

View File

@ -1,4 +1,3 @@
const express = require('express');
const vectra = require('vectra'); const vectra = require('vectra');
const path = require('path'); const path = require('path');
const sanitize = require('sanitize-filename'); const sanitize = require('sanitize-filename');