mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 19:37:46 +01:00
Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging
This commit is contained in:
commit
a1bdaf2739
@ -2991,8 +2991,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
return;
|
||||
}
|
||||
|
||||
hideStopButton();
|
||||
is_send_press = false;
|
||||
if (!data.error) {
|
||||
//const getData = await response.json();
|
||||
let getMessage = extractMessageFromData(data);
|
||||
@ -3113,6 +3111,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
}
|
||||
if (generatedTextFiltered(getMessage)) {
|
||||
console.debug('swiping right automatically');
|
||||
is_send_press = false;
|
||||
swipe_right();
|
||||
return
|
||||
}
|
||||
@ -3132,7 +3131,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
}
|
||||
console.debug('/savechat called by /Generate');
|
||||
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
is_send_press = false;
|
||||
hideStopButton();
|
||||
activateSendButtons();
|
||||
showSwipeButtons();
|
||||
setGenerationProgress(0);
|
||||
@ -6113,7 +6114,7 @@ async function deleteMessageImage() {
|
||||
delete message.extra.inline_image;
|
||||
mesBlock.find('.mes_img_container').removeClass('img_extra');
|
||||
mesBlock.find('.mes_img').attr('src', '');
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
function enlargeMessageImage() {
|
||||
@ -7908,7 +7909,7 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
//confirms message deletion with the "ok" button
|
||||
$("#dialogue_del_mes_ok").click(function () {
|
||||
$("#dialogue_del_mes_ok").click(async function () {
|
||||
$("#dialogue_del_mes").css("display", "none");
|
||||
$("#send_form").css("display", css_send_form_display);
|
||||
$(".del_checkbox").each(function () {
|
||||
@ -7924,7 +7925,7 @@ $(document).ready(function () {
|
||||
$(".mes[mesid='" + this_del_mes + "']").remove();
|
||||
chat.length = this_del_mes;
|
||||
count_view_mes = this_del_mes;
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
var $textchat = $("#chat");
|
||||
$textchat.scrollTop($textchat[0].scrollHeight);
|
||||
eventSource.emit(event_types.MESSAGE_DELETED, chat.length);
|
||||
@ -8199,7 +8200,7 @@ $(document).ready(function () {
|
||||
this_edit_mes_id = undefined;
|
||||
});
|
||||
|
||||
$(document).on("click", ".mes_edit_up", function () {
|
||||
$(document).on("click", ".mes_edit_up", async function () {
|
||||
if (is_send_press || this_edit_mes_id <= 0) {
|
||||
return;
|
||||
}
|
||||
@ -8224,11 +8225,11 @@ $(document).ready(function () {
|
||||
|
||||
this_edit_mes_id = targetId;
|
||||
updateViewMessageIds();
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
showSwipeButtons();
|
||||
});
|
||||
|
||||
$(document).on("click", ".mes_edit_down", function () {
|
||||
$(document).on("click", ".mes_edit_down", async function () {
|
||||
if (is_send_press || this_edit_mes_id >= chat.length - 1) {
|
||||
return;
|
||||
}
|
||||
@ -8253,7 +8254,7 @@ $(document).ready(function () {
|
||||
|
||||
this_edit_mes_id = targetId;
|
||||
updateViewMessageIds();
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
showSwipeButtons();
|
||||
});
|
||||
|
||||
@ -8277,14 +8278,14 @@ $(document).ready(function () {
|
||||
addOneMessage(clone, { insertAfter: this_edit_mes_id });
|
||||
|
||||
updateViewMessageIds();
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
$('#chat')[0].scrollTop = oldScroll;
|
||||
showSwipeButtons();
|
||||
});
|
||||
|
||||
$(document).on("click", ".mes_edit_delete", async function (event, customData) {
|
||||
const fromSlashCommand = customData?.fromSlashCommand || false;
|
||||
const swipeExists = (!chat[this_edit_mes_id].swipes || chat[this_edit_mes_id].swipes.length <= 1 || chat.is_user || parseInt(this_edit_mes_id) !== chat.length - 1);
|
||||
const swipeExists = (!Array.isArray(chat[this_edit_mes_id].swipes) || chat[this_edit_mes_id].swipes.length <= 1 || chat[this_edit_mes_id].is_user || parseInt(this_edit_mes_id) !== chat.length - 1);
|
||||
if (power_user.confirm_message_delete && fromSlashCommand !== true) {
|
||||
const confirmation = swipeExists ? await callPopup("Are you sure you want to delete this message?", 'confirm')
|
||||
: await callPopup("<h3>Delete this...</h3> <select id='del_type'><option value='swipe'>Swipe</option><option value='message'>Message</option></select>", 'confirm')
|
||||
@ -8316,7 +8317,7 @@ $(document).ready(function () {
|
||||
this_edit_mes_id = undefined;
|
||||
|
||||
updateViewMessageIds();
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
|
||||
eventSource.emit(event_types.MESSAGE_DELETED, count_view_mes);
|
||||
|
||||
|
@ -217,6 +217,10 @@ async function translateProviderDeepl(text, lang) {
|
||||
|
||||
async function translate(text, lang) {
|
||||
try {
|
||||
if (text == '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch (extension_settings.translate.provider) {
|
||||
case 'google':
|
||||
return await translateProviderGoogle(text, lang);
|
||||
|
@ -128,8 +128,8 @@ function loadNovelPreset(preset) {
|
||||
function loadNovelSettings(settings) {
|
||||
//load the rest of the Novel settings without any checks
|
||||
nai_settings.model_novel = settings.model_novel;
|
||||
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
|
||||
$('#model_novel_select').val(nai_settings.model_novel);
|
||||
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
|
||||
|
||||
if (settings.nai_preamble !== undefined) {
|
||||
nai_settings.preamble = settings.nai_preamble;
|
||||
|
@ -1647,6 +1647,11 @@ class ChatCompletion {
|
||||
const index = this.findMessageIndex(identifier);
|
||||
const message = this.messages.collection[index].collection.pop();
|
||||
|
||||
if (!message) {
|
||||
this.log(`No message to remove from ${identifier}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.increaseTokenBudgetBy(message.getTokens());
|
||||
|
||||
this.log(`Removed ${message.identifier} from ${identifier}. Remaining tokens: ${this.tokenBudget}`);
|
||||
@ -2542,6 +2547,7 @@ function getMaxContextWindowAI(value) {
|
||||
}
|
||||
|
||||
async function onModelChange() {
|
||||
biasCache = undefined;
|
||||
let value = String($(this).val());
|
||||
|
||||
if ($(this).is('#model_claude_select')) {
|
||||
|
@ -282,11 +282,11 @@ function setNameCallback(_, name) {
|
||||
setUserName(name); //this prevented quickReply usage
|
||||
}
|
||||
|
||||
function setNarratorName(_, text) {
|
||||
async function setNarratorName(_, text) {
|
||||
const name = text || NARRATOR_NAME_DEFAULT;
|
||||
chat_metadata[NARRATOR_NAME_KEY] = name;
|
||||
toastr.info(`System narrator name set to ${name}`);
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
async function sendMessageAs(_, text) {
|
||||
@ -341,7 +341,7 @@ async function sendMessageAs(_, text) {
|
||||
await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||
addOneMessage(message);
|
||||
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1));
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
async function sendNarratorMessage(_, text) {
|
||||
@ -373,7 +373,7 @@ async function sendNarratorMessage(_, text) {
|
||||
await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||
addOneMessage(message);
|
||||
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1));
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
async function sendCommentMessage(_, text) {
|
||||
@ -399,7 +399,7 @@ async function sendCommentMessage(_, text) {
|
||||
await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
|
||||
addOneMessage(message);
|
||||
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1));
|
||||
saveChatConditional();
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
function helpCommandCallback(_, type) {
|
||||
|
@ -134,7 +134,7 @@ export function getTokenCount(str, padding = undefined) {
|
||||
|
||||
const cacheObject = getTokenCacheObject();
|
||||
const hash = getStringHash(str);
|
||||
const cacheKey = `${tokenizerType}-${hash}`;
|
||||
const cacheKey = `${tokenizerType}-${hash}+${padding}`;
|
||||
|
||||
if (typeof cacheObject[cacheKey] === 'number') {
|
||||
return cacheObject[cacheKey];
|
||||
|
@ -202,6 +202,10 @@ table.responsiveTable {
|
||||
color: var(--white50a);
|
||||
}
|
||||
|
||||
.mes[is_system="true"] .mes_text br {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mes_text table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
|
Loading…
x
Reference in New Issue
Block a user