mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into neo-server
This commit is contained in:
@@ -266,7 +266,7 @@ class BulkTagPopupHandler {
|
|||||||
printTagList($('#bulkTagList'), { tags: () => this.getMutualTags(), tagOptions: { removable: true } });
|
printTagList($('#bulkTagList'), { tags: () => this.getMutualTags(), tagOptions: { removable: true } });
|
||||||
|
|
||||||
// Tag input with resolvable list for the mutual tags to get redrawn, so that newly added tags get sorted correctly
|
// Tag input with resolvable list for the mutual tags to get redrawn, so that newly added tags get sorted correctly
|
||||||
createTagInput('#bulkTagInput', '#bulkTagList', { tags: () => this.getMutualTags(), tagOptions: { removable: true }});
|
createTagInput('#bulkTagInput', '#bulkTagList', { tags: () => this.getMutualTags(), tagOptions: { removable: true } });
|
||||||
|
|
||||||
document.querySelector('#bulk_tag_popup_reset').addEventListener('click', this.resetTags.bind(this));
|
document.querySelector('#bulk_tag_popup_reset').addEventListener('click', this.resetTags.bind(this));
|
||||||
document.querySelector('#bulk_tag_popup_remove_mutual').addEventListener('click', this.removeMutual.bind(this));
|
document.querySelector('#bulk_tag_popup_remove_mutual').addEventListener('click', this.removeMutual.bind(this));
|
||||||
@@ -291,7 +291,7 @@ class BulkTagPopupHandler {
|
|||||||
// Find mutual tags for multiple characters
|
// Find mutual tags for multiple characters
|
||||||
const allTags = this.characterIds.map(cid => getTagsList(getTagKeyForEntity(cid)));
|
const allTags = this.characterIds.map(cid => getTagsList(getTagKeyForEntity(cid)));
|
||||||
const mutualTags = allTags.reduce((mutual, characterTags) =>
|
const mutualTags = allTags.reduce((mutual, characterTags) =>
|
||||||
mutual.filter(tag => characterTags.some(cTag => cTag.id === tag.id))
|
mutual.filter(tag => characterTags.some(cTag => cTag.id === tag.id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.currentMutualTags = mutualTags.sort(compareTagsForSort);
|
this.currentMutualTags = mutualTags.sort(compareTagsForSort);
|
||||||
@@ -587,7 +587,7 @@ class BulkEditOverlay {
|
|||||||
this.container.removeEventListener('mouseup', cancelHold);
|
this.container.removeEventListener('mouseup', cancelHold);
|
||||||
this.container.removeEventListener('touchend', cancelHold);
|
this.container.removeEventListener('touchend', cancelHold);
|
||||||
},
|
},
|
||||||
BulkEditOverlay.longPressDelay);
|
BulkEditOverlay.longPressDelay);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleLongPressEnd = (event) => {
|
handleLongPressEnd = (event) => {
|
||||||
@@ -694,7 +694,7 @@ class BulkEditOverlay {
|
|||||||
} else {
|
} else {
|
||||||
character.classList.remove(BulkEditOverlay.selectedClass);
|
character.classList.remove(BulkEditOverlay.selectedClass);
|
||||||
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = false;
|
if (legacyBulkEditCheckbox) legacyBulkEditCheckbox.checked = false;
|
||||||
this.#selectedCharacters = this.#selectedCharacters.filter(item => String(characterId) !== item)
|
this.#selectedCharacters = this.#selectedCharacters.filter(item => String(characterId) !== item);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateSelectedCount();
|
this.updateSelectedCount();
|
||||||
@@ -816,7 +816,7 @@ class BulkEditOverlay {
|
|||||||
<span>Also delete the chat files</span>
|
<span>Also delete the chat files</span>
|
||||||
</label>
|
</label>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request user input before concurrently handle deletion
|
* Request user input before concurrently handle deletion
|
||||||
|
@@ -263,7 +263,7 @@ async function RA_autoloadchat() {
|
|||||||
await selectCharacterById(String(active_character_id));
|
await selectCharacterById(String(active_character_id));
|
||||||
|
|
||||||
// Do a little tomfoolery to spoof the tag selector
|
// Do a little tomfoolery to spoof the tag selector
|
||||||
const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`)
|
const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`);
|
||||||
applyTagsOnCharacterSelect.call(selectedCharElement);
|
applyTagsOnCharacterSelect.call(selectedCharElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,22 +44,29 @@ function isConvertible(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark message as hidden (system message).
|
* Mark a range of messages as hidden ("is_system") or not.
|
||||||
* @param {number} messageId Message ID
|
* @param {number} start Starting message ID
|
||||||
* @param {JQuery<Element>} messageBlock Message UI element
|
* @param {number} end Ending message ID (inclusive)
|
||||||
* @returns
|
* @param {boolean} unhide If true, unhide the messages instead.
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function hideChatMessage(messageId, messageBlock) {
|
export async function hideChatMessageRange(start, end, unhide) {
|
||||||
const chatId = getCurrentChatId();
|
if (!getCurrentChatId()) return;
|
||||||
|
|
||||||
if (!chatId || isNaN(messageId)) return;
|
if (isNaN(start)) return;
|
||||||
|
if (!end) end = start;
|
||||||
|
const hide = !unhide;
|
||||||
|
|
||||||
const message = chat[messageId];
|
for (let messageId = start; messageId <= end; messageId++) {
|
||||||
|
const message = chat[messageId];
|
||||||
|
if (!message) continue;
|
||||||
|
|
||||||
if (!message) return;
|
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
||||||
|
if (!messageBlock.length) continue;
|
||||||
|
|
||||||
message.is_system = true;
|
message.is_system = hide;
|
||||||
messageBlock.attr('is_system', String(true));
|
messageBlock.attr('is_system', String(hide));
|
||||||
|
}
|
||||||
|
|
||||||
// Reload swipes. Useful when a last message is hidden.
|
// Reload swipes. Useful when a last message is hidden.
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
@@ -69,28 +76,25 @@ export async function hideChatMessage(messageId, messageBlock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark message as visible (non-system message).
|
* Mark message as hidden (system message).
|
||||||
|
* @deprecated Use hideChatMessageRange.
|
||||||
* @param {number} messageId Message ID
|
* @param {number} messageId Message ID
|
||||||
* @param {JQuery<Element>} messageBlock Message UI element
|
* @param {JQuery<Element>} _messageBlock Unused
|
||||||
* @returns
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
export async function unhideChatMessage(messageId, messageBlock) {
|
export async function hideChatMessage(messageId, _messageBlock) {
|
||||||
const chatId = getCurrentChatId();
|
return hideChatMessageRange(messageId, messageId, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (!chatId || isNaN(messageId)) return;
|
/**
|
||||||
|
* Mark message as visible (non-system message).
|
||||||
const message = chat[messageId];
|
* @deprecated Use hideChatMessageRange.
|
||||||
|
* @param {number} messageId Message ID
|
||||||
if (!message) return;
|
* @param {JQuery<Element>} _messageBlock Unused
|
||||||
|
* @returns {Promise<void>}
|
||||||
message.is_system = false;
|
*/
|
||||||
messageBlock.attr('is_system', String(false));
|
export async function unhideChatMessage(messageId, _messageBlock) {
|
||||||
|
return hideChatMessageRange(messageId, messageId, true);
|
||||||
// Reload swipes. Useful when a last message is hidden.
|
|
||||||
hideSwipeButtons();
|
|
||||||
showSwipeButtons();
|
|
||||||
|
|
||||||
saveChatDebounced();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,13 +480,13 @@ jQuery(function () {
|
|||||||
$(document).on('click', '.mes_hide', async function () {
|
$(document).on('click', '.mes_hide', async function () {
|
||||||
const messageBlock = $(this).closest('.mes');
|
const messageBlock = $(this).closest('.mes');
|
||||||
const messageId = Number(messageBlock.attr('mesid'));
|
const messageId = Number(messageBlock.attr('mesid'));
|
||||||
await hideChatMessage(messageId, messageBlock);
|
await hideChatMessageRange(messageId, messageId, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.mes_unhide', async function () {
|
$(document).on('click', '.mes_unhide', async function () {
|
||||||
const messageBlock = $(this).closest('.mes');
|
const messageBlock = $(this).closest('.mes');
|
||||||
const messageId = Number(messageBlock.attr('mesid'));
|
const messageId = Number(messageBlock.attr('mesid'));
|
||||||
await unhideChatMessage(messageId, messageBlock);
|
await hideChatMessageRange(messageId, messageId, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.mes_file_delete', async function () {
|
$(document).on('click', '.mes_file_delete', async function () {
|
||||||
|
@@ -221,7 +221,7 @@ function onAlternativeClicked(tokenLogprobs, alternative) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getGeneratingApi() === 'openai') {
|
if (getGeneratingApi() === 'openai') {
|
||||||
return callPopup(`<h3>Feature unavailable</h3><p>Due to API limitations, rerolling a token is not supported with OpenAI. Try switching to a different API.</p>`, 'text');
|
return callPopup('<h3>Feature unavailable</h3><p>Due to API limitations, rerolling a token is not supported with OpenAI. Try switching to a different API.</p>', 'text');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { messageLogprobs, continueFrom } = getActiveMessageLogprobData();
|
const { messageLogprobs, continueFrom } = getActiveMessageLogprobData();
|
||||||
@@ -261,7 +261,7 @@ function onPrefixClicked() {
|
|||||||
|
|
||||||
function checkGenerateReady() {
|
function checkGenerateReady() {
|
||||||
if (is_send_press) {
|
if (is_send_press) {
|
||||||
toastr.warning(`Please wait for the current generation to complete.`);
|
toastr.warning('Please wait for the current generation to complete.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -292,13 +292,13 @@ function onToggleLogprobsPanel() {
|
|||||||
} else {
|
} else {
|
||||||
logprobsViewer.addClass('resizing');
|
logprobsViewer.addClass('resizing');
|
||||||
logprobsViewer.transition({
|
logprobsViewer.transition({
|
||||||
opacity: 0.0,
|
opacity: 0.0,
|
||||||
duration: animation_duration,
|
duration: animation_duration,
|
||||||
},
|
},
|
||||||
async function () {
|
async function () {
|
||||||
await delay(50);
|
await delay(50);
|
||||||
logprobsViewer.removeClass('resizing');
|
logprobsViewer.removeClass('resizing');
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
logprobsViewer.hide();
|
logprobsViewer.hide();
|
||||||
}, animation_duration);
|
}, animation_duration);
|
||||||
@@ -407,7 +407,7 @@ export function saveLogprobsForActiveMessage(logprobs, continueFrom) {
|
|||||||
messageLogprobs: logprobs,
|
messageLogprobs: logprobs,
|
||||||
continueFrom,
|
continueFrom,
|
||||||
hash: getMessageHash(chat[msgId]),
|
hash: getMessageHash(chat[msgId]),
|
||||||
}
|
};
|
||||||
|
|
||||||
state.messageLogprobs.set(data.hash, data);
|
state.messageLogprobs.set(data.hash, data);
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ function convertTokenIdLogprobsToText(input) {
|
|||||||
|
|
||||||
// Flatten unique token IDs across all logprobs
|
// Flatten unique token IDs across all logprobs
|
||||||
const tokenIds = Array.from(new Set(input.flatMap(logprobs =>
|
const tokenIds = Array.from(new Set(input.flatMap(logprobs =>
|
||||||
logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token)
|
logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
// Submit token IDs to tokenizer to get token text, then build ID->text map
|
// Submit token IDs to tokenizer to get token text, then build ID->text map
|
||||||
@@ -469,7 +469,7 @@ function convertTokenIdLogprobsToText(input) {
|
|||||||
input.forEach(logprobs => {
|
input.forEach(logprobs => {
|
||||||
logprobs.token = tokenIdText.get(logprobs.token);
|
logprobs.token = tokenIdText.get(logprobs.token);
|
||||||
logprobs.topLogprobs = logprobs.topLogprobs.map(([token, logprob]) =>
|
logprobs.topLogprobs = logprobs.topLogprobs.map(([token, logprob]) =>
|
||||||
[tokenIdText.get(token), logprob]
|
[tokenIdText.get(token), logprob],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -2264,7 +2264,7 @@ export class ChatCompletion {
|
|||||||
|
|
||||||
const shouldSquash = (message) => {
|
const shouldSquash = (message) => {
|
||||||
return !excludeList.includes(message.identifier) && message.role === 'system' && !message.name;
|
return !excludeList.includes(message.identifier) && message.role === 'system' && !message.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
if (shouldSquash(message)) {
|
if (shouldSquash(message)) {
|
||||||
if (lastMessage && shouldSquash(lastMessage)) {
|
if (lastMessage && shouldSquash(lastMessage)) {
|
||||||
|
@@ -38,7 +38,7 @@ import {
|
|||||||
this_chid,
|
this_chid,
|
||||||
} from '../script.js';
|
} from '../script.js';
|
||||||
import { getMessageTimeStamp } from './RossAscends-mods.js';
|
import { getMessageTimeStamp } from './RossAscends-mods.js';
|
||||||
import { hideChatMessage, unhideChatMessage } from './chats.js';
|
import { hideChatMessageRange } from './chats.js';
|
||||||
import { getContext, saveMetadataDebounced } from './extensions.js';
|
import { getContext, saveMetadataDebounced } from './extensions.js';
|
||||||
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
|
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
|
||||||
import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js';
|
import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js';
|
||||||
@@ -49,6 +49,7 @@ import { textgen_types, textgenerationwebui_settings } from './textgen-settings.
|
|||||||
import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCount } from './tokenizers.js';
|
import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCount } from './tokenizers.js';
|
||||||
import { delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
|
import { delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
|
||||||
import { registerVariableCommands, resolveVariable } from './variables.js';
|
import { registerVariableCommands, resolveVariable } from './variables.js';
|
||||||
|
import { background_settings } from './backgrounds.js';
|
||||||
export {
|
export {
|
||||||
executeSlashCommands, getSlashCommandsHelp, registerSlashCommand,
|
executeSlashCommands, getSlashCommandsHelp, registerSlashCommand,
|
||||||
};
|
};
|
||||||
@@ -916,16 +917,7 @@ async function hideMessageCallback(_, arg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let messageId = range.start; messageId <= range.end; messageId++) {
|
await hideChatMessageRange(range.start, range.end, false);
|
||||||
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
|
||||||
|
|
||||||
if (!messageBlock.length) {
|
|
||||||
console.warn(`WARN: No message found with ID ${messageId}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await hideChatMessage(messageId, messageBlock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unhideMessageCallback(_, arg) {
|
async function unhideMessageCallback(_, arg) {
|
||||||
@@ -941,17 +933,7 @@ async function unhideMessageCallback(_, arg) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let messageId = range.start; messageId <= range.end; messageId++) {
|
await hideChatMessageRange(range.start, range.end, true);
|
||||||
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
|
||||||
|
|
||||||
if (!messageBlock.length) {
|
|
||||||
console.warn(`WARN: No message found with ID ${messageId}`);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
await unhideChatMessage(messageId, messageBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1609,7 +1591,9 @@ $(document).on('click', '[data-displayHelp]', function (e) {
|
|||||||
|
|
||||||
function setBackgroundCallback(_, bg) {
|
function setBackgroundCallback(_, bg) {
|
||||||
if (!bg) {
|
if (!bg) {
|
||||||
return;
|
// allow reporting of the background name if called without args
|
||||||
|
// for use in ST Scripts via pipe
|
||||||
|
return background_settings.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Set background to ' + bg);
|
console.log('Set background to ' + bg);
|
||||||
|
@@ -516,7 +516,7 @@ llamacpp.post('/slots', jsonParser, async function (request, response) {
|
|||||||
const baseUrl = trimV1(request.body.server_url);
|
const baseUrl = trimV1(request.body.server_url);
|
||||||
|
|
||||||
let fetchResponse;
|
let fetchResponse;
|
||||||
if (request.body.action === "info") {
|
if (request.body.action === 'info') {
|
||||||
fetchResponse = await fetch(`${baseUrl}/slots`, {
|
fetchResponse = await fetch(`${baseUrl}/slots`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
@@ -525,16 +525,16 @@ llamacpp.post('/slots', jsonParser, async function (request, response) {
|
|||||||
if (!/^\d+$/.test(request.body.id_slot)) {
|
if (!/^\d+$/.test(request.body.id_slot)) {
|
||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
if (request.body.action !== "erase" && !request.body.filename) {
|
if (request.body.action !== 'erase' && !request.body.filename) {
|
||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchResponse = await fetch(`${baseUrl}/slots/${request.body.id_slot}?action=${request.body.action}`, {
|
fetchResponse = await fetch(`${baseUrl}/slots/${request.body.id_slot}?action=${request.body.action}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
filename: request.body.action !== "erase" ? `${request.body.filename}` : undefined,
|
filename: request.body.action !== 'erase' ? `${request.body.filename}` : undefined,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user