Chore: Add code formatting conventions as eslint rules (#5158) * Add code formatting conventions as eslint rules * Improve formatting in addQuickReply
Signed| @@ -102,5 +102,28 @@ module.exports = { | ||
| 102 | 102 | // These rules should eventually be enabled. |
| 103 | 103 | 'no-async-promise-executor': 'off', |
| 104 | 104 | 'no-inner-declarations': 'off', |
| 105 | + 'brace-style': 'off', | |
| 106 | + // Additional formatting rules based on codebase conventions | |
| 107 | + 'array-bracket-spacing': ['error', 'never'], | |
| 108 | + 'computed-property-spacing': ['error', 'never'], | |
| 109 | + 'block-spacing': ['error', 'always'], | |
| 110 | + 'keyword-spacing': ['error', { before: true, after: true }], | |
| 111 | + 'space-before-blocks': ['error', 'always'], | |
| 112 | + 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }], | |
| 113 | + 'space-in-parens': ['error', 'never'], | |
| 114 | + 'comma-spacing': ['error', { before: false, after: true }], | |
| 115 | + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], | |
| 116 | + 'func-call-spacing': ['error', 'never'], | |
| 117 | + 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }], | |
| 118 | + 'padded-blocks': ['error', 'never'], | |
| 119 | + 'no-whitespace-before-property': 'error', | |
| 120 | + 'space-unary-ops': ['error', { words: true, nonwords: false }], | |
| 121 | + 'arrow-spacing': ['error', { before: true, after: true }], | |
| 122 | + 'template-curly-spacing': ['error', 'never'], | |
| 123 | + 'rest-spread-spacing': ['error', 'never'], | |
| 124 | + 'generator-star-spacing': ['error', { before: false, after: true }], | |
| 125 | + 'yield-star-spacing': ['error', { before: false, after: true }], | |
| 126 | + 'template-tag-spacing': ['error', 'never'], | |
| 127 | + 'switch-colon-spacing': ['error', { after: true, before: false }], | |
| 105 | 128 | }, |
| 106 | 129 | }; |
| @@ -2516,7 +2516,6 @@ export function addOneMessage(mes, { type = undefined, insertAfter = null, scrol | ||
| 2516 | 2516 | * @returns {JQuery<HTMLElement>} Rendered HTMLElement. |
| 2517 | 2517 | */ |
| 2518 | 2518 | export function updateMessageElement(mes, { messageId = chat.length - 1, messageElement = messageTemplate.clone(), adjustMediaScroll = SCROLL_BEHAVIOR.NONE } = {}) { |
| 2519 | - | |
| 2520 | 2519 | let avatarImg = getThumbnailUrl('persona', user_avatar); |
| 2521 | 2520 | |
| 2522 | 2521 | //for non-user messages |
| @@ -3709,9 +3708,9 @@ class StreamingProcessor { | ||
| 3709 | 3708 | } |
| 3710 | 3709 | |
| 3711 | 3710 | /** |
| 3712 | 3711 | * @returns {GeneratorAsyncGenerator<{ text: string, swipes: string[], logprobs: import('./scripts/logprobs.js').TokenLogprobs, toolCalls: any[], state: any }, void, void>} |
| 3713 | 3712 | */ |
| 3714 | 3713 | async* nullStreamingGeneration() { |
| 3715 | 3714 | throw new Error('Generation function for streaming is not hooked up'); |
| 3716 | 3715 | } |
| 3717 | 3716 | |
| @@ -4862,7 +4861,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 4862 | 4861 | |
| 4863 | 4862 | // Add quiet generation prompt at depth 0 |
| 4864 | 4863 | if (quiet_prompt && quiet_prompt.length) { |
| 4865 | - | |
| 4866 | 4864 | // here name1 is forced for all quiet prompts..why? |
| 4867 | 4865 | const name = name1; |
| 4868 | 4866 | //checks if we are in instruct, if so, formats the chat as such, otherwise just adds the quiet prompt |
| @@ -5399,7 +5397,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 5399 | 5397 | if (!isAborted && power_user.auto_swipe && generatedTextFiltered(getMessage)) { |
| 5400 | 5398 | is_send_press = false; |
| 5401 | 5399 | return await swipe(null, SWIPE_DIRECTION.RIGHT, { source: SWIPE_SOURCE.AUTO_SWIPE, repeated: true, forceMesId: chat.length - 1 }); |
| 5402 | - | |
| 5403 | 5400 | } |
| 5404 | 5401 | |
| 5405 | 5402 | console.debug('/api/chats/save called by /Generate'); |
| @@ -6517,7 +6514,6 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title | ||
| 6517 | 6514 | !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type); |
| 6518 | 6515 | addOneMessage(chat[chat_id], { type: 'swipe' }); |
| 6519 | 6516 | !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type); |
| 6520 | - | |
| 6521 | 6517 | } else { |
| 6522 | 6518 | console.debug('entering chat update routine for non-swipe post'); |
| 6523 | 6519 | const newMessage = {}; |
| @@ -8247,7 +8243,6 @@ export async function getChatsFromFiles(data, isGroupChat) { | ||
| 8247 | 8243 | currentChat.shift(); |
| 8248 | 8244 | } |
| 8249 | 8245 | chat_dict[file_name] = currentChat; |
| 8250 | - | |
| 8251 | 8246 | } catch (error) { |
| 8252 | 8247 | console.error(error); |
| 8253 | 8248 | } |
| @@ -9588,7 +9583,6 @@ export async function createOrEditCharacter(e) { | ||
| 9588 | 9583 | select_rm_info('char_create', avatarId, oldSelectedChar); |
| 9589 | 9584 | |
| 9590 | 9585 | crop_data = undefined; |
| 9591 | - | |
| 9592 | 9586 | } catch (error) { |
| 9593 | 9587 | console.error('Error creating character', error); |
| 9594 | 9588 | toastr.error(t`Failed to create character`); |
| @@ -9984,7 +9978,6 @@ export async function swipe(event, direction, { source, repeated, message = chat | ||
| 9984 | 9978 | duration: 0, //used to be 100 //Disabled on Cohee's request. https://github.com/SillyTavern/SillyTavern/pull/4610/files#r2408731744 |
| 9985 | 9979 | queue: false, |
| 9986 | 9980 | progress: function (animation, progress, remainingMs) { |
| 9987 | - | |
| 9988 | 9981 | if (is_animation_scroll) chatElement.scrollTop(getMessageBottomHeight(thisMesDiv)); |
| 9989 | 9982 | }, |
| 9990 | 9983 | complete: function () { |
| @@ -10001,7 +9994,6 @@ export async function swipe(event, direction, { source, repeated, message = chat | ||
| 10001 | 9994 | * @param {boolean} [skipSwipeOut=false] |
| 10002 | 9995 | */ |
| 10003 | 9996 | async function animateSwipe(run_generate = false, skipSwipeOut = false) { |
| 10004 | - | |
| 10005 | 9997 | if (!skipSwipeOut) { |
| 10006 | 9998 | //Swipe out. |
| 10007 | 9999 | await animateSwipeTransition(mesId, { xEnd: `${swipeRange}px`, duration: swipeDuration }); |
| @@ -10069,7 +10061,6 @@ export async function swipe(event, direction, { source, repeated, message = chat | ||
| 10069 | 10061 | |
| 10070 | 10062 | //If the swipe is not being deleted. |
| 10071 | 10063 | if (source != SWIPE_SOURCE.DELETE && source != SWIPE_SOURCE.BACK) { |
| 10072 | - | |
| 10073 | 10064 | // Make sure ad-hoc changes to extras are saved before swiping away |
| 10074 | 10065 | syncMesToSwipe(mesId); |
| 10075 | 10066 | |
| @@ -10382,7 +10373,6 @@ export async function doNewChat({ deleteCurrentChat = false } = {}) { | ||
| 10382 | 10373 | await createOrEditCharacter(new CustomEvent('newChat')); |
| 10383 | 10374 | if (deleteCurrentChat) await delChat(chat_file_for_del + '.jsonl'); |
| 10384 | 10375 | } |
| 10385 | - | |
| 10386 | 10376 | } |
| 10387 | 10377 | |
| 10388 | 10378 | /** |
| @@ -11407,9 +11397,7 @@ jQuery(async function () { | ||
| 11407 | 11397 | |
| 11408 | 11398 | divchat.style.borderRadius = ''; |
| 11409 | 11399 | divchat.style.backgroundColor = ''; |
| 11410 | - | |
| 11411 | 11400 | } else { |
| 11412 | - | |
| 11413 | 11401 | divchat.style.borderRadius = '10px'; // Adjust the value to control the roundness of the corners |
| 11414 | 11402 | divchat.style.backgroundColor = ''; // Set the background color to your preference |
| 11415 | 11403 | |
| @@ -986,7 +986,6 @@ class PromptManager { | ||
| 986 | 986 | * @returns {void} |
| 987 | 987 | */ |
| 988 | 988 | addPrompt(prompt, identifier) { |
| 989 | - | |
| 990 | 989 | if (typeof prompt !== 'object' || prompt === null) throw new Error('Object is not a prompt'); |
| 991 | 990 | |
| 992 | 991 | const newPrompt = { |
| @@ -1318,7 +1317,6 @@ class PromptManager { | ||
| 1318 | 1317 | this.updatePromptByIdentifier(identifier, prompt); |
| 1319 | 1318 | debouncedSaveServiceSettings().then(() => this.render()); |
| 1320 | 1319 | }); |
| 1321 | - | |
| 1322 | 1320 | } |
| 1323 | 1321 | |
| 1324 | 1322 | /** |
| @@ -101,7 +101,6 @@ observer.observe(document.documentElement, observerConfig); | ||
| 101 | 101 | * @returns {string} - A human-readable string that represents the time spent generating characters. |
| 102 | 102 | */ |
| 103 | 103 | export function humanizeGenTime(total_gen_time) { |
| 104 | - | |
| 105 | 104 | //convert time_spent to humanized format of "_ Hours, _ Minutes, _ Seconds" from milliseconds |
| 106 | 105 | let time_spent = total_gen_time || 0; |
| 107 | 106 | time_spent = Math.floor(time_spent / 1000); |
| @@ -1274,8 +1273,6 @@ export function initRossMods() { | ||
| 1274 | 1273 | } |
| 1275 | 1274 | |
| 1276 | 1275 | |
| 1277 | - | |
| 1278 | - | |
| 1279 | 1276 | if (event.ctrlKey && /^[1-9]$/.test(event.key)) { |
| 1280 | 1277 | // This will eventually be to trigger quick replies |
| 1281 | 1278 | // event.preventDefault(); |
| @@ -80,8 +80,6 @@ export class AutoComplete { | ||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
| 83 | - | |
| 84 | - | |
| 85 | 83 | /** |
| 86 | 84 | * @param {HTMLTextAreaElement|HTMLInputElement} textarea The textarea to receive autocomplete. |
| 87 | 85 | * @param {() => boolean} checkIfActivate Function should return true only if under the current conditions, autocomplete should display (e.g., for slash commands: autoComplete.text[0] == '/') |
| @@ -414,7 +412,6 @@ export class AutoComplete { | ||
| 414 | 412 | }); |
| 415 | 413 | |
| 416 | 414 | |
| 417 | - | |
| 418 | 415 | if (this.isForceHidden) { |
| 419 | 416 | // hidden with escape |
| 420 | 417 | return this.hide(); |
| @@ -465,7 +462,6 @@ export class AutoComplete { | ||
| 465 | 462 | } |
| 466 | 463 | |
| 467 | 464 | |
| 468 | - | |
| 469 | 465 | /** |
| 470 | 466 | * Create updated DOM. |
| 471 | 467 | */ |
| @@ -514,7 +510,6 @@ export class AutoComplete { | ||
| 514 | 510 | } |
| 515 | 511 | |
| 516 | 512 | |
| 517 | - | |
| 518 | 513 | /** |
| 519 | 514 | * Update position of DOM. |
| 520 | 515 | */ |
| @@ -1,6 +1,3 @@ | ||
| 1 | - | |
| 2 | - | |
| 3 | - | |
| 4 | 1 | export class AutoCompleteFuzzyScore { |
| 5 | 2 | /**@type {number}*/ start; |
| 6 | 3 | /**@type {number}*/ longestConsecutive; |
| @@ -2,7 +2,6 @@ import { AutoCompleteNameResultBase } from './AutoCompleteNameResultBase.js'; | ||
| 2 | 2 | import { AutoCompleteSecondaryNameResult } from './AutoCompleteSecondaryNameResult.js'; |
| 3 | 3 | |
| 4 | 4 | |
| 5 | - | |
| 6 | 5 | export class AutoCompleteNameResult extends AutoCompleteNameResultBase { |
| 7 | 6 | /** |
| 8 | 7 | * |
| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | import { AutoCompleteOption } from './AutoCompleteOption.js'; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | - | |
| 5 | 4 | export class AutoCompleteNameResultBase { |
| 6 | 5 | /**@type {string} */ name; |
| 7 | 6 | /**@type {number} */ start; |
| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | import { AutoCompleteFuzzyScore } from './AutoCompleteFuzzyScore.js'; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | - | |
| 5 | 4 | export class AutoCompleteOption { |
| 6 | 5 | /** @type {string} */ name; |
| 7 | 6 | /** @type {string} */ typeIcon; |
| @@ -150,7 +150,6 @@ function onCfgMenuItemClick() { | ||
| 150 | 150 | setTimeout(function () { |
| 151 | 151 | $('#cfgConfig').hide(); |
| 152 | 152 | }, animation_duration); |
| 153 | - | |
| 154 | 153 | } |
| 155 | 154 | //duplicate options menu close handler from script.js |
| 156 | 155 | //because this listener takes priority |
| @@ -251,7 +251,6 @@ class DataMaidDialog { | ||
| 251 | 251 | categoryElement.remove(); |
| 252 | 252 | this.displayEmptyPlaceholder(); |
| 253 | 253 | }); |
| 254 | - | |
| 255 | 254 | }); |
| 256 | 255 | categoryElement.querySelectorAll('.dataMaidItemDelete').forEach(button => { |
| 257 | 256 | button.addEventListener('click', async () => { |
| @@ -95,7 +95,6 @@ async function downloadAssetsList(url) { | ||
| 95 | 95 | fetch(url, { cache: 'no-cache' }) |
| 96 | 96 | .then(response => response.json()) |
| 97 | 97 | .then(async function (json) { |
| 98 | - | |
| 99 | 98 | availableAssets = {}; |
| 100 | 99 | $('#assets_menu').empty(); |
| 101 | 100 | |
| @@ -1414,7 +1414,6 @@ export async function getExpressionsList({ filterAvailable = false } = {}) { | ||
| 1414 | 1414 | }); |
| 1415 | 1415 | |
| 1416 | 1416 | if (apiResult.ok) { |
| 1417 | - | |
| 1418 | 1417 | const data = await apiResult.json(); |
| 1419 | 1418 | expressionsList = data.labels; |
| 1420 | 1419 | return expressionsList; |
| @@ -1488,7 +1487,6 @@ function chooseSpriteForExpression(spriteFolderName, expression, { prevExpressio | ||
| 1488 | 1487 | } |
| 1489 | 1488 | |
| 1490 | 1489 | return spriteFile; |
| 1491 | - | |
| 1492 | 1490 | } |
| 1493 | 1491 | |
| 1494 | 1492 | /** |
| @@ -791,7 +791,6 @@ async function listGalleryCommand(args) { | ||
| 791 | 791 | |
| 792 | 792 | const items = await getGalleryItems(url); |
| 793 | 793 | return JSON.stringify(items.map(it => it.src)); |
| 794 | - | |
| 795 | 794 | } catch (err) { |
| 796 | 795 | console.error(err); |
| 797 | 796 | } |
| @@ -10,16 +10,12 @@ export class QuickReplyApi { | ||
| 10 | 10 | /** @type {SettingsUi} */ settingsUi; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - | |
| 14 | - | |
| 15 | 13 | constructor(/** @type {QuickReplySettings} */settings, /** @type {SettingsUi} */settingsUi) { |
| 16 | 14 | this.settings = settings; |
| 17 | 15 | this.settingsUi = settingsUi; |
| 18 | 16 | } |
| 19 | 17 | |
| 20 | 18 | |
| 21 | - | |
| 22 | - | |
| 23 | 19 | /** |
| 24 | 20 | * @param {QuickReply} qr |
| 25 | 21 | * @returns {QuickReplySet} |
| @@ -53,8 +49,6 @@ export class QuickReplyApi { | ||
| 53 | 49 | } |
| 54 | 50 | |
| 55 | 51 | |
| 56 | - | |
| 57 | - | |
| 58 | 52 | /** |
| 59 | 53 | * Executes a quick reply by its index and returns the result. |
| 60 | 54 | * |
| @@ -14,8 +14,6 @@ import { selected_group } from '../../group-chats.js'; | ||
| 14 | 14 | export { debounceAsync }; |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - | |
| 18 | - | |
| 19 | 17 | const _VERBOSE = true; |
| 20 | 18 | export const debug = (...msg) => _VERBOSE ? console.debug('[QR2]', ...msg) : null; |
| 21 | 19 | export const log = (...msg) => _VERBOSE ? console.log('[QR2]', ...msg) : null; |
| @@ -54,8 +52,6 @@ let autoExec; | ||
| 54 | 52 | export let quickReplyApi; |
| 55 | 53 | |
| 56 | 54 | |
| 57 | - | |
| 58 | - | |
| 59 | 55 | const loadSets = async () => { |
| 60 | 56 | const response = await fetch('/api/settings/get', { |
| 61 | 57 | method: 'POST', |
| @@ -8,8 +8,6 @@ export class AutoExecuteHandler { | ||
| 8 | 8 | /** @type {Boolean[]}*/ preventAutoExecuteStack = []; |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - | |
| 12 | - | |
| 13 | 11 | constructor(/** @type {QuickReplySettings} */settings) { |
| 14 | 12 | this.settings = settings; |
| 15 | 13 | } |
| @@ -20,8 +18,6 @@ export class AutoExecuteHandler { | ||
| 20 | 18 | } |
| 21 | 19 | |
| 22 | 20 | |
| 23 | - | |
| 24 | - | |
| 25 | 21 | async performAutoExecute(/** @type {QuickReply[]} */qrList) { |
| 26 | 22 | for (const qr of qrList) { |
| 27 | 23 | this.preventAutoExecuteStack.push(qr.preventAutoExecute); |
| @@ -27,8 +27,6 @@ export class QuickReply { | ||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - | |
| 31 | - | |
| 32 | 30 | /**@type {number}*/ id; |
| 33 | 31 | /**@type {string}*/ icon; |
| 34 | 32 | /**@type {string}*/ label = ''; |
| @@ -89,8 +87,6 @@ export class QuickReply { | ||
| 89 | 87 | } |
| 90 | 88 | |
| 91 | 89 | |
| 92 | - | |
| 93 | - | |
| 94 | 90 | unrender() { |
| 95 | 91 | this.dom?.remove(); |
| 96 | 92 | this.dom = null; |
| @@ -169,8 +165,6 @@ export class QuickReply { | ||
| 169 | 165 | } |
| 170 | 166 | |
| 171 | 167 | |
| 172 | - | |
| 173 | - | |
| 174 | 168 | renderSettings(idx) { |
| 175 | 169 | if (!this.settingsDom) { |
| 176 | 170 | const item = document.createElement('div'); { |
| @@ -1769,8 +1763,6 @@ export class QuickReply { | ||
| 1769 | 1763 | } |
| 1770 | 1764 | |
| 1771 | 1765 | |
| 1772 | - | |
| 1773 | - | |
| 1774 | 1766 | delete() { |
| 1775 | 1767 | if (this.onDelete) { |
| 1776 | 1768 | this.unrender(); |
| @@ -1908,8 +1900,6 @@ export class QuickReply { | ||
| 1908 | 1900 | } |
| 1909 | 1901 | |
| 1910 | 1902 | |
| 1911 | - | |
| 1912 | - | |
| 1913 | 1903 | toJSON() { |
| 1914 | 1904 | return { |
| 1915 | 1905 | id: this.id, |
| @@ -13,8 +13,6 @@ export class QuickReplyConfig { | ||
| 13 | 13 | /**@type {HTMLElement}*/ setListDom; |
| 14 | 14 | |
| 15 | 15 | |
| 16 | - | |
| 17 | - | |
| 18 | 16 | static from(props) { |
| 19 | 17 | props.setList = props.setList?.map(it => QuickReplySetLink.from(it))?.filter(it => it.set) ?? []; |
| 20 | 18 | const instance = Object.assign(new this(), props); |
| @@ -23,8 +21,6 @@ export class QuickReplyConfig { | ||
| 23 | 21 | } |
| 24 | 22 | |
| 25 | 23 | |
| 26 | - | |
| 27 | - | |
| 28 | 24 | init() { |
| 29 | 25 | this.setList.forEach(it => this.hookQuickReplyLink(it)); |
| 30 | 26 | } |
| @@ -54,8 +50,6 @@ export class QuickReplyConfig { | ||
| 54 | 50 | } |
| 55 | 51 | |
| 56 | 52 | |
| 57 | - | |
| 58 | - | |
| 59 | 53 | renderSettingsInto(/**@type {HTMLElement}*/root) { |
| 60 | 54 | /**@type {HTMLElement}*/ |
| 61 | 55 | this.setListDom = root.querySelector('.qr--setList'); |
| @@ -91,8 +85,6 @@ export class QuickReplyConfig { | ||
| 91 | 85 | } |
| 92 | 86 | |
| 93 | 87 | |
| 94 | - | |
| 95 | - | |
| 96 | 88 | /** |
| 97 | 89 | * @param {QuickReplySetLink} qrl |
| 98 | 90 | */ |
| @@ -8,8 +8,6 @@ export class QuickReplyContextLink { | ||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - | |
| 12 | - | |
| 13 | 11 | /**@type {QuickReplySet}*/ set; |
| 14 | 12 | /**@type {Boolean}*/ isChained = false; |
| 15 | 13 | |
| @@ -209,8 +209,7 @@ export class QuickReplySet { | ||
| 209 | 209 | |
| 210 | 210 | addQuickReply(data = {}) { |
| 211 | 211 | const id = Math.max(this.idIndex, this.qrList.reduce((max, qr) => Math.max(max, qr.id), 0)) + 1; |
| 212 | - data.id = | |
| 212 | + data.id = this.idIndex = id + 1; | |
| 213 | - this.idIndex = id + 1; | |
| 214 | 213 | const qr = QuickReply.from(data); |
| 215 | 214 | this.qrList.push(qr); |
| 216 | 215 | this.hookQuickReply(qr); |
| @@ -9,8 +9,6 @@ export class QuickReplySetLink { | ||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - | |
| 13 | - | |
| 14 | 12 | /**@type {QuickReplySet}*/ set; |
| 15 | 13 | /**@type {Boolean}*/ isVisible = true; |
| 16 | 14 | |
| @@ -23,8 +21,6 @@ export class QuickReplySetLink { | ||
| 23 | 21 | /**@type {HTMLElement}*/ settingsDom; |
| 24 | 22 | |
| 25 | 23 | |
| 26 | - | |
| 27 | - | |
| 28 | 24 | renderSettings(idx) { |
| 29 | 25 | this.index = idx; |
| 30 | 26 | const item = document.createElement('div'); { |
| @@ -98,8 +94,6 @@ export class QuickReplySetLink { | ||
| 98 | 94 | } |
| 99 | 95 | |
| 100 | 96 | |
| 101 | - | |
| 102 | - | |
| 103 | 97 | update() { |
| 104 | 98 | if (this.onUpdate) { |
| 105 | 99 | this.onUpdate(this); |
| @@ -118,8 +112,6 @@ export class QuickReplySetLink { | ||
| 118 | 112 | } |
| 119 | 113 | |
| 120 | 114 | |
| 121 | - | |
| 122 | - | |
| 123 | 115 | toJSON() { |
| 124 | 116 | return { |
| 125 | 117 | set: this.set.name, |
| @@ -15,8 +15,6 @@ export class QuickReplySettings { | ||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - | |
| 19 | - | |
| 20 | 18 | /**@type {Boolean}*/ isEnabled = false; |
| 21 | 19 | /**@type {Boolean}*/ isCombined = false; |
| 22 | 20 | /**@type {Boolean}*/ isPopout = false; |
| @@ -50,8 +48,6 @@ export class QuickReplySettings { | ||
| 50 | 48 | /**@type {Function}*/ onRequestEditSet; |
| 51 | 49 | |
| 52 | 50 | |
| 53 | - | |
| 54 | - | |
| 55 | 51 | init() { |
| 56 | 52 | this.hookConfig(this.config); |
| 57 | 53 | this.hookConfig(this.chatConfig); |
| @@ -72,8 +68,6 @@ export class QuickReplySettings { | ||
| 72 | 68 | } |
| 73 | 69 | |
| 74 | 70 | |
| 75 | - | |
| 76 | - | |
| 77 | 71 | save() { |
| 78 | 72 | extension_settings.quickReplyV2 = this.toJSON(); |
| 79 | 73 | saveSettingsDebounced(); |
| @@ -16,15 +16,11 @@ export class SlashCommandHandler { | ||
| 16 | 16 | /** @type {QuickReplyApi} */ api; |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - | |
| 20 | - | |
| 21 | 19 | constructor(/** @type {QuickReplyApi} */api) { |
| 22 | 20 | this.api = api; |
| 23 | 21 | } |
| 24 | 22 | |
| 25 | 23 | |
| 26 | - | |
| 27 | - | |
| 28 | 24 | init() { |
| 29 | 25 | function getExecutionIcons(/** @type {QuickReply} */ qr) { |
| 30 | 26 | let icons = ''; |
| @@ -783,8 +779,6 @@ export class SlashCommandHandler { | ||
| 783 | 779 | } |
| 784 | 780 | |
| 785 | 781 | |
| 786 | - | |
| 787 | - | |
| 788 | 782 | getSetByName(name) { |
| 789 | 783 | const set = this.api.getSetByName(name); |
| 790 | 784 | if (!set) { |
| @@ -802,8 +796,6 @@ export class SlashCommandHandler { | ||
| 802 | 796 | } |
| 803 | 797 | |
| 804 | 798 | |
| 805 | - | |
| 806 | - | |
| 807 | 799 | async executeQuickReplyByIndex(idx) { |
| 808 | 800 | try { |
| 809 | 801 | return await this.api.executeQuickReplyByIndex(idx); |
| @@ -10,15 +10,11 @@ export class ButtonUi { | ||
| 10 | 10 | /**@type {HTMLElement}*/ popoutDom; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - | |
| 14 | - | |
| 15 | 13 | constructor(/**@type {QuickReplySettings}*/settings) { |
| 16 | 14 | this.settings = settings; |
| 17 | 15 | } |
| 18 | 16 | |
| 19 | 17 | |
| 20 | - | |
| 21 | - | |
| 22 | 18 | render() { |
| 23 | 19 | if (this.settings.isPopout) { |
| 24 | 20 | return this.renderPopout(); |
| @@ -57,8 +53,6 @@ export class ButtonUi { | ||
| 57 | 53 | } |
| 58 | 54 | |
| 59 | 55 | |
| 60 | - | |
| 61 | - | |
| 62 | 56 | renderBar() { |
| 63 | 57 | if (!this.dom) { |
| 64 | 58 | let buttonHolder; |
| @@ -100,8 +94,6 @@ export class ButtonUi { | ||
| 100 | 94 | } |
| 101 | 95 | |
| 102 | 96 | |
| 103 | - | |
| 104 | - | |
| 105 | 97 | renderPopout() { |
| 106 | 98 | if (!this.popoutDom) { |
| 107 | 99 | let buttonHolder; |
| @@ -29,18 +29,12 @@ export class SettingsUi { | ||
| 29 | 29 | /**@type {HTMLSelectElement}*/ currentSet; |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - | |
| 33 | - | |
| 34 | 32 | constructor(/**@type {QuickReplySettings}*/settings) { |
| 35 | 33 | this.settings = settings; |
| 36 | 34 | settings.onRequestEditSet = (qrs) => this.selectQrSet(qrs); |
| 37 | 35 | } |
| 38 | 36 | |
| 39 | 37 | |
| 40 | - | |
| 41 | - | |
| 42 | - | |
| 43 | - | |
| 44 | 38 | rerender() { |
| 45 | 39 | if (!this.dom) return; |
| 46 | 40 | const content = this.dom.querySelector('.inline-drawer-content'); |
| @@ -256,8 +250,6 @@ export class SettingsUi { | ||
| 256 | 250 | } |
| 257 | 251 | |
| 258 | 252 | |
| 259 | - | |
| 260 | - | |
| 261 | 253 | async onIsEnabled() { |
| 262 | 254 | this.settings.isEnabled = this.isEnabled.checked; |
| 263 | 255 | this.settings.save(); |
| @@ -11,8 +11,6 @@ export class ContextMenu { | ||
| 11 | 11 | /**@type {HTMLElement}*/ menu; |
| 12 | 12 | |
| 13 | 13 | |
| 14 | - | |
| 15 | - | |
| 16 | 14 | constructor(/**@type {QuickReply}*/qr) { |
| 17 | 15 | // this.itemList = items; |
| 18 | 16 | this.itemList = this.build(qr).children; |
| @@ -104,8 +102,6 @@ export class ContextMenu { | ||
| 104 | 102 | } |
| 105 | 103 | |
| 106 | 104 | |
| 107 | - | |
| 108 | - | |
| 109 | 105 | show({ clientX, clientY }) { |
| 110 | 106 | if (this.isActive) return; |
| 111 | 107 | this.isActive = true; |
| @@ -15,8 +15,6 @@ export class MenuItem { | ||
| 15 | 15 | /**@type {function}*/ onExpand; |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - | |
| 19 | - | |
| 20 | 18 | /** |
| 21 | 19 | * |
| 22 | 20 | * @param {?string} icon |
| @@ -80,7 +78,6 @@ export class MenuItem { | ||
| 80 | 78 | } |
| 81 | 79 | item.addEventListener('mouseover', () => sub.show(item)); |
| 82 | 80 | item.addEventListener('mouseleave', () => sub.hide()); |
| 83 | - | |
| 84 | 81 | } |
| 85 | 82 | } |
| 86 | 83 | } |
| @@ -9,8 +9,6 @@ export class SubMenu { | ||
| 9 | 9 | /**@type {HTMLElement}*/ root; |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - | |
| 13 | - | |
| 14 | 12 | constructor(/**@type {MenuItem[]}*/items) { |
| 15 | 13 | this.itemList = items; |
| 16 | 14 | } |
| @@ -29,8 +27,6 @@ export class SubMenu { | ||
| 29 | 27 | } |
| 30 | 28 | |
| 31 | 29 | |
| 32 | - | |
| 33 | - | |
| 34 | 30 | show(/**@type {HTMLElement}*/parent) { |
| 35 | 31 | if (this.isActive) return; |
| 36 | 32 | this.isActive = true; |
| @@ -1031,7 +1031,6 @@ function executeRegexScriptForDebugging(script, text) { | ||
| 1031 | 1031 | const trailingText = text.substring(lastIndex); |
| 1032 | 1032 | outputText += trailingText; |
| 1033 | 1033 | highlightedOutput += escapeHtml(trailingText); |
| 1034 | - | |
| 1035 | 1034 | } catch (e) { |
| 1036 | 1035 | err = (err ? err + '; ' : '') + `Replace error: ${e.message}`; |
| 1037 | 1036 | outputText = text; // Fallback |
| @@ -115,5 +115,4 @@ jQuery(() => { | ||
| 115 | 115 | returns: 'number of tokens', |
| 116 | 116 | helpString: 'Counts the number of tokens in the current chat.', |
| 117 | 117 | })); |
| 118 | - | |
| 119 | 118 | }); |
| @@ -1043,7 +1043,6 @@ class AllTalkTtsProvider { | ||
| 1043 | 1043 | // V2: Combine the endpoint with the relative path |
| 1044 | 1044 | return `${this.settings.provider_endpoint}${data.output_file_url}`; |
| 1045 | 1045 | } |
| 1046 | - | |
| 1047 | 1046 | } catch (error) { |
| 1048 | 1047 | console.error('[fetchTtsGeneration] Exception caught:', error); |
| 1049 | 1048 | throw error; |
| @@ -239,7 +239,6 @@ class ChatterboxTtsProvider { | ||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | this.setupEventListeners(); |
| 242 | - | |
| 243 | 242 | } catch (error) { |
| 244 | 243 | console.error('Error loading Chatterbox settings:', error); |
| 245 | 244 | this.updateStatus('Offline'); |
| @@ -518,7 +517,6 @@ class ChatterboxTtsProvider { | ||
| 518 | 517 | }); |
| 519 | 518 | |
| 520 | 519 | await audio.play(); |
| 521 | - | |
| 522 | 520 | } catch (error) { |
| 523 | 521 | console.error('Error previewing voice:', error); |
| 524 | 522 | this.updateStatus('Ready'); |
| @@ -627,7 +625,6 @@ class ChatterboxTtsProvider { | ||
| 627 | 625 | |
| 628 | 626 | // Return the response directly - SillyTavern expects a Response object |
| 629 | 627 | return response; |
| 630 | - | |
| 631 | 628 | } catch (error) { |
| 632 | 629 | console.error('Error in generateTts:', error); |
| 633 | 630 | this.updateStatus('Ready'); |
| @@ -583,7 +583,6 @@ class CoquiTtsProvider { | ||
| 583 | 583 | $('#coqui_api_model_install_button').show(); |
| 584 | 584 | return; |
| 585 | 585 | } |
| 586 | - | |
| 587 | 586 | } |
| 588 | 587 | |
| 589 | 588 | |
| @@ -110,15 +110,11 @@ class CosyVoiceProvider { | ||
| 110 | 110 | //#################// |
| 111 | 111 | |
| 112 | 112 | async getVoice(voiceName) { |
| 113 | - | |
| 114 | - | |
| 115 | - | |
| 116 | 113 | if (this.voices.length == 0) { |
| 117 | 114 | this.voices = await this.fetchTtsVoiceObjects(); |
| 118 | 115 | } |
| 119 | 116 | |
| 120 | 117 | |
| 121 | - | |
| 122 | 118 | const match = this.voices.filter( |
| 123 | 119 | v => v.name == voiceName, |
| 124 | 120 | )[0]; |
| @@ -130,7 +126,6 @@ class CosyVoiceProvider { | ||
| 130 | 126 | } |
| 131 | 127 | |
| 132 | 128 | |
| 133 | - | |
| 134 | 129 | async generateTts(text, voiceId) { |
| 135 | 130 | const response = await this.fetchTtsGeneration(text, voiceId); |
| 136 | 131 | return response; |
| @@ -198,7 +193,6 @@ class CosyVoiceProvider { | ||
| 198 | 193 | } |
| 199 | 194 | |
| 200 | 195 | |
| 201 | - | |
| 202 | 196 | // Interface not used |
| 203 | 197 | async fetchTtsFromHistory(history_item_id) { |
| 204 | 198 | return Promise.resolve(history_item_id); |
| @@ -124,7 +124,6 @@ export class GoogleNativeTtsProvider { | ||
| 124 | 124 | console.info(`Google TTS: Loaded ${this.voices.length} voices`); |
| 125 | 125 | |
| 126 | 126 | return this.voices; |
| 127 | - | |
| 128 | 127 | } catch (error) { |
| 129 | 128 | console.error('Failed to fetch Google TTS voices:', error); |
| 130 | 129 | throw error; |
| @@ -151,7 +150,6 @@ export class GoogleNativeTtsProvider { | ||
| 151 | 150 | this.audioElement.src = url; |
| 152 | 151 | this.audioElement.play(); |
| 153 | 152 | this.audioElement.onended = () => URL.revokeObjectURL(url); |
| 154 | - | |
| 155 | 153 | } catch (error) { |
| 156 | 154 | console.error('TTS Preview Error:', error); |
| 157 | 155 | toastr.error(`Could not generate preview: ${error.message}`); |
| @@ -115,15 +115,11 @@ class GptSovitsV2Provider { | ||
| 115 | 115 | //#################// |
| 116 | 116 | |
| 117 | 117 | async getVoice(voiceName) { |
| 118 | - | |
| 119 | - | |
| 120 | - | |
| 121 | 118 | if (this.voices.length == 0) { |
| 122 | 119 | this.voices = await this.fetchTtsVoiceObjects(); |
| 123 | 120 | } |
| 124 | 121 | |
| 125 | 122 | |
| 126 | - | |
| 127 | 123 | const match = this.voices.filter( |
| 128 | 124 | v => v.name == voiceName, |
| 129 | 125 | )[0]; |
| @@ -135,7 +131,6 @@ class GptSovitsV2Provider { | ||
| 135 | 131 | } |
| 136 | 132 | |
| 137 | 133 | |
| 138 | - | |
| 139 | 134 | async generateTts(text, voiceId) { |
| 140 | 135 | const response = await this.fetchTtsGeneration(text, voiceId); |
| 141 | 136 | return response; |
| @@ -171,8 +166,6 @@ class GptSovitsV2Provider { | ||
| 171 | 166 | */ |
| 172 | 167 | |
| 173 | 168 | |
| 174 | - | |
| 175 | - | |
| 176 | 169 | async fetchTtsGeneration(inputText, voiceId, lang = null, forceNoStreaming = false) { |
| 177 | 170 | console.info(`Generating new TTS for voice_id ${voiceId}`); |
| 178 | 171 | |
| @@ -215,7 +208,6 @@ class GptSovitsV2Provider { | ||
| 215 | 208 | } |
| 216 | 209 | |
| 217 | 210 | |
| 218 | - | |
| 219 | 211 | // Interface not used |
| 220 | 212 | async fetchTtsFromHistory(history_item_id) { |
| 221 | 213 | return Promise.resolve(history_item_id); |
| @@ -1,4 +1,3 @@ | ||
| 1 | - | |
| 2 | 1 | import { saveTtsProviderSettings } from './index.js'; |
| 3 | 2 | |
| 4 | 3 | export { GSVITtsProvider }; |
| @@ -60,11 +59,9 @@ class GSVITtsProvider { | ||
| 60 | 59 | const characterList = await response.json(); |
| 61 | 60 | this.characterList = characterList; |
| 62 | 61 | this.voices = Object.keys(characterList); |
| 63 | - | |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | 64 | |
| 67 | - | |
| 68 | 65 | get settingsHtml() { |
| 69 | 66 | let html = ` |
| 70 | 67 | <label for="gsvi_api_language">Text Language</label> |
| @@ -142,11 +139,8 @@ class GSVITtsProvider { | ||
| 142 | 139 | $('#gsvi_batch_size_output').text(this.settings.batch_size); |
| 143 | 140 | |
| 144 | 141 | |
| 145 | - | |
| 146 | - | |
| 147 | 142 | // Persist settings changes |
| 148 | 143 | saveTtsProviderSettings(); |
| 149 | - | |
| 150 | 144 | } |
| 151 | 145 | |
| 152 | 146 | async loadSettings(settings) { |
| @@ -197,7 +191,6 @@ class GSVITtsProvider { | ||
| 197 | 191 | } |
| 198 | 192 | |
| 199 | 193 | |
| 200 | - | |
| 201 | 194 | // Perform a simple readiness check by trying to fetch voiceIds |
| 202 | 195 | async checkReady() { |
| 203 | 196 | await Promise.allSettled([this.fetchCharacterList()]); |
| @@ -256,12 +249,10 @@ class GSVITtsProvider { | ||
| 256 | 249 | |
| 257 | 250 | |
| 258 | 251 | return `${this.settings.provider_endpoint}/tts?${params.toString()}`; |
| 259 | - | |
| 260 | 252 | } |
| 261 | 253 | |
| 262 | 254 | // Interface not used by GSVI TTS |
| 263 | 255 | async fetchTtsFromHistory(history_item_id) { |
| 264 | 256 | return Promise.resolve(history_item_id); |
| 265 | 257 | } |
| 266 | - | |
| 267 | 258 | } |
| @@ -611,7 +611,6 @@ async function processTtsQueue() { | ||
| 611 | 611 | |
| 612 | 612 | // Pass the full voiceMapKey (e.g., "User ("Quotes")") as well with character name |
| 613 | 613 | await tts(segmentText, voiceId, char, voiceMapKey); |
| 614 | - | |
| 615 | 614 | } catch (error) { |
| 616 | 615 | toastr.error(error.toString()); |
| 617 | 616 | console.error(error); |
| @@ -707,7 +706,6 @@ async function processTtsQueue() { | ||
| 707 | 706 | |
| 708 | 707 | // Clear current job so the segmented jobs can be processed |
| 709 | 708 | currentTtsJob = null; |
| 710 | - | |
| 711 | 709 | } catch (error) { |
| 712 | 710 | toastr.error(error.toString()); |
| 713 | 711 | console.error(error); |
| @@ -1286,7 +1284,6 @@ export function getCharacters(unrestricted) { | ||
| 1286 | 1284 | } |
| 1287 | 1285 | |
| 1288 | 1286 | return characters; |
| 1289 | - | |
| 1290 | 1287 | } |
| 1291 | 1288 | |
| 1292 | 1289 | export function sanitizeId(input) { |
| @@ -1314,7 +1311,6 @@ function parseVoiceMap(voiceMapString) { | ||
| 1314 | 1311 | } |
| 1315 | 1312 | |
| 1316 | 1313 | |
| 1317 | - | |
| 1318 | 1314 | /** |
| 1319 | 1315 | * Apply voiceMap based on current voiceMapEntries |
| 1320 | 1316 | */ |
| @@ -837,7 +837,6 @@ class MiniMaxTtsProvider { | ||
| 837 | 837 | // Backend handles all the complex processing and returns audio data directly |
| 838 | 838 | console.debug('MiniMax TTS: Audio response received from backend'); |
| 839 | 839 | return response; |
| 840 | - | |
| 841 | 840 | } catch (error) { |
| 842 | 841 | console.error('Error in MiniMax TTS generation:', error); |
| 843 | 842 | throw error; |
| @@ -954,7 +953,6 @@ class MiniMaxTtsProvider { | ||
| 954 | 953 | this.audioElement.onended = null; |
| 955 | 954 | this.audioElement.onerror = null; |
| 956 | 955 | }; |
| 957 | - | |
| 958 | 956 | } catch (error) { |
| 959 | 957 | console.error('MiniMax TTS Preview Error:', error); |
| 960 | 958 | toastr.error(`Could not generate preview: ${error.message}`); |
| @@ -146,7 +146,6 @@ class OpenAITtsProvider { | ||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | populateCharacterInstructions() { |
| 149 | - | |
| 150 | 149 | const currentCharacters = $('.tts_voicemap_block_char span').map((i, el) => $(el).text()).get(); |
| 151 | 150 | |
| 152 | 151 | $('#openai-character-instructions').empty(); |
| @@ -172,5 +172,4 @@ class SileroTtsProvider { | ||
| 172 | 172 | async fetchTtsFromHistory(history_item_id) { |
| 173 | 173 | return Promise.resolve(history_item_id); |
| 174 | 174 | } |
| 175 | - | |
| 176 | 175 | } |
| @@ -323,5 +323,4 @@ class XTTSTtsProvider { | ||
| 323 | 323 | async fetchTtsFromHistory(history_item_id) { |
| 324 | 324 | return Promise.resolve(history_item_id); |
| 325 | 325 | } |
| 326 | - | |
| 327 | 326 | } |
| @@ -1456,7 +1456,6 @@ async function onViewStatsClick() { | ||
| 1456 | 1456 | messageElement.addClass('vectorized'); |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
| 1459 | - | |
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | async function onVectorizeAllFilesClick() { |
| @@ -13,7 +13,6 @@ export function SaveLocal(target, val) { | ||
| 13 | 13 | export function LoadLocal(target) { |
| 14 | 14 | console.debug('LoadLocal -- ' + target); |
| 15 | 15 | return localStorage.getItem(target); |
| 16 | - | |
| 17 | 16 | } |
| 18 | 17 | /** |
| 19 | 18 | * @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE |
| @@ -76,7 +76,6 @@ export const fuzzySearchCategories = Object.freeze({ | ||
| 76 | 76 | * data = filterHelper.applyFilters(data); |
| 77 | 77 | */ |
| 78 | 78 | export class FilterHelper { |
| 79 | - | |
| 80 | 79 | /** |
| 81 | 80 | * Cache fuzzy search weighting scores for re-usability, sorting and stuff |
| 82 | 81 | * |
| @@ -2477,7 +2477,6 @@ jQuery(() => { | ||
| 2477 | 2477 | const value = $(this).prop('checked'); |
| 2478 | 2478 | hideMutedSprites = value; |
| 2479 | 2479 | onHideMutedSpritesClick(value); |
| 2480 | - | |
| 2481 | 2480 | }); |
| 2482 | 2481 | $('#send_textarea').on('keyup', onSendTextareaInput); |
| 2483 | 2482 | $('#groupCurrentMemberPopoutButton').on('click', doCurMemberListPopout); |
| @@ -59,7 +59,8 @@ export function initInputMarkdown() { | ||
| 59 | 59 | let cursorShift = charsToAdd.length; |
| 60 | 60 | let selectedTextandPossibleFormatting = textarea.value.substring(start - possiblePreviousFormattingMargin, end + possiblePreviousFormattingMargin).trim(); |
| 61 | 61 | |
| 62 | 62 | if (isTextSelected) { //if text is selected |
| 63 | + //if text is selected | |
| 63 | 64 | selectedText = textarea.value.substring(start, end); |
| 64 | 65 | if (selectedTextandPossibleFormatting === charsToAdd + selectedText + charsToAdd) { |
| 65 | 66 | // If the selected text is already formatted, remove the formatting |
| @@ -90,7 +91,8 @@ export function initInputMarkdown() { | ||
| 90 | 91 | textarea.focus(); |
| 91 | 92 | document.execCommand('insertText', false, charsToAdd + selectedText + charsToAdd + possibleAddedSpace); |
| 92 | 93 | } |
| 93 | 94 | } else {// No text is selected |
| 95 | + // No text is selected | |
| 94 | 96 | //check 1 character before and after the cursor for non-space characters |
| 95 | 97 | |
| 96 | 98 | if (beforeCaret !== ' ' && afterCaret !== ' ' && afterCaret !== '' && beforeCaret !== '') { //look for caret in the middle of a word |
| @@ -116,7 +118,6 @@ export function initInputMarkdown() { | ||
| 116 | 118 | } |
| 117 | 119 | |
| 118 | 120 | if (charsToAdd + discoveredWord + charsToAdd === discoveredWordWithPossibleFormatting) { |
| 119 | - | |
| 120 | 121 | // Replace the expanded selection with the original discovered word |
| 121 | 122 | textarea.focus(); |
| 122 | 123 | document.execCommand('insertText', false, discoveredWord); |
| @@ -126,8 +127,6 @@ export function initInputMarkdown() { | ||
| 126 | 127 | textarea.focus(); |
| 127 | 128 | document.execCommand('insertText', false, charsToAdd + discoveredWord + charsToAdd); |
| 128 | 129 | } |
| 129 | - | |
| 130 | - | |
| 131 | 130 | } else { //caret is not inside a word, so just add the formatting |
| 132 | 131 | textarea.focus(); |
| 133 | 132 | textarea.setSelectionRange(start, end); |
| @@ -798,7 +798,6 @@ jQuery(() => { | ||
| 798 | 798 | $('#instruct_system_sequence').prop('readOnly', false); |
| 799 | 799 | $('#instruct_system_suffix').prop('readOnly', false); |
| 800 | 800 | } |
| 801 | - | |
| 802 | 801 | }); |
| 803 | 802 | |
| 804 | 803 | $('#instruct_enabled').on('change', function () { |
| @@ -2279,7 +2279,6 @@ function appendElectronHubOptions(model_list, groupModels = false) { | ||
| 2279 | 2279 | appendOption(model); |
| 2280 | 2280 | }); |
| 2281 | 2281 | } |
| 2282 | - | |
| 2283 | 2282 | } |
| 2284 | 2283 | |
| 2285 | 2284 | function electronHubSortBy(data, property = 'alphabetically') { |
| @@ -3985,7 +3984,6 @@ function loadOpenAISettings(data, settings) { | ||
| 3985 | 3984 | option.value = i; |
| 3986 | 3985 | option.text = item; |
| 3987 | 3986 | $('#settings_preset_openai').append(option); |
| 3988 | - | |
| 3989 | 3987 | }); |
| 3990 | 3988 | openai_setting_names = settingNames; |
| 3991 | 3989 | |
| @@ -4896,7 +4894,6 @@ function getSiliconflowMaxContext(model, isUnlocked) { | ||
| 4896 | 4894 | |
| 4897 | 4895 | // Return context size if model found, otherwise default to 32k |
| 4898 | 4896 | return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_32k; |
| 4899 | - | |
| 4900 | 4897 | } |
| 4901 | 4898 | |
| 4902 | 4899 | /** |
| @@ -5041,7 +5038,6 @@ async function onModelChange() { | ||
| 5041 | 5038 | console.log('Claude model changed to', value); |
| 5042 | 5039 | oai_settings.claude_model = value; |
| 5043 | 5040 | $('#model_claude_select').val(oai_settings.claude_model); |
| 5044 | - | |
| 5045 | 5041 | } |
| 5046 | 5042 | |
| 5047 | 5043 | if ($(this).is('#model_openai_select')) { |
| @@ -1593,7 +1593,6 @@ export async function showCharConnections() { | ||
| 1593 | 1593 | highlightPersonas: true, |
| 1594 | 1594 | targetedChar: getCurrentConnectionObj(), |
| 1595 | 1595 | shiftClickHandler: (element, ev) => { |
| 1596 | - | |
| 1597 | 1596 | const personaId = $(element).attr('data-pid'); |
| 1598 | 1597 | |
| 1599 | 1598 | /** @type {PersonaConnection[]} */ |
| @@ -1845,7 +1844,6 @@ async function lockPersonaCallback(_args, value) { | ||
| 1845 | 1844 | if (isFalseBoolean(value)) { |
| 1846 | 1845 | await setPersonaLockState(false, type); |
| 1847 | 1846 | return 'false'; |
| 1848 | - | |
| 1849 | 1847 | } |
| 1850 | 1848 | |
| 1851 | 1849 | return ''; |
| @@ -478,7 +478,6 @@ export class Popup { | ||
| 478 | 478 | break; |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | - | |
| 482 | 481 | }; |
| 483 | 482 | this.dlg.addEventListener('keydown', keyListener.bind(this)); |
| 484 | 483 | } |
| @@ -536,7 +536,6 @@ function switchSwipeNumAllMessages() { | ||
| 536 | 536 | var originalSliderValues = []; |
| 537 | 537 | |
| 538 | 538 | async function switchLabMode({ noReset = false } = {}) { |
| 539 | - | |
| 540 | 539 | /* if (power_user.enableZenSliders && power_user.enableLabMode) { |
| 541 | 540 | toastr.warning("Can't start Lab Mode while Zen Sliders are active") |
| 542 | 541 | return |
| @@ -571,8 +570,6 @@ async function switchLabMode({ noReset = false } = {}) { | ||
| 571 | 570 | $('#amount_gen').attr('min', '1') |
| 572 | 571 | .attr('max', '99999') |
| 573 | 572 | .attr('step', '1'); |
| 574 | - | |
| 575 | - | |
| 576 | 573 | } else if (!noReset) { |
| 577 | 574 | //re apply the original sliders values to each input |
| 578 | 575 | originalSliderValues.forEach(function (slider) { |
| @@ -628,7 +625,6 @@ async function switchZenSliders() { | ||
| 628 | 625 | }); |
| 629 | 626 | $('div[id$="_zenslider"]').remove(); |
| 630 | 627 | } |
| 631 | - | |
| 632 | 628 | } |
| 633 | 629 | async function CreateZenSliders(elmnt) { |
| 634 | 630 | var originalSlider = elmnt; |
| @@ -1178,7 +1174,6 @@ function applyShadowWidth() { | ||
| 1178 | 1174 | document.documentElement.style.setProperty('--shadowWidth', String(power_user.shadow_width)); |
| 1179 | 1175 | $('#shadow_width_counter').val(power_user.shadow_width); |
| 1180 | 1176 | $('#shadow_width').val(power_user.shadow_width); |
| 1181 | - | |
| 1182 | 1177 | } |
| 1183 | 1178 | |
| 1184 | 1179 | function applyFontScale(type) { |
| @@ -2954,7 +2949,6 @@ function setAvgBG() { | ||
| 2954 | 2949 | } */ |
| 2955 | 2950 | |
| 2956 | 2951 | function getAverageRGB(imgEl) { |
| 2957 | - | |
| 2958 | 2952 | var blockSize = 5, // only visit every 5 pixels |
| 2959 | 2953 | defaultRGB = { r: 0, g: 0, b: 0 }, // for non-supporting envs |
| 2960 | 2954 | canvas = document.createElement('canvas'), |
| @@ -2994,7 +2988,6 @@ function setAvgBG() { | ||
| 2994 | 2988 | rgb.b = ~~(rgb.b / count); |
| 2995 | 2989 | |
| 2996 | 2990 | return rgb; |
| 2997 | - | |
| 2998 | 2991 | } |
| 2999 | 2992 | |
| 3000 | 2993 | /** |
| @@ -514,7 +514,6 @@ class PresetManager { | ||
| 514 | 514 | console.error('Preset could not be renamed', error); |
| 515 | 515 | throw new Error('Preset could not be renamed'); |
| 516 | 516 | } |
| 517 | - | |
| 518 | 517 | } |
| 519 | 518 | |
| 520 | 519 | /** |
| @@ -865,7 +865,6 @@ function selectReasoningTemplateCallback(args, name) { | ||
| 865 | 865 | UI.$select.val(foundName).trigger('change'); |
| 866 | 866 | !quiet && toastr.success(`Reasoning template "${foundName}" selected`); |
| 867 | 867 | return foundName; |
| 868 | - | |
| 869 | 868 | } |
| 870 | 869 | |
| 871 | 870 | function registerReasoningSlashCommands() { |
| @@ -203,7 +203,6 @@ function setSamplerListListeners() { | ||
| 203 | 203 | |
| 204 | 204 | console.log(samplerName, relatedDOMElement.data(SELECT_SAMPLER.DATA), shouldDisplay); |
| 205 | 205 | }); |
| 206 | - | |
| 207 | 206 | } |
| 208 | 207 | |
| 209 | 208 | function isElementVisibleInDOM(element) { |
| @@ -4916,7 +4916,6 @@ export async function sendNarratorMessage(args, text) { | ||
| 4916 | 4916 | } |
| 4917 | 4917 | |
| 4918 | 4918 | export async function promptQuietForLoudResponse(who, text) { |
| 4919 | - | |
| 4920 | 4919 | let character_id = getContext().characterId; |
| 4921 | 4920 | if (who === 'sys') { |
| 4922 | 4921 | text = 'System: ' + text; |
| @@ -4955,7 +4954,6 @@ export async function promptQuietForLoudResponse(who, text) { | ||
| 4955 | 4954 | addOneMessage(message); |
| 4956 | 4955 | await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1)); |
| 4957 | 4956 | await saveChatConditional(); |
| 4958 | - | |
| 4959 | 4957 | } |
| 4960 | 4958 | |
| 4961 | 4959 | async function sendCommentMessage(args, text) { |
| @@ -26,7 +26,6 @@ import { SlashCommandScope } from './SlashCommandScope.js'; | ||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - | |
| 30 | 29 | export class SlashCommand { |
| 31 | 30 | /** |
| 32 | 31 | * Creates a SlashCommand from a properties object. |
| @@ -48,8 +47,6 @@ export class SlashCommand { | ||
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | |
| 51 | - | |
| 52 | - | |
| 53 | 50 | /**@type {string}*/ name; |
| 54 | 51 | /**@type {(namedArguments:NamedArguments, unnamedArguments:UnnamedArguments)=>string|SlashCommandClosure|Promise<string|SlashCommandClosure>}*/ callback; |
| 55 | 52 | /**@type {string}*/ helpString; |
| @@ -5,7 +5,6 @@ import { SlashCommandExecutor } from './SlashCommandExecutor.js'; | ||
| 5 | 5 | import { SlashCommandScope } from './SlashCommandScope.js'; |
| 6 | 6 | |
| 7 | 7 | |
| 8 | - | |
| 9 | 8 | /**@readonly*/ |
| 10 | 9 | /**@enum {string}*/ |
| 11 | 10 | export const ARGUMENT_TYPE = { |
| @@ -10,8 +10,6 @@ export class SlashCommandCommandAutoCompleteOption extends AutoCompleteOption { | ||
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - | |
| 14 | - | |
| 15 | 13 | /** |
| 16 | 14 | * @param {SlashCommand} command |
| 17 | 15 | * @param {string} name |
| @@ -18,15 +18,11 @@ export class SlashCommandDebugController { | ||
| 18 | 18 | /** @type {(closure:SlashCommandClosure, executor:SlashCommandExecutor)=>Promise<boolean>} */ onBreakPoint; |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - | |
| 22 | - | |
| 23 | 21 | testStepping(closure) { |
| 24 | 22 | return this.stepStack[this.stack.indexOf(closure)]; |
| 25 | 23 | } |
| 26 | 24 | |
| 27 | 25 | |
| 28 | - | |
| 29 | - | |
| 30 | 26 | down(closure) { |
| 31 | 27 | this.stack.push(closure); |
| 32 | 28 | if (this.stepStack.length < this.stack.length) { |
| @@ -44,7 +40,6 @@ export class SlashCommandDebugController { | ||
| 44 | 40 | } |
| 45 | 41 | |
| 46 | 42 | |
| 47 | - | |
| 48 | 43 | resume() { |
| 49 | 44 | this.continueResolver?.(false); |
| 50 | 45 | this.continuePromise = null; |
| @@ -18,7 +18,6 @@ export class SlashCommandEnumAutoCompleteOption extends AutoCompleteOption { | ||
| 18 | 18 | /**@type {SlashCommandEnumValue}*/ enumValue; |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - | |
| 22 | 21 | /** |
| 23 | 22 | * @param {SlashCommand} cmd |
| 24 | 23 | * @param {SlashCommandEnumValue} enumValue |
| @@ -48,7 +48,6 @@ export class SlashCommandExecutionError extends Error { | ||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - | |
| 52 | 51 | constructor(cause, message, commandName, start, end, commandText, fullText) { |
| 53 | 52 | super(message, { cause }); |
| 54 | 53 | this.commandName = commandName; |
| @@ -109,8 +109,6 @@ export class SlashCommandScope { | ||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - | |
| 113 | - | |
| 114 | 112 | export class SlashCommandScopeVariableExistsError extends Error {} |
| 115 | 113 | |
| 116 | 114 | |
| @@ -2091,7 +2091,6 @@ function onTagAsFolderClick() { | ||
| 2091 | 2091 | // If folder display has changed, we have to redraw the character list, otherwise this folders state would not change |
| 2092 | 2092 | printCharactersDebounced(); |
| 2093 | 2093 | saveSettingsDebounced(); |
| 2094 | - | |
| 2095 | 2094 | } |
| 2096 | 2095 | |
| 2097 | 2096 | function updateDrawTagFolder(element, tag) { |
| @@ -802,7 +802,6 @@ async function getStatusTextgen() { | ||
| 802 | 802 | console.info('Status check aborted.', err.reason); |
| 803 | 803 | } else { |
| 804 | 804 | console.error('Error getting status', err); |
| 805 | - | |
| 806 | 805 | } |
| 807 | 806 | setOnlineStatus('no_connection'); |
| 808 | 807 | } |
| @@ -455,7 +455,6 @@ async function changeName(handle, name, callback) { | ||
| 455 | 455 | |
| 456 | 456 | toastr.success('Name changed successfully', 'Name Changed'); |
| 457 | 457 | callback(); |
| 458 | - | |
| 459 | 458 | } catch (error) { |
| 460 | 459 | console.error('Error changing name:', error); |
| 461 | 460 | } |
| @@ -495,7 +494,6 @@ async function restoreSnapshot(name, callback) { | ||
| 495 | 494 | } catch (error) { |
| 496 | 495 | console.error('Error restoring snapshot:', error); |
| 497 | 496 | } |
| 498 | - | |
| 499 | 497 | } |
| 500 | 498 | |
| 501 | 499 | /** |
| @@ -601,7 +599,6 @@ async function viewSettingsSnapshots() { | ||
| 601 | 599 | const content = await loadSnapshotContent(snapshot.name); |
| 602 | 600 | contentBlock.val(content); |
| 603 | 601 | } |
| 604 | - | |
| 605 | 602 | }); |
| 606 | 603 | template.find('.snapshotList').append(snapshotBlock); |
| 607 | 604 | } |
| @@ -667,7 +664,6 @@ async function resetEverything(callback) { | ||
| 667 | 664 | } catch (error) { |
| 668 | 665 | console.error('Error resetting everything:', error); |
| 669 | 666 | } |
| 670 | - | |
| 671 | 667 | } |
| 672 | 668 | |
| 673 | 669 | async function openUserProfile() { |
| @@ -2310,7 +2310,6 @@ export function highlightRegex(regexStr) { | ||
| 2310 | 2310 | flags: new RegExp('(?<=\\/)([gimsuy]*)$', 'g'), // Match trailing flags |
| 2311 | 2311 | delimiters: new RegExp('^\\/|(?<![\\\\<])\\/', 'g'), // Match leading or trailing delimiters |
| 2312 | 2312 | }; |
| 2313 | - | |
| 2314 | 2313 | } catch (error) { |
| 2315 | 2314 | return { |
| 2316 | 2315 | brackets: new RegExp('(\\\\)?\\[.*?\\]', 'g'), // Non-escaped square brackets |
| @@ -675,7 +675,6 @@ class WorldInfoTimedEffects { | ||
| 675 | 675 | console.log('[WI] Timed effect "delay" applied to entry', entry); |
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | - | |
| 679 | 678 | } |
| 680 | 679 | |
| 681 | 680 | /** |
| @@ -4495,7 +4494,6 @@ function parseDecorators(content) { | ||
| 4495 | 4494 | } |
| 4496 | 4495 | |
| 4497 | 4496 | return [[], content]; |
| 4498 | - | |
| 4499 | 4497 | } |
| 4500 | 4498 | |
| 4501 | 4499 | /** |
| @@ -111,7 +111,6 @@ router.post('/get', async (request, response) => { | ||
| 111 | 111 | |
| 112 | 112 | try { |
| 113 | 113 | if (fs.existsSync(folderPath) && fs.statSync(folderPath).isDirectory()) { |
| 114 | - | |
| 115 | 114 | ensureFoldersExist(request.user.directories); |
| 116 | 115 | |
| 117 | 116 | const folders = fs.readdirSync(folderPath, { withFileTypes: true }) |
| @@ -346,7 +345,6 @@ router.post('/character', async (request, response) => { | ||
| 346 | 345 | let output = []; |
| 347 | 346 | try { |
| 348 | 347 | if (fs.existsSync(folderPath) && fs.statSync(folderPath).isDirectory()) { |
| 349 | - | |
| 350 | 348 | // Live2d assets |
| 351 | 349 | if (category == 'live2d') { |
| 352 | 350 | const folders = fs.readdirSync(folderPath, { withFileTypes: true }); |
| @@ -541,7 +541,6 @@ llamacpp.post('/props', async function (request, response) { | ||
| 541 | 541 | console.debug('LlamaCpp props response:', data); |
| 542 | 542 | |
| 543 | 543 | return response.send(data); |
| 544 | - | |
| 545 | 544 | } catch (error) { |
| 546 | 545 | console.error(error); |
| 547 | 546 | return response.sendStatus(500); |
| @@ -591,7 +590,6 @@ llamacpp.post('/slots', async function (request, response) { | ||
| 591 | 590 | console.debug('LlamaCpp slots response:', data); |
| 592 | 591 | |
| 593 | 592 | return response.send(data); |
| 594 | - | |
| 595 | 593 | } catch (error) { |
| 596 | 594 | console.error(error); |
| 597 | 595 | return response.sendStatus(500); |
| @@ -639,7 +639,6 @@ function charaFormatData(data, directories) { | ||
| 639 | 639 | if (file && file.entries) { |
| 640 | 640 | _.set(char, 'data.character_book', convertWorldInfoToCharacterBook(data.world, file.entries)); |
| 641 | 641 | } |
| 642 | - | |
| 643 | 642 | } catch { |
| 644 | 643 | console.warn(`Failed to read world info file: ${data.world}. Character book will not be available.`); |
| 645 | 644 | } |
| @@ -921,7 +920,8 @@ async function importFromJson(uploadPath, { request }, preservedFileName) { | ||
| 921 | 920 | let charJSON = JSON.stringify(char); |
| 922 | 921 | const result = await writeCharacterData(DEFAULT_AVATAR_PATH, charJSON, pngName, request); |
| 923 | 922 | return result ? pngName : ''; |
| 924 | 923 | } else if (jsonData.char_name !== undefined) {//json Pygmalion notepad |
| 924 | + //json Pygmalion notepad | |
| 925 | 925 | console.info('Importing from gradio json'); |
| 926 | 926 | jsonData.char_name = sanitize(jsonData.char_name); |
| 927 | 927 | if (jsonData.creator_notes) { |
| @@ -367,7 +367,6 @@ router.post('/version', async (request, response) => { | ||
| 367 | 367 | const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath); |
| 368 | 368 | |
| 369 | 369 | return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); |
| 370 | - | |
| 371 | 370 | } catch (error) { |
| 372 | 371 | console.error('Getting extension version failed', error); |
| 373 | 372 | return response.status(500).send(`Server Error: ${error.message}`); |
| @@ -406,7 +405,6 @@ router.post('/delete', async (request, response) => { | ||
| 406 | 405 | console.info(`Extension has been deleted at ${extensionPath}`); |
| 407 | 406 | |
| 408 | 407 | return response.send(`Extension has been deleted at ${extensionPath}`); |
| 409 | - | |
| 410 | 408 | } catch (error) { |
| 411 | 409 | console.error('Deleting custom content failed', error); |
| 412 | 410 | return response.status(500).send(`Server Error: ${error.message}`); |
| @@ -256,7 +256,6 @@ router.post('/caption-image', async (request, response) => { | ||
| 256 | 256 | console.info(status); |
| 257 | 257 | |
| 258 | 258 | if (status.state === HordeAsyncRequestStates.done) { |
| 259 | - | |
| 260 | 259 | if (status.forms === undefined) { |
| 261 | 260 | console.error('Image interrogation request failed: no forms found.'); |
| 262 | 261 | return response.sendStatus(500); |
| @@ -278,7 +277,6 @@ router.post('/caption-image', async (request, response) => { | ||
| 278 | 277 | return response.sendStatus(503); |
| 279 | 278 | } |
| 280 | 279 | } |
| 281 | - | |
| 282 | 280 | } catch (error) { |
| 283 | 281 | console.error(error); |
| 284 | 282 | response.sendStatus(500); |
| @@ -442,7 +442,6 @@ router.post('/', async function (request, response) { | ||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | return response.status(400).json({ error: 'Invalid request format.' }); |
| 445 | - | |
| 446 | 445 | } catch (error) { |
| 447 | 446 | console.error('[ImageMetadata] API error:', error); |
| 448 | 447 | return response.status(500).json({ error: 'Internal server error.' }); |
| @@ -189,7 +189,6 @@ router.post('/generate-voice', async (request, response) => { | ||
| 189 | 189 | response.setHeader('Content-Length', audioBytes.length); |
| 190 | 190 | |
| 191 | 191 | return response.send(Buffer.from(audioBytes)); |
| 192 | - | |
| 193 | 192 | } catch (conversionError) { |
| 194 | 193 | console.error('MiniMax TTS: Audio conversion error:', conversionError); |
| 195 | 194 | return response.status(500).json({ error: `Audio data conversion failed: ${conversionError.message}` }); |
| @@ -222,7 +221,6 @@ router.post('/generate-voice', async (request, response) => { | ||
| 222 | 221 | console.error('MiniMax TTS: No valid audio data in response:', responseData); |
| 223 | 222 | return response.status(500).json({ error: `API Error: ${errorMessage}` }); |
| 224 | 223 | } |
| 225 | - | |
| 226 | 224 | } catch (error) { |
| 227 | 225 | console.error('MiniMax TTS generation failed:', error); |
| 228 | 226 | return response.status(500).json({ error: 'Internal server error' }); |
| @@ -158,7 +158,6 @@ router.post('/samplers', async (request, response) => { | ||
| 158 | 158 | const data = await result.json(); |
| 159 | 159 | const names = data.map(x => x.name); |
| 160 | 160 | return response.send(names); |
| 161 | - | |
| 162 | 161 | } catch (error) { |
| 163 | 162 | console.error(error); |
| 164 | 163 | return response.sendStatus(500); |
| @@ -301,7 +301,6 @@ publicRouter.get('/', async function (request, response) { | ||
| 301 | 301 | |
| 302 | 302 | // Send a 404 so the frontend can display a placeholder |
| 303 | 303 | return response.sendStatus(404); |
| 304 | - | |
| 305 | 304 | } catch (error) { |
| 306 | 305 | console.error('Failed getting thumbnail', error); |
| 307 | 306 | return response.sendStatus(500); |
| @@ -118,7 +118,6 @@ export function postProcessPrompt(messages, type, names) { | ||
| 118 | 118 | * @copyright Prompt Conversion script taken from RisuAI by kwaroran (GPLv3). |
| 119 | 119 | */ |
| 120 | 120 | export function convertClaudePrompt(messages, addAssistantPostfix, addAssistantPrefill, withSysPromptSupport, useSystemPrompt, addSysHumanMsg, excludePrefixes) { |
| 121 | - | |
| 122 | 121 | //Prepare messages for claude. |
| 123 | 122 | //When 'Exclude Human/Assistant prefixes' checked, setting messages role to the 'system'(last message is exception). |
| 124 | 123 | if (messages.length > 0) { |
| @@ -1012,7 +1012,6 @@ export async function canResolve(name, useIPv6 = true, useIPv4 = true) { | ||
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | return v6Resolved || v4Resolved; |
| 1015 | - | |
| 1016 | 1015 | } catch (error) { |
| 1017 | 1016 | return false; |
| 1018 | 1017 | } |