diff --git a/public/User Avatars/you1.png b/public/User Avatars/you1.png deleted file mode 100644 index e241153a4..000000000 Binary files a/public/User Avatars/you1.png and /dev/null differ diff --git a/public/characters/Aqua.png b/public/characters/Aqua.png index 6da8e87e1..96997c06e 100644 Binary files a/public/characters/Aqua.png and b/public/characters/Aqua.png differ diff --git a/public/characters/Darkness.png b/public/characters/Darkness.png index e3aea3fd2..85106e240 100644 Binary files a/public/characters/Darkness.png and b/public/characters/Darkness.png differ diff --git a/public/index.html b/public/index.html index 0df7c3cf0..913eb9679 100644 --- a/public/index.html +++ b/public/index.html @@ -45,18 +45,10 @@ const systemCharName = 'Chloe'; var default_user_name = "You"; var name1 = default_user_name; - var name2 = systemCharName; + var name2 = "Chloe"; // might want to migrate this to 'system message' code - var chat = [{ - name: systemCharName, - 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?"

\n' + - '\n' - }]; - + var chat = [{name: 'Chloe',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?"

\n'+'\n'}]; + var safetychat = [{name: 'Chloe',is_user: false,is_name: true,create_date: 0,mes: '\n*You deleted a charcter and arrived back here for safety reasons! Pick another character!*\n\n'}]; var chat_create_date = 0; //RossAscends: Added function to format dates used in files and chat timestamps to a humanized format. @@ -66,15 +58,18 @@ //New chats made with characters will use this new formatting. //Useable variable is (( humanizedISO8601Datetime )) - var baseDate = new Date(Date.now()); - var humanYear = baseDate.getFullYear(); - var humanMonth = (baseDate.getMonth()+1); - var humanDate = baseDate.getDate(); - var humanHour = (baseDate.getHours() < 10? '0' : '') + baseDate.getHours(); - var humanMinute = (baseDate.getMinutes() < 10? '0' : '') + baseDate.getMinutes(); - var humanSecond = (baseDate.getSeconds() < 10? '0' : '') + baseDate.getSeconds(); - var humanMillisecond = (baseDate.getMilliseconds() < 10? '0' : '') + baseDate.getMilliseconds(); - var humanizedISO8601DateTime = (humanYear+"-"+humanMonth+"-"+humanDate+" @"+humanHour+"h "+humanMinute+"m "+humanSecond+"s "+humanMillisecond+"ms"); + function humanizedISO8601DateTime() { + let baseDate = new Date(Date.now()); + let humanYear = baseDate.getFullYear(); + let humanMonth = (baseDate.getMonth()+1); + let humanDate = baseDate.getDate(); + let humanHour = (baseDate.getHours() < 10? '0' : '') + baseDate.getHours(); + let humanMinute = (baseDate.getMinutes() < 10? '0' : '') + baseDate.getMinutes(); + let humanSecond = (baseDate.getSeconds() < 10? '0' : '') + baseDate.getSeconds(); + let humanMillisecond = (baseDate.getMilliseconds() < 10? '0' : '') + baseDate.getMilliseconds(); + let HumanizedDateTime = (humanYear+"-"+humanMonth+"-"+humanDate+" @"+humanHour+"h "+humanMinute+"m "+humanSecond+"s "+humanMillisecond+"ms"); + return HumanizedDateTime; + }; var default_ch_mes = "Hello"; @@ -86,6 +81,7 @@ let selected_group = null; let is_group_automode_enabled = false; var this_chid; + var active_character; var backgrounds = []; var default_avatar = 'img/fluffy.png'; var is_colab = false; @@ -208,6 +204,8 @@ var style_anchor = true; var character_anchor = true; let extension_prompt = ''; + var auto_connect = false; + var auto_load_chat = false; var main_api = 'kobold'; //novel settings @@ -256,21 +254,46 @@ xhr.setRequestHeader("X-CSRF-Token", token); }); + $.get("/csrf-token") .then(data => { token = data.token; + getCharacters(); getSettings("def"); getLastVersion(); - getCharacters(); - + //getCharacters(); printMessages(); getBackgrounds(); getUserAvatars(); + autoloadchat(); + autoconnect(); }); + + function flushSettings() { + $('#settings_perset').empty(); + $('#world_info').empty(); + $('#world_info').append(''); + } + + //RossAscends: a smaller load-up function to be used instead of refreshing the page in cases like deleting a character and changing username + function QuickRefresh(){ + flushSettings(); + clearChat(); + //characters.length = 0 //if this could be enabled it would allow the GetCharacters function to detect files added or removed from the char dir on each panel load + console.log('quickRefresh() -- active_character -- '+active_character); + console.log('quickRefresh() -- this_chid -- '+this_chid); + getSettings("def"); + getCharacters(); + getUserAvatars(); + //console.log(chat); + printMessages(); + $( "#rm_button_selected_ch" ).css("class","deselected-right-tab"); + $( "#rm_button_selected_ch" ).children("h2").text(''); + if (NavToggle.checked === false) { + document.getElementById('nav-toggle').click(); + }; + } - $('#characloud_url').click(function(){ - window.open('https://boosty.to/tavernai', '_blank'); - }); $('#character_search_bar').on('input', function() { const searchValue = $(this).val().trim().toLowerCase(); @@ -284,6 +307,10 @@ }); } }); + + $('#characloud_url').click(function(){ + window.open('https://boosty.to/tavernai', '_blank'); + }); function checkOnlineStatus(){ //console.log(online_status); if(online_status == 'no_connection'){ @@ -394,7 +421,6 @@ } } } - function resultCheckStatus(){ is_api_button_press = false; checkOnlineStatus(); @@ -461,18 +487,22 @@ } function printCharacters(){ - //console.log(1); + //console.log('printCharacters() entered'); + $("#rm_print_characters_block").empty(); + console.log('printCharacters() -- sees '+characters.length+' characters.'); characters.forEach(function(item, i, arr) { + var this_avatar = default_avatar; if(item.avatar != 'none'){ this_avatar = "characters/"+item.avatar+"?"+Date.now(); - } - $("#rm_print_characters_block").prepend('
'+item.name+'
'); - //console.log(item.name); + } //RossAscends: changed 'prepend' to 'append' to make alphabetical sorting display correctly. + $("#rm_print_characters_block").append('
'+item.name+'
'); + console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')'); }); printGroups(); + } function printGroups() { @@ -550,7 +580,9 @@ async function getCharacters() { await getGroups(); - const response = await fetch("/getcharacters", { + //console.log('getCharacters() -- entered'); + //console.log(characters); + var response = await fetch("/getcharacters", { //RossAscends: changed from const method: "POST", headers: { "Content-Type": "application/json", @@ -559,26 +591,44 @@ body: JSON.stringify({                      "": ""                  }) - }); if (response.ok === true) { - const getData = await response.json(); - //console.log(getData); + + var getData = ''; //RossAscends: reset to force array to update to account for deleted character. + var getData = await response.json(); //RossAscends: changed from const + //console.log(getData); + //var aa = JSON.parse(getData[0]); - const load_ch_count = Object.getOwnPropertyNames(getData); + var load_ch_count = Object.getOwnPropertyNames(getData); //RossAscends: change from const to create dynamic character load amounts. + var charCount = load_ch_count.length; + //console.log('/getcharacters -- expecting to load '+charCount+' characters.') for(var i = 0; i < load_ch_count.length;i++){ - - //characters[i] = []; + characters[i] = []; characters[i] = getData[i]; - - //console.log(characters[i]); + //console.log('/getcharacters -- loaded character #'+(i+1)+' ('+characters[i].name+')'); } - characters.sort((a,b) => a.create_date - b.create_date ); + //RossAscends: updated character sorting to be alphabetical + characters.sort(function (a,b) { + //console.log('sorting characters: '+a.name+' vs '+b.name); + if(a.name < b.name){ + return -1 + } + if (a.name > b.name) { + return 1; + } + return 0; + + }); + //console.log(characters); + //characters.reverse(); - if(this_chid != undefined) $("#avatar_url_pole").val(characters[this_chid].avatar); + //console.log('/getcharacters -- this_chid -- '+this_chid); + if(this_chid != undefined && this_chid != 'invalid-safety-id') $("#avatar_url_pole").val(characters[this_chid].avatar); + //console.log('/getcharacters -- sending '+i+' characters to /printcharacters'); printCharacters(); - //console.log(propOwn.length); + + //console.log(propOwn.length); //return JSON.parse(getData[0]); //const getData = await response.json(); //var getMessage = getData.results[0].text; @@ -611,7 +661,7 @@ } } - async function isColab() { + async function isColab() { is_checked_colab = true; const response = await fetch("/iscolab", { method: "POST", @@ -705,7 +755,9 @@ } } function printMessages(){ - chat.forEach(function(item, i, arr) { + //console.log(chat); + //console.log('printMessages() -- printing messages for -- '+this_chid+' '+active_character+' '+characters[this_chid]); + chat.forEach(function(item, i, arr) { addOneMessage(item); }); } @@ -758,7 +810,7 @@ if (mes.force_avatar) { avatarImg = mes.force_avatar; } - else if(this_chid == undefined){ + else if(this_chid == undefined || this_chid == "invalid-safety-id"){ avatarImg = "img/chloe.png"; } else{ @@ -1041,7 +1093,7 @@ chat[chat.length-1]['name'] = name1; chat[chat.length-1]['is_user'] = true; chat[chat.length-1]['is_name'] = true; - chat[chat.length-1]['send_date'] = Date.now(); + chat[chat.length-1]['send_date'] = humanizedISO8601DateTime(); chat[chat.length-1]['mes'] = textareaText; chat[chat.length-1]['extra'] = {}; @@ -1498,7 +1550,7 @@ chat[chat.length-1]['name'] = name2; chat[chat.length-1]['is_user'] = false; chat[chat.length-1]['is_name'] = this_mes_is_name; - chat[chat.length-1]['send_date'] = Date.now(); + chat[chat.length-1]['send_date'] = humanizedISO8601DateTime(); getMessage = $.trim(getMessage); chat[chat.length-1]['mes'] = getMessage; @@ -1520,6 +1572,8 @@ } else { saveChat(); } + //console.log('/savechat called by /Generate'); + saveChat(); }else{ //console.log('run force_name2 protocol'); Generate('force_name2'); @@ -1549,7 +1603,6 @@ is_send_press = false; } } - async function saveChat() { chat.forEach(function(item, i) { if(item['is_user']){ @@ -1580,7 +1633,7 @@ }); } async function getChat() { - //console.log(characters[this_chid].chat); + console.log('/getchat -- entered for -- '+characters[this_chid].name); jQuery.ajax({ type: 'POST', url: '/getchat', @@ -1600,13 +1653,16 @@ } //chat = data; chat_create_date = chat[0]['create_date']; + //console.log('/getchat saw chat_create_date: '+chat_create_date); chat.shift(); }else{ - chat_create_date = Date.now(); + chat_create_date = humanizedISO8601DateTime(); } //console.log(chat); + //console.log('getChatResults called by /getchat'); getChatResult(); + //console.log('savechat called by /getchat'); saveChat(); }, error: function (jqXHR, exception) { @@ -1616,7 +1672,6 @@ } }); } - function getChatResult(){ name2 = characters[this_chid].name; if(chat.length > 1){ @@ -1636,7 +1691,7 @@ chat[0]['name'] = name2; chat[0]['is_user'] = false; chat[0]['is_name'] = true; - chat[0]['send_date'] = Date.now(); + chat[0]['send_date'] = humanizedISO8601DateTime(); if(characters[this_chid].first_mes != ""){ chat[0]['mes'] = characters[this_chid].first_mes; }else{ @@ -1662,7 +1717,7 @@ } }); - //RossAscends: Lets add some hotkeys + //RossAscends: Additional hotkeys document.addEventListener('keydown', (event) => { if(event.ctrlKey && event.key == "Enter") { // Ctrl+Enter for Regeneration Last Response @@ -1684,11 +1739,12 @@ $( "#rm_button_create" ).css("class","deselected-right-tab"); $( "#rm_button_characters" ).css("class","deselected-right-tab"); + $( "#rm_button_settings" ).click(function() { selected_button = 'settings'; menu_type = 'settings'; $( "#rm_characters_block" ).css("display", "none"); - $( "#rm_api_block" ).css("display", "block"); + $( "#rm_api_block" ).css("display", "grid"); $('#rm_api_block').css('opacity',0.0); $('#rm_api_block').transition({ opacity: 1.0, @@ -2153,12 +2209,12 @@ }); function select_rm_create(){ menu_type = 'create'; +//console.log('select_rm_Create() -- selected button: '+selected_button); if(selected_button == 'create'){ if(create_save_avatar != ''){ $("#add_avatar_button").get(0).files = create_save_avatar; read_avatar_load($("#add_avatar_button").get(0)); } - } $( "#rm_characters_block" ).css("display", "none"); $( "#rm_api_block" ).css("display", "none"); @@ -2173,11 +2229,13 @@ complete: function() { } }); $( "#rm_info_block" ).css("display", "none"); - $( "#delete_button_div" ).css("display", "none"); + $( "#delete_button" ).css("display", "none"); + $( "#export_button" ).css("display", "none"); $("#create_button").css("display", "block"); $("#create_button").attr("value", "Create"); - $('#result_info').html(' '); + //RossAscends: commented this out as part of the auto-loading token counter + //$('#result_info').html(' '); $( "#rm_button_characters" ).css("class","deselected-right-tab"); $( "#rm_button_settings" ).css("class","deselected-right-tab"); $( "#rm_button_selected_ch" ).css("class","deselected-right-tab"); @@ -2204,7 +2262,7 @@ $("#form_create").attr("actiontype", "createcharacter"); } function select_rm_characters(){ - + QuickRefresh(); menu_type = 'characters'; $( "#rm_characters_block" ).css("display", "block"); $('#rm_characters_block').css('opacity',0.0); @@ -2237,14 +2295,15 @@ $( "#rm_button_settings" ).css("class","deselected-right-tab"); $( "#rm_button_selected_ch" ).css("class","deselected-right-tab"); } - function select_selected_character(chid){ //character select - + //console.log('select_selected_character() -- starting with input of -- '+chid+' (name:'+characters[chid].name+')'); select_rm_create(); menu_type = 'character_edit'; - $( "#delete_button_div" ).css("display", "block"); + $( "#delete_button" ).css("display", "block"); + $( "#export_button" ).css("display", "block"); $( "#rm_button_selected_ch" ).css("class","selected-right-tab"); var display_name = characters[chid].name; + $( "#rm_button_selected_ch" ).children("h2").text(display_name); @@ -2284,21 +2343,34 @@ $("#name_div").css("display", "none"); $("#form_create").attr("actiontype", "editcharacter"); + active_character = chid; + //console.log('select_selected_character() -- active_character -- '+chid+'(ChID of '+display_name+')'); + saveSettings(); + //console.log('select_selected_character() -- called saveSettings() to save -- active_character -- '+active_character+'(ChID of '+display_name+')'); + } $(document).on('click', '.character_select', function(){ - if(this_chid !== $(this).attr("chid")){ + if(this_chid !== $(this).attr("chid")){ //if clicked on a different character from what was currently selected if(!is_send_press){ selected_group = null; is_group_generating = false; this_edit_mes_id = undefined; selected_button = 'character_edit'; this_chid = $(this).attr("chid"); + active_character = this_chid; clearChat(); chat.length = 0; - getChat(); - + getChat(); + var count_tokens = encode(JSON.stringify(characters[this_chid].description+characters[this_chid].personality+characters[this_chid].scenario+characters[this_chid].mes_example)).length; + //RossAscends: added token counter to load when a character is selected, instead of waiting for an edit. + if(count_tokens < 1024){ + $('#result_info').html(count_tokens+" Tokens"); + }else{ + $('#result_info').html(""+count_tokens+" Tokens(TOO MANY TOKENS)"); + } + console.log('Clicked on '+characters[this_chid].name+' Active_Character set to: '+active_character+' (ChID:'+this_chid+')'); } - }else{ + }else{ //if clicked on character that was already selected selected_button = 'character_edit'; select_selected_character(this_chid); } @@ -2448,7 +2520,6 @@ is_advanced_char_open = false; $('#character_popup').css('display', 'none'); }); - $("#dialogue_popup_ok").click(function(){ $("#shadow_popup").css('display', 'none'); $("#shadow_popup").css('opacity:', 0.0); @@ -2457,19 +2528,29 @@ bg_file_for_del.parent().remove(); } if(popup_type == 'del_ch'){ + console.log('Deleting character -- ChID: '+this_chid+ ' -- Name: '+characters[this_chid].name); var msg = jQuery('#form_create').serialize(); // ID form jQuery.ajax({ method: 'POST', url: '/deletecharacter', beforeSend: function(){ select_rm_info("Character deleted"); - //$('#create_button').attr('value','Deleting...'); }, data: msg, cache: false, success: function(html){ - location.reload(); + //RossAscends: setting active character to null in order to avoid array errors. + //this allows for dynamic refresh of character list after deleting a character. + $('#character_cross').click(); + active_character = 'invalid-safety-id'; //unsets the chid in settings (this prevents AutoLoadChat from trying to load the wrong ChID + this_chid = 'invalid-safety-id'; //unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays) + 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. + chat = safetychat; // sets up chloe to tell user about having deleted a character + saveSettings(); // saving settings to keep changes to variables + QuickRefresh(); // call quick refresh of Char list, clears chat, and loads Chloe 'post-char-delete' message. + //location.reload(); // this is Humi's original code //getCharacters(); //$('#create_button_div').html(html); } @@ -2493,11 +2574,11 @@ deleteGroup(groupId); } } + //Make a new chat for selected character if(popup_type == 'new_chat' && this_chid != undefined && menu_type != "create"){//Fix it; New chat doesn't create while open create character menu clearChat(); chat.length = 0; - characters[this_chid].chat = Date.now(); //RossAscends: added character name to new chat filenames and replaced Date.now() with humanizedISO8601DateTime; - //characters[this_chid].chat = (name2 +' - '+ humanizedISO8601DateTime); //RossAscends: added character name to new chat filenames and replaced Date.now() with humanizedISO8601DateTime; + characters[this_chid].chat = (name2 +' - '+ humanizedISO8601DateTime()); //RossAscends: added character name to new chat filenames and replaced Date.now() with humanizedISO8601DateTime; $("#selected_chat_pole").val(characters[this_chid].chat); timerSaveEdit = setTimeout(() => {$("#create_button").click();},durationSaveEdit); getChat(); @@ -2536,7 +2617,6 @@ $("#shadow_popup").css('display', 'block'); $('#shadow_popup').transition({ opacity: 1.0 ,duration: animation_rm_duration, easing:animation_rm_easing}); } - function read_bg_load(input) { if (input.files && input.files[0]) { var reader = new FileReader(); @@ -2633,8 +2713,8 @@ var formData = new FormData($("#form_create").get(0)); if($("#form_create").attr("actiontype") == "createcharacter"){ - if($("#character_name_pole").val().length > 0){ - + if($("#character_name_pole").val().length > 0){ //if the character name text area isn't empty (only posible when creating a new character) + //console.log('/createcharacter entered'); jQuery.ajax({ type: 'POST', url: '/createcharacter', @@ -2647,7 +2727,7 @@ contentType: false, processData: false, success: function(html){ - $('#character_cross').click(); + $('#character_cross').click(); //closes the advanced character editing popup $("#character_name_pole").val(''); create_save_name = ''; $("#description_textarea").val(''); @@ -2679,13 +2759,15 @@ select_rm_info("Character created"); $('#rm_info_block').transition({ opacity: 1.0 ,duration: 2000}); - + + getCharacters(); }else{ $('#result_info').html(html); } }, error: function (jqXHR, exception) { + //alert('ERROR: '+xhr.status+ ' Status Text: '+xhr.statusText+' '+xhr.responseText); $('#create_button').removeAttr("disabled"); } }); @@ -2693,8 +2775,8 @@ $('#result_info').html("Name not entered"); } }else{ - console.log($("#add_avatar_button").val()); - + //console.log('/editcharacter -- entered.'); + //console.log('Avatar Button Value:'+$("#add_avatar_button").val()); jQuery.ajax({ type: 'POST', url: '/editcharacter', @@ -2707,14 +2789,12 @@ contentType: false, processData: false, success: function(html){ - $('.mes').each(function(){ if($(this).attr('ch_name') != name1){ $(this).children('.avatar').children('img').attr('src', $('#avatar_load_preview').attr('src')); } }); if(chat.length === 1 ){ - var this_ch_mes = default_ch_mes; if($('#firstmessage_textarea').val() != ""){ this_ch_mes = $('#firstmessage_textarea').val(); @@ -2732,24 +2812,19 @@ } } $('#create_button').removeAttr("disabled"); - getCharacters(); - $("#add_avatar_button").replaceWith($("#add_avatar_button").val('').clone(true)); $('#create_button').attr('value','Save'); - - var count_tokens = encode(JSON.stringify(characters[this_chid].description+characters[this_chid].personality+characters[this_chid].scenario+characters[this_chid].mes_example)).length; + //console.log('/editcharacters -- this_chid -- '+this_chid); + if(this_chid != undefined && this_chid != 'invalid-safety-id'){ //added check to avoid trying to load tokens in case of character deletion + var count_tokens = encode(JSON.stringify(characters[this_chid].description+characters[this_chid].personality+characters[this_chid].scenario+characters[this_chid].mes_example)).length; + } if(count_tokens < 1024){ $('#result_info').html(count_tokens+" Tokens"); }else{ $('#result_info').html(""+count_tokens+" Tokens(TOO MANY TOKENS)"); } - - //$('#result_info').transition({ opacity: 0.0 ,delay: 500,duration: 1000,easing: 'in-out',complete: function() { - //$('#result_info').transition({ opacity: 1.0,duration: 0}); - //$('#result_info').html(' '); - //}}); }, error: function (jqXHR, exception) { $('#create_button').removeAttr("disabled"); @@ -2761,7 +2836,7 @@ }); $( "#delete_button" ).click(function() { popup_type = 'del_ch'; - callPopup('

