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 1cf62c3d4..89a734a2c 100644
--- a/public/index.html
+++ b/public/index.html
@@ -43,17 +43,10 @@
var default_user_name = "You";
var name1 = default_user_name;
var name2 = systemUserName;
+ var name2 = "Chloe";
// might want to migrate this to 'system message' code
- var chat = [{
- 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?"
\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.
@@ -63,15 +56,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";
@@ -80,6 +76,7 @@
var generatedPromtCache = '';
var characters = [];
var this_chid;
+ var active_character;
var backgrounds = [];
var default_avatar = 'img/fluffy.png';
var is_colab = false;
@@ -178,6 +175,8 @@
var anchor_order = 0;
var style_anchor = true;
var character_anchor = true;
+ var auto_connect = false;
+ var auto_load_chat = false;
var main_api = 'kobold';
//novel settings
@@ -226,21 +225,39 @@
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();
});
- $('#characloud_url').click(function(){
- window.open('https://boosty.to/tavernai', '_blank');
- });
+ //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(){
+ 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();
+ };
+ }
+
$('#character_search_bar').on('input', function() {
const searchValue = $(this).val().trim().toLowerCase();
@@ -254,6 +271,10 @@
});
}
});
+
+ $('#characloud_url').click(function(){
+ window.open('https://boosty.to/tavernai', '_blank');
+ });
function checkOnlineStatus(){
//console.log(online_status);
if(online_status == 'no_connection'){
@@ -364,7 +385,6 @@
}
}
}
-
function resultCheckStatus(){
is_api_button_press = false;
checkOnlineStatus();
@@ -431,23 +451,26 @@
}
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('

');
highlightSelectedAvatar();
}
@@ -2549,6 +2617,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();
@@ -2564,7 +2640,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();
@@ -2594,7 +2669,7 @@
///////////////////////////////////////////
async function getSettings(type){//timer
-
+//console.log('getSettings() pinging server for settings request');
jQuery.ajax({
type: 'POST',
url: '/getsettings',
@@ -2616,25 +2691,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 = {};
@@ -2649,7 +2724,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) {
@@ -2666,7 +2742,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);
@@ -2675,10 +2752,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);
@@ -2688,6 +2769,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');
@@ -2709,7 +2793,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;
@@ -2727,7 +2810,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);
@@ -2750,14 +2833,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);
@@ -2778,9 +2863,16 @@
}
});
// end world info settings
+
+ //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);
@@ -2790,9 +2882,8 @@
});
}
-
async function saveSettings(type){
-
+//console.log('saveSettings() -- pinging server to save settings.');
jQuery.ajax({
type: 'POST',
url: '/savesettings',
@@ -2808,6 +2899,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,
@@ -2819,9 +2912,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,
@@ -2831,8 +2925,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);
@@ -2870,7 +2966,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 &&
@@ -2976,18 +3071,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({
@@ -3005,18 +3100,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);
+ }
+ }
+ }
//
//
@@ -3026,11 +3124,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);
+
}
});
}
@@ -3117,8 +3218,6 @@
anchor_order = parseInt($('#anchor_order').find(":selected").val());
saveSettings();
});
-
-
function compareVersions(v1, v2) {
const v1parts = v1.split('.');
const v2parts = v2.split('.');
@@ -3145,9 +3244,6 @@
return 0;
}
-
-
-
//**************************CHARACTER IMPORT EXPORT*************************//
$( "#character_import_button" ).click(function() {
$("#character_import_file").click();
@@ -3206,9 +3302,6 @@
document.body.appendChild(link);
link.click();
});
-
-
-
//**************************CHAT IMPORT EXPORT*************************//
$( "#chat_import_button" ).click(function() {
$("#chat_import_file").click();
@@ -3228,7 +3321,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',
@@ -3718,7 +3811,83 @@
createNewWorldInfo();
});
});
+ //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
@@ -3743,32 +3912,34 @@
-
@@ -3885,15 +4056,18 @@
-
-