mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Better bookmark links
This commit is contained in:
@ -262,6 +262,10 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="textgenerationwebui_api-presets">
|
<div id="textgenerationwebui_api-presets">
|
||||||
|
<h3>Text generation presets</h3>
|
||||||
|
<select id="settings_preset_textgenerationwebui">
|
||||||
|
<option value="gui">Default</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
@ -1192,32 +1196,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="shadow_tips_popup">
|
|
||||||
<div id="tips_popup">
|
|
||||||
<img id="tips_cross" src="img/cross.png" style="position: absolute; margin-left: 230px; width: 20px; height: 20px; cursor: pointer; opacity: 0.6">
|
|
||||||
|
|
||||||
<img src="img/love.png" style="width: 45px;height: 45px; margin-bottom: 0px; opacity: 0.6;">
|
|
||||||
<div style="margin-top:20px; margin-left: 20px; margin-right: 20px; margin-bottom: 15px;">
|
|
||||||
<u>TavernAI</u> is being developed with love and care on a voluntary basis. If you like
|
|
||||||
the project and
|
|
||||||
want to support it, your donation would make a huge impact! <u>Thank you!</u>
|
|
||||||
</div>
|
|
||||||
<img src="img/eth_icon.png" style="width: 35px;height: 35px; margin-bottom: 0px; opacity: 0.6;">
|
|
||||||
<img src="img/usdt.png" style="width: 35px;height: 35px; margin-bottom: 0px; opacity: 0.6;">
|
|
||||||
<div id="tips_text">
|
|
||||||
<h3 style="margin-top: 0px; opacity: 0.8">Ethereum or USDT</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<img src="img/eth.png" style="opacity: 0.4; margin-bottom: 4px;">
|
|
||||||
<div>0x975E5C91042ce8168B3d37b17F99949c5eFB3Dfe</div>
|
|
||||||
<!--<div style="margin-bottom:5px;">***</div><div>TRX: TCiBKCt6xEGrsjpgQA2jDXWJLyUh1KN2Sn</div><div>BTC: 1LASziomyYNkZ2zk8Sa4ZLTkvczBMrjyjP</div>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- right nav panel for character/groups management/editing/creation -->
|
|
||||||
<!-- <input type="checkbox" id="nav-toggle"> -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- templates for JS to reuse when needed -->
|
<!-- templates for JS to reuse when needed -->
|
||||||
<div id="message_template">
|
<div id="message_template">
|
||||||
|
@ -67,7 +67,7 @@ import {
|
|||||||
nai_settings,
|
nai_settings,
|
||||||
} from "./scripts/nai-settings.js";
|
} from "./scripts/nai-settings.js";
|
||||||
|
|
||||||
import { debounce, delay } from "./scripts/utils.js";
|
import { debounce, delay, stringFormat } from "./scripts/utils.js";
|
||||||
|
|
||||||
//exporting functions and vars for mods
|
//exporting functions and vars for mods
|
||||||
export {
|
export {
|
||||||
@ -232,7 +232,7 @@ const system_messages = {
|
|||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
mes: `Bookmark created! Click here to open the bookmark chat: <a class="bookmark_link" file_name="{0}" href="javascript:void(null);">{0}</a>`,
|
mes: `Bookmark created! Click here to open the bookmark chat: <a class="bookmark_link" file_name="{0}" href="javascript:void(null);">{1}</a>`,
|
||||||
},
|
},
|
||||||
bookmark_back: {
|
bookmark_back: {
|
||||||
name: systemUserName,
|
name: systemUserName,
|
||||||
@ -240,7 +240,7 @@ const system_messages = {
|
|||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
mes: `Click here to return to the original chat: <a class="bookmark_link" file_name="{0}" href="javascript:void(null);">{0}</a>`,
|
mes: `Click here to return to the previous chat: <a class="bookmark_link" file_name="{0}" href="javascript:void(null);">Return</a>`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -706,6 +706,10 @@ function deleteLastMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
||||||
|
if (!mes) {
|
||||||
|
mes = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (this_chid != undefined && !isSystem)
|
if (this_chid != undefined && !isSystem)
|
||||||
mes = mes.replaceAll("<", "<").replaceAll(">", ">"); //for welcome message
|
mes = mes.replaceAll("<", "<").replaceAll(">", ">"); //for welcome message
|
||||||
if (this_chid === undefined) {
|
if (this_chid === undefined) {
|
||||||
@ -868,6 +872,12 @@ function sendSystemMessage(type, text) {
|
|||||||
newMessage.mes = text;
|
newMessage.mes = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!newMessage.extras) {
|
||||||
|
newMessage.extras = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
newMessage.extras.type = type;
|
||||||
|
|
||||||
chat.push(newMessage);
|
chat.push(newMessage);
|
||||||
addOneMessage(newMessage);
|
addOneMessage(newMessage);
|
||||||
is_send_press = false;
|
is_send_press = false;
|
||||||
@ -4061,17 +4071,28 @@ $(document).ready(function () {
|
|||||||
selectRightMenuWithAnimation('rm_extensions_block');
|
selectRightMenuWithAnimation('rm_extensions_block');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".select_chat_block, .bookmark_link", function () {
|
$(document).on("click", ".select_chat_block, .bookmark_link", async function () {
|
||||||
|
let originalChat = characters[this_chid]["chat"];
|
||||||
let file_name = $(this).attr("file_name").replace(".jsonl", "");
|
let file_name = $(this).attr("file_name").replace(".jsonl", "");
|
||||||
//console.log(characters[this_chid]['chat']);
|
//console.log(characters[this_chid]['chat']);
|
||||||
characters[this_chid]["chat"] = file_name;
|
characters[this_chid]["chat"] = file_name;
|
||||||
clearChat();
|
clearChat();
|
||||||
chat.length = 0;
|
chat.length = 0;
|
||||||
getChat();
|
await getChat();
|
||||||
$("#selected_chat_pole").val(file_name);
|
$("#selected_chat_pole").val(file_name);
|
||||||
$("#create_button").click();
|
$("#create_button").click();
|
||||||
$("#shadow_select_chat_popup").css("display", "none");
|
$("#shadow_select_chat_popup").css("display", "none");
|
||||||
$("#load_select_chat_div").css("display", "block");
|
$("#load_select_chat_div").css("display", "block");
|
||||||
|
|
||||||
|
// create "return back" message
|
||||||
|
/*if ($(this).hasClass('bookmark_link')) {
|
||||||
|
const existingMessageIndex = chat.findIndex(x => x.extras?.type === system_message_types.BOOKMARK_BACK);
|
||||||
|
|
||||||
|
if (existingMessageIndex === -1) {
|
||||||
|
const messageText = stringFormat(system_messages[system_message_types.BOOKMARK_BACK].mes, originalChat);
|
||||||
|
sendSystemMessage(system_message_types.BOOKMARK_BACK, messageText);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.drawer-toggle').click(function () {
|
$('.drawer-toggle').click(function () {
|
||||||
|
@ -30,17 +30,24 @@ async function getExistingChatNames() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBookmarkName() {
|
async function getBookmarkName(currentChat) {
|
||||||
|
const nameToken = 'Bookmark #';
|
||||||
|
if (currentChat.includes(nameToken)) {
|
||||||
|
currentChat = currentChat.substring(0, currentChat.lastIndexOf(nameToken)).trim();
|
||||||
|
}
|
||||||
|
|
||||||
const chatNames = await getExistingChatNames();
|
const chatNames = await getExistingChatNames();
|
||||||
let newChat = Date.now();
|
let newChat = Date.now();
|
||||||
|
let friendlyName = '';
|
||||||
|
|
||||||
for (let i = 0; i < 1000; i++) {
|
for (let i = 0; i < 1000; i++) {
|
||||||
newChat = `Bookmark - ${i}`;
|
friendlyName = `${nameToken}${i}`;
|
||||||
|
newChat = `${currentChat} ${friendlyName}`;
|
||||||
if (!chatNames.includes(newChat)) {
|
if (!chatNames.includes(newChat)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newChat;
|
return { newChat, friendlyName };
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@ -50,10 +57,10 @@ $(document).ready(function () {
|
|||||||
throw new Error('not yet implemented');
|
throw new Error('not yet implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
let newChat = await getBookmarkName();
|
let { newChat, friendlyName } = await getBookmarkName(characters[this_chid].chat);
|
||||||
|
|
||||||
saveChat(newChat);
|
saveChat(newChat);
|
||||||
let mainMessage = stringFormat(system_messages[system_message_types.BOOKMARK_CREATED].mes, newChat);
|
let mainMessage = stringFormat(system_messages[system_message_types.BOOKMARK_CREATED].mes, newChat, friendlyName);
|
||||||
sendSystemMessage(system_message_types.BOOKMARK_CREATED, mainMessage);
|
sendSystemMessage(system_message_types.BOOKMARK_CREATED, mainMessage);
|
||||||
saveChat();
|
saveChat();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user