Delete the character?

'); + callPopup('

Delete the character?

Page will reload and you will be returned to Chloe.'); }); $( "#rm_info_button" ).click(function() { $('#rm_info_avatar').html(''); @@ -2861,23 +2936,25 @@ } }); - // RossAscends: Added functionality that will close the RightNav panels when User clicks outside them + // RossAscends: Added functionality that will close the RightNav panel click outside of it or related panels (adv editing popup, or dialog popups) var NavToggle = document.getElementById("nav-toggle"); var PanelPin = document.getElementById("rm_button_panel_pin"); $('document').ready(function(){ $("html").click(function(e){ - if (NavToggle.checked === true && PanelPin.checked === false) { - if ($(e.target).attr('id') !== "nav-toggle") { - if (document.querySelector('#right-nav-panel').contains(e.target) === false){ - document.getElementById('nav-toggle').click(); + if (NavToggle.checked === true && PanelPin.checked === false) { + if ($(e.target).attr('id') !== "nav-toggle") { + if (document.querySelector('#right-nav-panel').contains(e.target) === false){ + if (document.querySelector('#character_popup').contains(e.target) === false){ + if (document.querySelector('#dialogue_popup').contains(e.target) === false){ + document.getElementById('nav-toggle').click(); + } + } + } } - } - }; + }; + }); }); - }); - - //------------------------------------------------------------------------------------------------------------- $( "#options_button" ).click(function() { // this is the options button click function, shows the options menu if closed if($("#options").css('display') === 'none' && $("#options").css('opacity') == 0.0){ @@ -2923,7 +3000,6 @@ callPopup('

