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