mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Good night, sweet Chloe
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.1 MiB |
Binary file not shown.
Before Width: | Height: | Size: 561 KiB |
115
public/script.js
115
public/script.js
@ -25,53 +25,41 @@ export {
|
|||||||
window["TavernAI"] = {};
|
window["TavernAI"] = {};
|
||||||
|
|
||||||
const VERSION = "1.2.8";
|
const VERSION = "1.2.8";
|
||||||
var converter = new showdown.Converter({ emoji: "true" });
|
let converter = new showdown.Converter({ emoji: "true" });
|
||||||
var bg_menu_toggle = false;
|
let bg_menu_toggle = false;
|
||||||
const systemUserName = "TavernAI";
|
const systemUserName = "TavernAI";
|
||||||
const systemCharName = "Chloe";
|
let default_user_name = "You";
|
||||||
var default_user_name = "You";
|
let name1 = default_user_name;
|
||||||
var name1 = default_user_name;
|
let name2 = "TavernAI";
|
||||||
var name2 = "Chloe";
|
let chat = [];
|
||||||
// might want to migrate this to 'system message' code
|
let safetychat = [
|
||||||
var chat = [
|
|
||||||
{
|
{
|
||||||
name: "Chloe",
|
name: systemUserName,
|
||||||
is_user: false,
|
|
||||||
is_name: true,
|
|
||||||
create_date: 0,
|
|
||||||
mes:
|
|
||||||
"\n*You went inside. The air smelled of fried meat, tobacco and a hint of wine. A dim light was cast by candles, and a fire crackled in the fireplace. It seems to be a very pleasant place. Behind the wooden bar is an elf waitress, she is smiling. Her ears are very pointy, and there is a twinkle in her eye. She wears glasses and a white apron. As soon as she noticed you, she immediately came right up close to you.*\n\n" +
|
|
||||||
' "Hello there! How is your evening going?"<br><br>\n' +
|
|
||||||
'<img src="img/star_dust_city.png" width=80%; display:block;">\n',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
var safetychat = [
|
|
||||||
{
|
|
||||||
name: "Chloe",
|
|
||||||
is_user: false,
|
is_user: false,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
create_date: 0,
|
create_date: 0,
|
||||||
mes: "\n*You deleted a character/chat and arrived back here for safety reasons! Pick another character!*\n\n",
|
mes: "\n*You deleted a character/chat and arrived back here for safety reasons! Pick another character!*\n\n",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
var chat_create_date = 0;
|
let chat_create_date = 0;
|
||||||
|
|
||||||
let prev_selected_char = null;
|
let prev_selected_char = null;
|
||||||
var default_ch_mes = "Hello";
|
let default_ch_mes = "Hello";
|
||||||
var count_view_mes = 0;
|
let count_view_mes = 0;
|
||||||
var mesStr = "";
|
let mesStr = "";
|
||||||
var generatedPromtCache = "";
|
let generatedPromtCache = "";
|
||||||
var characters = [];
|
let characters = [];
|
||||||
let groups = [];
|
let groups = [];
|
||||||
let selected_group = null;
|
let selected_group = null;
|
||||||
let is_group_automode_enabled = false;
|
let is_group_automode_enabled = false;
|
||||||
var this_chid;
|
let this_chid;
|
||||||
var active_character;
|
let active_character;
|
||||||
var backgrounds = [];
|
let backgrounds = [];
|
||||||
var default_avatar = "img/fluffy.png";
|
const default_avatar = "img/fluffy.png";
|
||||||
var is_colab = false;
|
const system_avatar = "img/five.png";
|
||||||
var is_checked_colab = false;
|
let is_colab = false;
|
||||||
var is_mes_reload_avatar = false;
|
let is_checked_colab = false;
|
||||||
|
let is_mes_reload_avatar = false;
|
||||||
let collapse_newlines = false;
|
let collapse_newlines = false;
|
||||||
|
|
||||||
const system_message_types = {
|
const system_message_types = {
|
||||||
@ -85,15 +73,25 @@ const system_message_types = {
|
|||||||
const system_messages = {
|
const system_messages = {
|
||||||
help: {
|
help: {
|
||||||
name: systemUserName,
|
name: systemUserName,
|
||||||
force_avatar: "img/five.png",
|
force_avatar: system_avatar,
|
||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
mes: 'Hi there! The following chat formatting commands are supported:<br><ul><li><tt>*text*</tt> – format the actions that your character does</li><li><tt>{*text*}</tt> – set the behavioral bias for your character</li></ul><p>Need more help? Visit our wiki – <a href="https://github.com/TavernAI/TavernAI/wiki">TavernAI Wiki</a>!</p>',
|
mes: 'Hi there! The following chat formatting commands are supported:<br><ul><li><tt>*text*</tt> – format the actions that your character does</li><li><tt>{*text*}</tt> – set the behavioral bias for your character</li></ul><p>Need more help? Visit our wiki – <a target="_blank" href="https://github.com/TavernAI/TavernAI/wiki">TavernAI Wiki</a>!</p>',
|
||||||
|
},
|
||||||
|
welcome:
|
||||||
|
{
|
||||||
|
name: systemUserName,
|
||||||
|
force_avatar: system_avatar,
|
||||||
|
is_user: false,
|
||||||
|
is_name: true,
|
||||||
|
mes:
|
||||||
|
'Hello there! In order to begin chatting:<ol><li>Connect to one of the supported generation APIs</li><li>Create or pick a character from the list</li></ol>' +
|
||||||
|
'Still have questions left? Check out built-in help or visit our <a target="_blank" href="https://github.com/TavernAI/TavernAI/wiki">TavernAI Wiki</a>!'
|
||||||
},
|
},
|
||||||
group: {
|
group: {
|
||||||
name: systemUserName,
|
name: systemUserName,
|
||||||
force_avatar: "img/five.png",
|
force_avatar: system_avatar,
|
||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
@ -101,7 +99,7 @@ const system_messages = {
|
|||||||
},
|
},
|
||||||
empty: {
|
empty: {
|
||||||
name: systemUserName,
|
name: systemUserName,
|
||||||
force_avatar: "img/five.png",
|
force_avatar: system_avatar,
|
||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
@ -109,7 +107,7 @@ const system_messages = {
|
|||||||
},
|
},
|
||||||
generic: {
|
generic: {
|
||||||
name: systemUserName,
|
name: systemUserName,
|
||||||
force_avatar: "img/five.png",
|
force_avatar: system_avatar,
|
||||||
is_user: false,
|
is_user: false,
|
||||||
is_system: true,
|
is_system: true,
|
||||||
is_name: true,
|
is_name: true,
|
||||||
@ -269,22 +267,11 @@ $.get("/csrf-token").then((data) => {
|
|||||||
getCharacters();
|
getCharacters();
|
||||||
getSettings("def");
|
getSettings("def");
|
||||||
getLastVersion();
|
getLastVersion();
|
||||||
//getCharacters();
|
sendSystemMessage(system_message_types.WELCOME);
|
||||||
printMessages();
|
|
||||||
getBackgrounds();
|
getBackgrounds();
|
||||||
getUserAvatars();
|
getUserAvatars();
|
||||||
});
|
});
|
||||||
|
|
||||||
function flushSettings() {
|
|
||||||
$("#settings_perset").empty();
|
|
||||||
$("#settings_perset_novel").empty();
|
|
||||||
$("#world_info").empty();
|
|
||||||
$("#settings_perset").append(
|
|
||||||
'<option value="gui">GUI KoboldAI Settings</option>'
|
|
||||||
);
|
|
||||||
$("#world_info").append('<option value="None">None</option>');
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkOnlineStatus() {
|
function checkOnlineStatus() {
|
||||||
//console.log(online_status);
|
//console.log(online_status);
|
||||||
if (online_status == "no_connection") {
|
if (online_status == "no_connection") {
|
||||||
@ -758,7 +745,7 @@ function clearChat() {
|
|||||||
|
|
||||||
function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
||||||
if (this_chid != undefined && !isSystem)
|
if (this_chid != undefined && !isSystem)
|
||||||
mes = mes.replaceAll("<", "<").replaceAll(">", ">"); //for Chloe
|
mes = mes.replaceAll("<", "<").replaceAll(">", ">"); //for *****
|
||||||
if (this_chid === undefined) {
|
if (this_chid === undefined) {
|
||||||
mes = mes
|
mes = mes
|
||||||
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
||||||
@ -805,7 +792,7 @@ function addOneMessage(mes) {
|
|||||||
if (mes.force_avatar) {
|
if (mes.force_avatar) {
|
||||||
avatarImg = mes.force_avatar;
|
avatarImg = mes.force_avatar;
|
||||||
} else if (this_chid == undefined || this_chid == "invalid-safety-id") {
|
} else if (this_chid == undefined || this_chid == "invalid-safety-id") {
|
||||||
avatarImg = "img/chloe.png";
|
avatarImg = "img/five.png";
|
||||||
} else {
|
} else {
|
||||||
if (characters[this_chid].avatar != "none") {
|
if (characters[this_chid].avatar != "none") {
|
||||||
avatarImg = "characters/" + characters[this_chid].avatar;
|
avatarImg = "characters/" + characters[this_chid].avatar;
|
||||||
@ -814,7 +801,7 @@ function addOneMessage(mes) {
|
|||||||
//console.log(avatarImg);
|
//console.log(avatarImg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
avatarImg = "img/fluffy.png";
|
avatarImg = default_avatar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1804,7 +1791,7 @@ async function Generate(type, automatic_trigger) {
|
|||||||
chat[chat.length - 1]["mes"] = getMessage;
|
chat[chat.length - 1]["mes"] = getMessage;
|
||||||
|
|
||||||
if (type === "group_chat") {
|
if (type === "group_chat") {
|
||||||
let avatarImg = "img/fluffy.png";
|
let avatarImg = default_avatars;
|
||||||
if (characters[this_chid].avatar != "none") {
|
if (characters[this_chid].avatar != "none") {
|
||||||
avatarImg = `characters/${characters[this_chid].avatar
|
avatarImg = `characters/${characters[this_chid].avatar
|
||||||
}?${Date.now()}`;
|
}?${Date.now()}`;
|
||||||
@ -2138,11 +2125,11 @@ async function getGroupChat(id) {
|
|||||||
mes["send_date"] = humanizedDateTime();
|
mes["send_date"] = humanizedDateTime();
|
||||||
mes["mes"] = character.first_mes
|
mes["mes"] = character.first_mes
|
||||||
? substituteParams(character.first_mes.trim())
|
? substituteParams(character.first_mes.trim())
|
||||||
: (mes["mes"] = default_ch_mes);
|
: default_ch_mes;
|
||||||
mes["force_avatar"] =
|
mes["force_avatar"] =
|
||||||
character.avatar != "none"
|
character.avatar != "none"
|
||||||
? `characters/${character.avatar}?${Date.now()}`
|
? `characters/${character.avatar}?${Date.now()}`
|
||||||
: "img/fluffy.png";
|
: default_avatar;
|
||||||
chat.push(mes);
|
chat.push(mes);
|
||||||
addOneMessage(mes);
|
addOneMessage(mes);
|
||||||
}
|
}
|
||||||
@ -2194,8 +2181,8 @@ async function deleteGroup(id) {
|
|||||||
this_chid = "invalid-safety-id"; //unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)
|
this_chid = "invalid-safety-id"; //unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)
|
||||||
selected_group = null;
|
selected_group = null;
|
||||||
characters.length = 0; // resets the characters array, forcing getcharacters to reset
|
characters.length = 0; // resets the characters array, forcing getcharacters to reset
|
||||||
name2 = "Chloe"; // replaces deleted charcter name with Chloe, since she wil be displayed next.
|
name2 = systemUserName; // replaces deleted charcter name with *****, since she wil be displayed next.
|
||||||
chat = [...safetychat]; // sets up chloe to tell user about having deleted a character
|
chat = [...safetychat]; // sets up ***** to tell user about having deleted a character
|
||||||
|
|
||||||
/* QuickRefresh(); */
|
/* QuickRefresh(); */
|
||||||
$("#rm_info_avatar").html("");
|
$("#rm_info_avatar").html("");
|
||||||
@ -4041,10 +4028,10 @@ $(document).ready(function () {
|
|||||||
//this allows for dynamic refresh of character list after deleting a character.
|
//this allows for dynamic refresh of character list after deleting a character.
|
||||||
$("#character_cross").click(); // closes advanced editing popup
|
$("#character_cross").click(); // closes advanced editing popup
|
||||||
this_chid = "invalid-safety-id"; // unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)
|
this_chid = "invalid-safety-id"; // unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)
|
||||||
//avatar = "..img/Chloe.jpg";
|
//avatar = "..img/*****.jpg";
|
||||||
characters.length = 0; // resets the characters array, forcing getcharacters to reset
|
characters.length = 0; // resets the characters array, forcing getcharacters to reset
|
||||||
name2 = "Chloe"; // replaces deleted charcter name with Chloe, since she will be displayed next.
|
name2 = systemUserName; // replaces deleted charcter name with *****, since she will be displayed next.
|
||||||
chat = [...safetychat]; // sets up chloe to tell user about having deleted a character
|
chat = [...safetychat]; // sets up ***** to tell user about having deleted a character
|
||||||
$(document.getElementById("rm_button_selected_ch")).css(
|
$(document.getElementById("rm_button_selected_ch")).css(
|
||||||
"class",
|
"class",
|
||||||
"deselected-right-tab"
|
"deselected-right-tab"
|
||||||
@ -4055,7 +4042,7 @@ $(document).ready(function () {
|
|||||||
clearChat(); // removes deleted char's chat
|
clearChat(); // removes deleted char's chat
|
||||||
this_chid = undefined; // prevents getCharacters from trying to load an invalid char.
|
this_chid = undefined; // prevents getCharacters from trying to load an invalid char.
|
||||||
getCharacters(); // gets the new list of characters (that doesn't include the deleted one)
|
getCharacters(); // gets the new list of characters (that doesn't include the deleted one)
|
||||||
printMessages(); // prints out Chloe's 'deleted character' message
|
printMessages(); // prints out *****'s 'deleted character' message
|
||||||
//console.log("#dialogue_popup_ok(del-char) >>>> saving");
|
//console.log("#dialogue_popup_ok(del-char) >>>> saving");
|
||||||
saveSettings(); // saving settings to keep changes to variables
|
saveSettings(); // saving settings to keep changes to variables
|
||||||
//getCharacters();
|
//getCharacters();
|
||||||
@ -4367,7 +4354,7 @@ $(document).ready(function () {
|
|||||||
$("#delete_button").click(function () {
|
$("#delete_button").click(function () {
|
||||||
popup_type = "del_ch";
|
popup_type = "del_ch";
|
||||||
callPopup(
|
callPopup(
|
||||||
"<h3>Delete the character?</h3>Page will reload and you will be returned to Chloe."
|
"<h3>Delete the character?</h3>Your chat will be closed."
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$("#rm_info_button").click(function () {
|
$("#rm_info_button").click(function () {
|
||||||
|
Reference in New Issue
Block a user