Start new chat?

'); } }); - $( "#option_regenerate" ).click(function() { if(is_send_press == false){ is_send_press = true; @@ -3112,6 +3188,8 @@ } } async function getUserAvatars(){ + $("#user_avatar_block").html(""); //RossAscends: necessary to avoid doubling avatars each QuickRefresh. + $('#user_avatar_block').append('
+
'); const response = await fetch("/getuseravatars", { method: "POST", headers: { @@ -3127,6 +3205,7 @@ const getData = await response.json(); //background = getData; //console.log(getData.length); + for(var i = 0; i < getData.length; i++) { //console.log(1); appendUserAvatar(getData[i]); @@ -3144,7 +3223,7 @@ } function appendUserAvatar(name) { - const block = $("#user_avatar_block").append('
'); + const block = $("#user_avatar_block").append('
'); highlightSelectedAvatar(); } @@ -3184,6 +3263,14 @@ $('#character_anchor').change(function() { character_anchor = !!$('#character_anchor').prop('checked'); saveSettings(); + }); + $('#auto-connect-checkbox').change(function() { + auto_connect = !!$('#auto-connect-checkbox').prop('checked'); + saveSettings(); + }); + $('#auto-load-chat-checkbox').change(function() { + auto_load_chat = !!$('#auto-load-chat-checkbox').prop('checked'); + saveSettings(); }); $(document).on('input', '#rep_pen', function() { rep_pen = $(this).val(); @@ -3199,7 +3286,6 @@ $('#rep_pen_size_counter').html( $(this).val()+" Tokens"); var repPenSizeTimer = setTimeout(saveSettings, 500); }); - //Novel $(document).on('input', '#temp_novel', function() { temp_novel = $(this).val(); @@ -3229,7 +3315,7 @@ /////////////////////////////////////////// async function getSettings(type){//timer - +//console.log('getSettings() pinging server for settings request'); jQuery.ajax({ type: 'POST', url: '/getsettings', @@ -3251,25 +3337,25 @@ $('#your_name').val(name1); } } - - - //Novel + + //Load which API we are using if(settings.main_api != undefined){ main_api = settings.main_api; $("#main_api option[value="+main_api+"]").attr('selected', 'true'); changeMainAPI(); } + //load Novel API KEY is exists if(settings.api_key_novel != undefined){ api_key_novel = settings.api_key_novel; $("#api_key_novel").val(api_key_novel); } + //load the rest of the Novel settings without any checks model_novel = settings.model_novel; $("#model_novel_select option[value="+model_novel+"]").attr('selected', 'true'); novelai_setting_names = data.novelai_setting_names; novelai_settings = data.novelai_settings; novelai_settings.forEach(function(item, i, arr) { - novelai_settings[i] = JSON.parse(item); }); var arr_holder = {}; @@ -3284,7 +3370,8 @@ preset_settings_novel = settings.preset_settings_novel; $("#settings_perset_novel option[value="+novelai_setting_names[preset_settings_novel]+"]").attr('selected', 'true'); - //Kobold + + //Load KoboldAI settings koboldai_setting_names = data.koboldai_setting_names; koboldai_settings = data.koboldai_settings; koboldai_settings.forEach(function(item, i, arr) { @@ -3301,7 +3388,8 @@ koboldai_setting_names = arr_holder; preset_settings = settings.preset_settings; - + + //Load AI model config settings (temp, context length, anchors, and anchor order) temp = settings.temp; amount_gen = settings.amount_gen; if(settings.max_context !== undefined) max_context = parseInt(settings.max_context); @@ -3310,10 +3398,14 @@ if(settings.character_anchor !== undefined) character_anchor = !!settings.character_anchor; if(settings.world_info_depth !== undefined) world_info_depth = Number(settings.world_info_depth); if(settings.world_info_budget !== undefined) world_info_budget = Number(settings.world_info_budget); + + //load poweruser options + if(settings.auto_connect !== undefined) auto_connect = !!settings.auto_connect; + if(settings.auto_load_chat !== undefined) auto_load_chat = !!settings.auto_load_chat; + rep_pen = settings.rep_pen; rep_pen_size = settings.rep_pen_size; - - + var addZeros = ""; if(isInt(temp)) addZeros = ".00"; $('#temp').val(temp); @@ -3323,6 +3415,9 @@ $('#character_anchor').prop('checked', character_anchor); $("#anchor_order option[value="+anchor_order+"]").attr('selected', 'true'); + $('#auto-connect-checkbox').prop('checked', auto_connect); + $('#auto-load-chat-checkbox').prop('checked', auto_load_chat); + $('#max_context').val(max_context); $('#max_context_counter').html(max_context+' Tokens'); @@ -3344,7 +3439,6 @@ $('#rep_pen_size_counter').html(rep_pen_size+" Tokens"); //Novel - temp_novel = settings.temp_novel; rep_pen_novel = settings.rep_pen_novel; rep_pen_size_novel = settings.rep_pen_size_novel; @@ -3362,7 +3456,7 @@ $('#rep_pen_size_novel').val(rep_pen_size_novel); $('#rep_pen_size_counter_novel').html(rep_pen_size_novel+" Tokens"); - ////////////////////// + //Enable GUI deference settings if GUI is selected for Kobold if(preset_settings == 'gui'){ $("#settings_perset option[value=gui]").attr('selected', 'true'); $("#range_block").children().prop("disabled", true); @@ -3385,14 +3479,16 @@ } } - //User + //Load User's Name and Avatar + user_avatar = settings.user_avatar; $('.mes').each(function(){ if($(this).attr('ch_name') == name1){ $(this).children('.avatar').children('img').attr('src', 'User Avatars/'+user_avatar); } }); - + + //Load the API server URL from settings api_server = settings.api_server; $('#api_url_text').val(api_server); @@ -3423,9 +3519,16 @@ $('body').append(script); } } + + //get the character to auto-load + if(settings.active_character !== undefined){ + if(settings.active_character !== ''){ + active_character = settings.active_character; + } + } } + if(!is_checked_colab) isColab(); - }, error: function (jqXHR, exception) { console.log(exception); @@ -3435,9 +3538,8 @@ }); } - async function saveSettings(type){ - +//console.log('saveSettings() -- pinging server to save settings.'); jQuery.ajax({ type: 'POST', url: '/savesettings', @@ -3453,6 +3555,8 @@ anchor_order: anchor_order, style_anchor: style_anchor, character_anchor: character_anchor, + auto_connect: auto_connect, + auto_load_chat: auto_load_chat, main_api: main_api, api_key_novel: api_key_novel, rep_pen: rep_pen, @@ -3464,9 +3568,10 @@ world_info: world_info, world_info_depth: world_info_depth, world_info_budget: world_info_budget, + active_character: active_character                  }), beforeSend: function(){ - +//console.log('saveSettings() -- active_character -- '+active_character); }, cache: false, @@ -3476,8 +3581,10 @@ success: function(data){ //online_status = data.result; if(type === 'change_name'){ - location.reload(); - } + QuickRefresh(); //RossAscends: No more page reload on username change + //location.reload(); + } + }, error: function (jqXHR, exception) { console.log(exception); @@ -3515,7 +3622,6 @@ $('#shadow_select_chat_popup').css('display', 'none'); $('#load_select_chat_div').css('display', 'block'); }); - function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && @@ -3623,18 +3729,18 @@ this_edit_mes_id = undefined; saveChat(); } - $("#your_name_button").click(function() { if(!is_send_press){ name1 = $("#your_name").val(); if(name1 === undefined || name1 == '') name1 = default_user_name; - console.log(name1); + //console.log(name1); saveSettings('change_name'); } }); //Select chat async function getAllCharaChats() { + //console.log('getAllCharaChats() pinging server for character chat history.'); $('#select_chat_div').html(''); //console.log(characters[this_chid].chat); jQuery.ajax({ @@ -3652,18 +3758,21 @@ let dataArr = Object.values(data); data = dataArr.sort((a, b) => a['file_name'].localeCompare(b['file_name'])); data = data.reverse(); + for (const key in data) { - let strlen = 40; + let strlen = 300; let mes = data[key]['mes']; - if(mes.length > strlen){ - mes = '...'+mes.substring(mes.length - strlen); - } - $('#select_chat_div').append('
'+data[key]['file_name']+'
'+mes+'
'); - if(characters[this_chid]['chat'] == data[key]['file_name'].replace('.jsonl', '')){ - //children().last() - $('#select_chat_div').children(':nth-last-child(1)').attr('highlight', true); - } - } + if(mes !== undefined){ + if(mes.length > strlen){ + mes = '...'+mes.substring(mes.length - strlen); + } + $('#select_chat_div').append('
'+data[key]['file_name']+'
'+mes+'
'); + if(characters[this_chid]['chat'] == data[key]['file_name'].replace('.jsonl', '')){ + //children().last() + $('#select_chat_div').children(':nth-last-child(1)').attr('highlight', true); + } + } + } //
//
@@ -3673,11 +3782,14 @@ //chat = data; //getChatResult(); //saveChat(); - }, + //console.log('getAllCharaChats() -- Finished successfully'); + }, error: function (jqXHR, exception) { //getChatResult(); - console.log(exception); + //console.log('getAllCharaChats() -- Failed'); + console.log(exception); console.log(jqXHR); + } }); } @@ -3764,8 +3876,6 @@ anchor_order = parseInt($('#anchor_order').find(":selected").val()); saveSettings(); }); - - function compareVersions(v1, v2) { const v1parts = v1.split('.'); const v2parts = v2.split('.'); @@ -3792,9 +3902,6 @@ return 0; } - - - //**************************CHARACTER IMPORT EXPORT*************************// $( "#character_import_button" ).click(function() { $("#character_import_file").click(); @@ -3853,9 +3960,6 @@ document.body.appendChild(link); link.click(); }); - - - //**************************CHAT IMPORT EXPORT*************************// $( "#chat_import_button" ).click(function() { $("#chat_import_file").click(); @@ -3875,7 +3979,7 @@ $("#chat_import_file_type").val(format); //console.log(format); var formData = new FormData($("#form_import_chat").get(0)); - +//console.log('/importchat entered with: '+formData); jQuery.ajax({ type: 'POST', url: '/importchat', @@ -4404,8 +4508,84 @@ setExtensionPrompt: setExtensionPrompt, }; }; - }); + + //RossAscends: auto-load last character function (fires when active_character is defined and auto_load_chat is true) + function autoloadchat(){ + console.log('starting autoloadchat routine'); + jQuery.ajax({ + type: 'POST', + url: '/getsettings', + data: JSON.stringify({}), + beforeSend: function(){ + }, + cache: false, + dataType: "json", + contentType: "application/json", + success: function(data){ + if(data.result != 'file not find'){ + settings = JSON.parse(data.settings); + //get the character to auto-load + if(settings.active_character !== undefined){ + if(settings.active_character !== ''){ + active_character = settings.active_character; + } + } + } + console.log('active_character = '+active_character); + console.log('auto_load_chat = '+auto_load_chat); + + if (active_character !== undefined && auto_load_chat == true){ + $('#CharID'+active_character).click(); //will auto-select and load chat of last selected character is auto_load_chat is true + } + }, + error: function (jqXHR, exception) { + console.log(exception); + console.log(jqXHR); + + } + }); + + } + //RossAscends: auto-connect to last API function (fires when API URL exists in settings and auto_connect is true) + function autoconnect(){ + console.log('starting autoconnect routine'); + jQuery.ajax({ + type: 'POST', + url: '/getsettings', + data: JSON.stringify({}), + beforeSend: function(){ + }, + cache: false, + dataType: "json", + contentType: "application/json", + //processData: false, + success: function(data){ + if(data.result != 'file not find'){ + settings = JSON.parse(data.settings); + + //Load the API server URL from settings + api_server = settings.api_server; + $('#api_url_text').val(api_server); + } + console.log('api_server = '+ api_server ); + console.log('auto_connect = '+ auto_connect); + if(api_server !== ''&& auto_connect == true){ + $('#api_button').click(); + } + }, + error: function (jqXHR, exception) { + console.log(exception); + console.log(jqXHR); + + } + }); + + } + + }); +      + Tavern.AI @@ -4430,20 +4610,23 @@
- - -

Create character

- +
+ +
+ +
+

Create character

+
- +
-

Personality summary

A brief description of the personality (?)
+

Personality summary

A brief description of the personality ?

Scenario

-
Circumstances and context of the dialogue (?)
+
Circumstances and context of the dialogue ?
@@ -4459,14 +4642,13 @@
-

Examples of dialogue

-
Forms a personality more clearly (?)
-
- - - +
+

Examples of dialogue

+
Forms a personality more clearly ?
+
+ +
-
@@ -4483,7 +4665,7 @@
 
- +
@@ -4570,7 +4752,7 @@   0 - + @@ -4583,15 +4765,18 @@ -
+
-
(?)
- + +
+ ? +
+
@@ -4605,7 +4790,7 @@
-
+
@@ -4649,43 +4834,33 @@