');
- highlightSelectedAvatar();
- }
- //***************SETTINGS****************//
+ }
+ function highlightSelectedAvatar() {
+ $("#user_avatar_block").find('.avatar').removeClass('selected');
+ $("#user_avatar_block").find(`.avatar[imgfile='${user_avatar}']`).addClass('selected');
+ }
+ function appendUserAvatar(name) {
+ const block = $("#user_avatar_block").append('
');
+ highlightSelectedAvatar();
+ }
+ //***************SETTINGS****************//
///////////////////////////////////////////
async function getSettings(type) {//timer
- //console.log('getSettings() pinging server for settings request');
+ console.log('getSettings() -- Entered');
jQuery.ajax({
type: 'POST',
url: '/getsettings',
data: JSON.stringify({}),
beforeSend: function () {
-
+ console.log('getSettings -- before pull -- amount_gen = '+amount_gen)
},
cache: false,
@@ -2300,38 +2398,45 @@ window['TavernAI'] = {};
textgenerationwebui_settings = settings.textgenerationwebui_settings || textgenerationwebui_settings;
temp = settings.temp;
- amount_gen = settings.amount_gen;
- if (settings.max_context !== undefined) max_context = parseInt(settings.max_context);
- if (settings.anchor_order !== undefined) anchor_order = parseInt(settings.anchor_order);
- if (settings.style_anchor !== undefined) style_anchor = !!settings.style_anchor;
- 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);
$('#temp_counter').html(temp + addZeros);
+ amount_gen = settings.amount_gen;
+ $('#amount_gen').val(amount_gen);
+ $('#amount_gen_counter').html(amount_gen + ' Tokens');
+ console.log('getSettings -- just pulled -- amount_gen ='+amount_gen);
+
+ if (settings.max_context !== undefined) max_context = parseInt(settings.max_context);
+ $('#max_context').val(max_context);
+ $('#max_context_counter').html(max_context + ' Tokens');
+
+ if (settings.anchor_order !== undefined) anchor_order = parseInt(settings.anchor_order);
+ if (settings.style_anchor !== undefined) style_anchor = !!settings.style_anchor;
+ if (settings.character_anchor !== undefined) character_anchor = !!settings.character_anchor;
$('#style_anchor').prop('checked', style_anchor);
$('#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);
+ 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);
- $('#max_context').val(max_context);
- $('#max_context_counter').html(max_context + ' Tokens');
+ rep_pen = settings.rep_pen;
+ rep_pen_size = settings.rep_pen_size;
- $('#amount_gen').val(amount_gen);
- $('#amount_gen_counter').html(amount_gen + ' Tokens');
+ swipes = !!settings.swipes; //// swipecode
+ $('#swipes-checkbox').prop('checked', swipes); /// swipecode
+ console.log('getSettings -- swipes = '+swipes+'. toggling box');
+ hideSwipeButtons();
+ showSwipeButtons();
+
+/* $('#swipes-checkbox').change(function() {
+ swipes = !!$('#swipes-checkbox').prop('checked');
+
+ //if(swipes){ showSwipeButtons(); }else{ hideSwipeButtons(); }
+ saveSettings();
+ }); */
$('#world_info_depth_counter').html(`${world_info_depth} Messages`);
$('#world_info_depth').val(world_info_depth);
@@ -2446,26 +2551,14 @@ window['TavernAI'] = {};
$("#" + i + "_counter_textgenerationwebui")
.html(textgenerationwebui_settings[i]);
}
-/* //RossAscends: getting variables added/adjusted/applied with RA-mods
- active_character = settings.active_character;
- this_chid = settings.active_character; //forcing variable sameness for chid and this_chid with active_character in order to load RA_ALC
- var chid = settings.active_character; //forcing variable sameness for chid and this_chid with active_character in order to load RA_ALC
- console.log(
- "getSettings -- loaded from file -- active_character : " +
- settings.active_character
- );
- auto_connect = settings.auto_connect;
- auto_load_chat = settings.auto_load_chat; */
+
selected_button = settings.selected_button;
-/* NavOpenClosePref = settings.NavOpenClosePref;
- stickyNavPref = settings.stickyNavPref; */
-/* $("#nav-toggle").prop("checked", NavOpenClosePref);
- $("#rm_button_panel_pin").prop("checked", stickyNavPref);
- $("#auto-connect-checkbox").prop("checked", auto_connect);
- $("#auto-load-chat-checkbox").prop("checked", auto_load_chat); */
+
+
}
if (!is_checked_colab) isColab();
+ console.log('getSettings() -- success -- amount_gen='+amount_gen );
},
error: function (jqXHR, exception) {
console.log(exception);
@@ -2477,9 +2570,8 @@ window['TavernAI'] = {};
collapse_newlines = localStorage.getItem(storage_keys.collapse_newlines) == 'true';
$('#collapse-newlines-checkbox').prop('checked', collapse_newlines);
}
-
async function saveSettings(type) {
- //console.log('Entering settings with name1 = '+name1);
+ console.log('saveSettings() -- Entered');
jQuery.ajax({
type: 'POST',
url: '/savesettings',
@@ -2496,8 +2588,6 @@ window['TavernAI'] = {};
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,
@@ -2511,9 +2601,11 @@ window['TavernAI'] = {};
world_info_budget: world_info_budget,
active_character: active_character,
textgenerationwebui_settings: textgenerationwebui_settings,
+ swipes: swipes
}),
beforeSend: function () {
//console.log('saveSettings() -- active_character -- '+active_character);
+ //console.log('saveSettings() -- before send - amount_gen = '+amount_gen);
if (type == 'change_name') {
name1 = $('#your_name').val()
// console.log('beforeSend name1 = '+name1);
@@ -2535,7 +2627,7 @@ window['TavernAI'] = {};
}
-
+ //console.log('saveSettings() -- success -- amount_gen='+amount_gen);
},
error: function (jqXHR, exception) {
console.log(exception);
@@ -2616,16 +2708,7 @@ window['TavernAI'] = {};
}
}
}
- //
- //
- //console.log(data);
- //chat.length = 0;
-
- //chat = data;
- //getChatResult();
- //saveChat();
- //console.log('getAllCharaChats() -- Finished successfully');
},
error: function (jqXHR, exception) {
//getChatResult();
@@ -2873,36 +2956,318 @@ window['TavernAI'] = {};
$("#rm_button_settings").css("class", "deselected-right-tab");
$("#rm_button_selected_ch").css("class", "deselected-right-tab");
}
+ function showSwipeButtons(){
+
+ if(chat[chat.length-1].name !== 'TavernAI'){
+ if(swipes){
+ //console.log('showSwipeButtons -- entered');
+ //console.log('SSB -- are we showing a char first_message? mesid = '+$('.mes:last').attr('mesid'));
+ if($('.mes:last').attr('mesid') > 0){ // don't show swipes for opening messages.
+ //console.log('SSB -- for right button - is this a user message?'+(chat[chat.length-1]['is_user'])+' and count_view_mes = '+count_view_mes);
+ if(!chat[chat.length-1]['is_user'] && count_view_mes > 1){ // if the last chat is not from user, and there is more than one msg to view
+ //console.log('SSB -- CONFIRM -- showing right button');
+ $("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_right').css('display', 'flex'); // display right swipe
+ //console.log('SSB -- for left - how many messages exist to the left? '+(chat[chat.length-1]['swipe_id']));
+ if(chat[chat.length-1]['swipe_id'] !== undefined){ //if swipe_id exists (mean swipes have happened on this message-cell before)
+ //console.log('SBB -- for left pt2 -- What swipe message # is this?'+chat[chat.length-1]['swipe_id']);
+ if(chat[chat.length-1]['swipe_id'] != 0){ //and it's not 0 (meaning there is at least one message to view to the left)
+ $("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_left').css('display', 'flex'); //display left swipe
+ //console.log('SSB -- CONFIRM -- showed left button');
+ }//else{console.log('SSB -- only showed right side because only one swipe option.');}
+ }//else{console.log('SSB -- noped out of showing left button because swipe_id didnt exist');}
+ }//else{console.log('SSB -- noped out of showing swipes on User message');}
+ }//else{console.log('SSB -- noped out of first message swiping');}
+ }//else{console.log('SSB -- swipes not enabled');}
+ }//else{console.log('SBB -- noped out of swiping system messages');}
+ }
+
+ function hideSwipeButtons(){
+ console.log('hideswipebuttons entered');
+ $("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_right').css('display', 'none');
+ $("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_left').css('display', 'none');
+ }
+ function onlyUnique(value, index, array) {
+ return array.indexOf(value) === index;
+ }
+
+ function shuffle(array) {
+ let currentIndex = array.length, randomIndex;
+
+ while (currentIndex != 0) {
+ randomIndex = Math.floor(Math.random() * currentIndex);
+ currentIndex--;
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
+ }
+ return array;
+ }
+
+ function setExtensionPrompt(key, value) {
+ extension_prompts[key] = value;
+ }
+
+ window['TavernAI'].getContext = function () {
+ return {
+ chat: chat,
+ characters: characters,
+ groups: groups,
+ worldInfo: world_info_data,
+ name1: name1,
+ name2: name2,
+ characterId: this_chid,
+ groupId: selected_group,
+ chatId: (this_chid && characters[this_chid] && characters[this_chid].chat),
+ onlineStatus: online_status,
+ addOneMessage: addOneMessage,
+ generate: Generate,
+ encode: encode,
+ extensionPrompts: extension_prompts,
+ setExtensionPrompt: setExtensionPrompt,
+ saveChat: saveChat,
+ sendSystemMessage: sendSystemMessage,
+ };
+ };
+
+/////////////////////////////////////////////////////////
+///////// INTERACTIVE FUNCTIONS AND LISTENERS ///////////
+/////////////////////////////////////////////////////////
+
import { encode, decode } from "../scripts/gpt-2-3-tokenizer/mod.js";
$(document).ready(function () {
-
-
-
-/* //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();
-
- if (!this_chid || this_chid === 'invalid-safety-id') {
- $("#rm_button_selected_ch").css("class", "deselected-right-tab");
- $("#rm_button_selected_ch").children("h2").text('');
+ $('#swipes-checkbox').change(function() {
+ console.log('detected swipes-checkbox changed values')
+ swipes = !!$('#swipes-checkbox').prop('checked');
+ if(swipes){
+ showSwipeButtons();
+ }else{
+ hideSwipeButtons();
}
+ saveSettings();
+ });
+///// SWIPE BUTTON CLICKS ///////
- if (NavToggle.checked === false) {
- document.getElementById('nav-toggle').click();
- };
- } */
+ $(document).on('click', '.swipe_right', function(){ //when we click swipe right button
+ const swipe_duration = 120;
+ const swipe_range = 700;
+ //console.log(swipe_range);
+ let run_generate = false;
+ let run_swipe_right = false;
+ if(chat[chat.length-1]['swipe_id'] === undefined){ // if there is no swipe-message in the last spot of the chat array
+ chat[chat.length-1]['swipe_id'] = 0; // set it to id 0
+ chat[chat.length-1]['swipes'] = []; // empty the array
+ chat[chat.length-1]['swipes'][0] = chat[chat.length-1]['mes']; //assign swipe array with last message from chat
+ }
+ chat[chat.length-1]['swipe_id']++; //make new slot in array
+ //console.log(chat[chat.length-1]['swipes']);
+ if(parseInt(chat[chat.length-1]['swipe_id']) === chat[chat.length-1]['swipes'].length){ //if swipe id of last message is the same as the length of the 'swipes' array
+ run_generate = true;
+ }else if(parseInt(chat[chat.length-1]['swipe_id']) < chat[chat.length-1]['swipes'].length){ //otherwise, if the id is less than the number of swipes
+ chat[chat.length-1]['mes'] = chat[chat.length-1]['swipes'][chat[chat.length-1]['swipe_id']]; //load the last mes box with the latest generation
+ run_swipe_right = true; //then swipe
+ }
+
+ if(chat[chat.length-1]['swipe_id'] > chat[chat.length-1]['swipes'].length){ //if we swipe right while generating (the swipe ID is greater than what we are viewing now)
+ chat[chat.length-1]['swipe_id'] = chat[chat.length-1]['swipes'].length; //show that message slot (will be '...' while generating)
+ }
+ if(run_generate){ //hide swipe arrows while generating
+ $(this).css('display', 'none');
+
+ }
+ if(run_generate || run_swipe_right){ // handles animated transitions when swipe right, specifically height transitions between messages
+
+ let this_mes_div = $(this).parent();
+ let this_mes_block = $(this).parent().children('.mes_block').children('.mes_text');
+ const this_mes_div_height = this_mes_div[0].scrollHeight;
+ const this_mes_block_height = this_mes_block[0].scrollHeight;
+
+ this_mes_div.children('.swipe_left').css('display', 'flex');
+ this_mes_div.children('.mes_block').transition({ // this moves the div back and forth
+ x: '-'+swipe_range,
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+
+ const is_animation_scroll = ($('#chat').scrollTop() >= ($('#chat').prop("scrollHeight") - $('#chat').outerHeight()) - 10);
+ //console.log(parseInt(chat[chat.length-1]['swipe_id']));
+ //console.log(chat[chat.length-1]['swipes'].length);
+ if(run_generate && parseInt(chat[chat.length-1]['swipe_id']) === chat[chat.length-1]['swipes'].length){
+ //console.log('showing ...');
+ $("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.mes_block').children('.mes_text').html('...'); //shows ... while generating
+ }else{
+ //console.log('showing previously generated swipe candidate, or "..."');
+ addOneMessage(chat[chat.length-1], 'swipe');
+ }
+ let new_height = this_mes_div_height-(this_mes_block_height - this_mes_block[0].scrollHeight);
+ if(new_height < 103) new_height = 103;
+
+
+ this_mes_div.animate({height: new_height+'px'}, {
+ duration: 100,
+ queue:false,
+ progress: function() {
+ // Scroll the chat down as the message expands
+ if(is_animation_scroll) $("#chat").scrollTop($("#chat")[0].scrollHeight);
+ },
+ complete: function() {
+ this_mes_div.css('height', 'auto');
+ // Scroll the chat down to the bottom once the animation is complete
+ if(is_animation_scroll) $("#chat").scrollTop($("#chat")[0].scrollHeight);
+ }
+ });
+ this_mes_div.children('.mes_block').transition({
+ x: swipe_range,
+ duration: 0,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ this_mes_div.children('.mes_block').transition({
+ x: '0px',
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ if(run_generate && !is_send_press && parseInt(chat[chat.length-1]['swipe_id']) === chat[chat.length-1]['swipes'].length){
+ console.log('caught here 2');
+ is_send_press = true;
+ Generate('swipe');
+ }else{
+ if(parseInt(chat[chat.length-1]['swipe_id']) !== chat[chat.length-1]['swipes'].length){
+ console.log('caught here 3');
+ saveChat();
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+ });
+
+ $(this).parent().children('.avatar').transition({ // moves avatar aong with swipe
+ x: '-'+swipe_range,
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ $(this).parent().children('.avatar').transition({
+ x: swipe_range,
+ duration: 0,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ $(this).parent().children('.avatar').transition({
+ x: '0px',
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ });
+ $(document).on('click', '.swipe_left', function(){ // when we swipe left..but no generation.
+ const swipe_duration = 120;
+ const swipe_range = '700px';
+ chat[chat.length-1]['swipe_id']--;
+ if(chat[chat.length-1]['swipe_id'] >= 0){ // hide the left arrow if we are viewing the first candidate of the last message block
+ $(this).parent().children('swipe_right_button').css('display', 'flex');
+ if(chat[chat.length-1]['swipe_id'] === 0){
+ $(this).css('display', 'none');
+ }
+
+ let this_mes_div = $(this).parent();
+ let this_mes_block = $(this).parent().children('.mes_block').children('.mes_text');
+ const this_mes_div_height = this_mes_div[0].scrollHeight;
+ this_mes_div.css('height', this_mes_div_height);
+ const this_mes_block_height = this_mes_block[0].scrollHeight;
+
+ chat[chat.length-1]['mes'] = chat[chat.length-1]['swipes'][chat[chat.length-1]['swipe_id']];
+ $(this).parent().children('.mes_block').transition({
+ x: swipe_range,
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ const is_animation_scroll = ($('#chat').scrollTop() >= ($('#chat').prop("scrollHeight") - $('#chat').outerHeight()) - 10);
+console.log('sipwing left after tr5ansition calls addOneMessage');
+ addOneMessage(chat[chat.length-1], 'swipe');
+ let new_height = this_mes_div_height-(this_mes_block_height - this_mes_block[0].scrollHeight);
+ if(new_height < 103) new_height = 103;
+ this_mes_div.animate({height: new_height+'px'}, {
+ duration: 100,
+ queue:false,
+ progress: function() {
+ // Scroll the chat down as the message expands
+
+ if(is_animation_scroll) $("#chat").scrollTop($("#chat")[0].scrollHeight);
+ },
+ complete: function() {
+ this_mes_div.css('height', 'auto');
+ // Scroll the chat down to the bottom once the animation is complete
+ if(is_animation_scroll) $("#chat").scrollTop($("#chat")[0].scrollHeight);
+ }
+ });
+ $(this).parent().children('.mes_block').transition({
+ x: '-'+swipe_range,
+ duration: 0,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ $(this).parent().children('.mes_block').transition({
+ x: '0px',
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ saveChat();
+ }
+ });
+ }
+ });
+ }
+ });
+
+ $(this).parent().children('.avatar').transition({
+ x: swipe_range,
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ $(this).parent().children('.avatar').transition({
+ x: '-'+swipe_range,
+ duration: 0,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+ $(this).parent().children('.avatar').transition({
+ x: '0px',
+ duration: swipe_duration,
+ easing: animation_rm_easing,
+ queue:false,
+ complete: function() {
+
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+ if(chat[chat.length-1]['swipe_id'] < 0){
+ chat[chat.length-1]['swipe_id'] = 0;
+ }
+ });
+
+//// CHAR SEARCH BAR /////
$('#character_search_bar').on('input', function () {
const searchValue = $(this).val().trim().toLowerCase();
@@ -2918,68 +3283,27 @@ $(document).ready(function () {
}
});
-
-/* //RossAscends: a utility function for counting characters, even works for unsaved characters.
- function CountCharTokens() {
- $('#result_info').html('');
- if (selected_button == 'create') {
- var count_tokens = encode(JSON.stringify(create_save_description + create_save_personality + create_save_scenario + create_save_mes_example)).length;
- console.log('This unsaved character has ' + count_tokens + ' tokens in the defs.');
- } else {
- 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(characters[this_chid].name + ' has ' + count_tokens + ' tokens in the defs.');
- }
-
- if (count_tokens < 1024) {
- $('#result_info').html(count_tokens + " Tokens");
- } else {
- $('#result_info').html("" + count_tokens + " Tokens(TOO MANY TOKENS)");
- }
- } */
-
$('#characloud_url').click(function () {
window.open('https://boosty.to/tavernai', '_blank');
});
$("#send_but").click(function () {
- //$( "#send_but" ).css({"background": "url('img/load.gif')","background-size": "100%, 100%", "background-position": "center center"});
if (is_send_press == false) {
+ hideSwipeButtons();
is_send_press = true;
Generate();
}
});
- //hotkey to send input with enter (shift+enter generates a new line in the chat input box)
- //this is not ideal for touch device users with virtual keyboards.
- //ideally we would detect if the user is using a virtual keyboard, and disable this shortcut for them.
- //because mobile users' hands are always near the screen, tapping the send button is better for them, and enter should always make a new line.
- //note: CAI seems to have this handled. PC: shift+enter = new line, enter = send. iOS: shift+enter AND enter both make new lines, and only the send button sends.
- //maybe a way to simulate this would be to disable the eventListener for people iOS.
-
$("#send_textarea").keydown(function (e) {
if (!e.shiftKey && !e.ctrlKey && e.key == "Enter" && is_send_press == false) {
+ hideSwipeButtons();
is_send_press = true;
e.preventDefault();
Generate();
}
});
-/* //RossAscends: Additional hotkeys
- document.addEventListener('keydown', (event) => {
-
- if (event.ctrlKey && event.key == "Enter") { // Ctrl+Enter for Regeneration Last Response
-
- if (is_send_press == false) {
- is_send_press = true;
- Generate('regenerate');
- }
- } else if (event.ctrlKey && event.key == "ArrowUp") { //Ctrl+UpArrow for Connect to last server
-
- document.getElementById('api_button').click();
-
- }
- }); */
-
//menu buttons setup
var selected_button_style = {};
var deselected_button_style = {};
@@ -3712,26 +4036,6 @@ $(document).ready(function () {
}
});
-/* // 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) {
- 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) {
$("#options").css('display', 'block');
@@ -3774,12 +4078,14 @@ $(document).ready(function () {
});
$("#option_regenerate").click(function () {
if (is_send_press == false) {
+ hideSwipeButtons();
is_send_press = true;
Generate('regenerate');
}
});
// this function hides the input form, and shows the delete/cancel buttons for deleting messages from chat
$("#option_delete_mes").click(function () {
+ hideSwipeButtons();
if (this_chid != undefined && !is_send_press || (selected_group && !is_group_generating)) {
$('#dialogue_del_mes').css('display', 'block');
$('#send_form').css('display', 'none');
@@ -3803,6 +4109,7 @@ $(document).ready(function () {
});
this_del_mes = 0;
+ showSwipeButtons();
});
//confirms message delation with the "ok" button
@@ -3831,6 +4138,9 @@ $(document).ready(function () {
$textchat.scrollTop($textchat[0].scrollHeight);
}
this_del_mes = 0;
+ $('#chat .mes').last().addClass('last_mes');
+ $('#chat .mes').eq(-2).removeClass('last_mes');
+ showSwipeButtons();
});
@@ -3851,11 +4161,12 @@ $(document).ready(function () {
});
$("#settings_perset").change(function () {
-
+console.log('#settings_preset sensor -- starting');
if ($('#settings_perset').find(":selected").val() != 'gui') {
preset_settings = $('#settings_perset').find(":selected").text();
temp = koboldai_settings[koboldai_setting_names[preset_settings]].temp;
amount_gen = koboldai_settings[koboldai_setting_names[preset_settings]].genamt;
+ console.log('settings_perset -- changed -- amount_gen ='+ amount_gen);
rep_pen = koboldai_settings[koboldai_setting_names[preset_settings]].rep_pen;
rep_pen_size = koboldai_settings[koboldai_setting_names[preset_settings]].rep_pen_range;
max_context = koboldai_settings[koboldai_setting_names[preset_settings]].max_length;
@@ -3887,6 +4198,7 @@ $(document).ready(function () {
$("#amount_gen_block").children().prop("disabled", true);
$("#amount_gen_block").css('opacity', 0.45);
}
+ console.log('setting_preset -- finished');
saveSettings();
});
$("#settings_perset_novel").change(function () {
@@ -4088,7 +4400,21 @@ $(document).ready(function () {
let chatScrollPosition = $("#chat").scrollTop();
if (this_edit_mes_id !== undefined) {
+
+ let run_edit = true;
+ var edit_mes_id = $(this).parent().parent().parent().attr('mesid');
let mes_edited = $('#chat').children().filter('[mesid="' + this_edit_mes_id + '"]').children('.mes_block').children('.ch_name').children('.mes_edit_done');
+ if(edit_mes_id == count_view_mes-1){ //if the generating swipe (...)
+ if(chat[edit_mes_id]['swipe_id'] !== undefined){
+ if(chat[edit_mes_id]['swipes'].length === chat[edit_mes_id]['swipe_id']){
+ run_edit = false;
+ }
+ }
+ if(run_edit){
+ hideSwipeButtons();
+ }
+ }
+
messageEditDone(mes_edited);
}
$(this).parent().parent().children('.mes_text').empty();
@@ -4773,46 +5099,7 @@ $(document).ready(function () {
});
/// UTILS
- function onlyUnique(value, index, array) {
- return array.indexOf(value) === index;
- }
- function shuffle(array) {
- let currentIndex = array.length, randomIndex;
-
- while (currentIndex != 0) {
- randomIndex = Math.floor(Math.random() * currentIndex);
- currentIndex--;
- [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
- }
- return array;
- }
-
- function setExtensionPrompt(key, value) {
- extension_prompts[key] = value;
- }
-
- window['TavernAI'].getContext = function () {
- return {
- chat: chat,
- characters: characters,
- groups: groups,
- worldInfo: world_info_data,
- name1: name1,
- name2: name2,
- characterId: this_chid,
- groupId: selected_group,
- chatId: (this_chid && characters[this_chid] && characters[this_chid].chat),
- onlineStatus: online_status,
- addOneMessage: addOneMessage,
- generate: Generate,
- encode: encode,
- extensionPrompts: extension_prompts,
- setExtensionPrompt: setExtensionPrompt,
- saveChat: saveChat,
- sendSystemMessage: sendSystemMessage,
- };
- };
/* //RossAscends: auto-load last character function (fires when active_character is defined and auto_load_chat is true)
function autoloadchat() {
diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js
index 6ea43bc06..daedf9424 100644
--- a/public/scripts/RossAscends-mods.js
+++ b/public/scripts/RossAscends-mods.js
@@ -324,29 +324,20 @@ $("document").ready(function () {
//2. find a way to make the chat slide down smoothly when the last mes div gets .remove()-d
document.addEventListener('swiped-left', function(e) {
- var SwipeTargetMesClassParent = e.target.closest('.mes');
- if (is_send_press == false){
- if (SwipeTargetMesClassParent !== null && SwipeTargetMesClassParent.nextSibling == null ){
- $('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
- $('#chat').children().last().css({'transform':'translateX(-100vw) scale(0,0)','overflow':'hidden'});
- $('#chat').children().last().css({'opacity':'0'});
-
- Generate('regenerate');
+ var SwipeTargetMesClassParent = e.target.closest('.last_mes');
+ if (SwipeTargetMesClassParent !== null){
+ if($('.swipe_right:last').attr('style')=='display: flex;' == true){
+ $('.swipe_right:last').click();
}
}
});
document.addEventListener('swiped-right', function(e) {
- var SwipeTargetMesClassParent = e.target.closest('.mes');
- console.log(is_send_press);
- if (is_send_press === false){
- if (SwipeTargetMesClassParent !== null && SwipeTargetMesClassParent.nextSibling == null){
- $('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
- $('#chat').children().last().css({'transform':'translateX(100vh) scale(0,0)','overflow':'hidden'});
- $('#chat').children().last().css({'opacity':'0'});
- Generate('regenerate');
- console.log(is_send_press);
+ var SwipeTargetMesClassParent = e.target.closest('.last_mes');
+ if (SwipeTargetMesClassParent !== null){
+ if($('.swipe_left:last').attr('style')=='display: flex;' == true){
+ $('.swipe_left:last').click();
}
- }
+ }
});
//Additional hotkeys CTRL+ENTER and CTRL+UPARROW
@@ -370,6 +361,12 @@ $("document").ready(function () {
if (event.ctrlKey && event.key == "ArrowRight") { //for debug, empty local storage state
ClearLocal();
}
+ if (event.key == "ArrowLeft") { //swipes left
+ $('.swipe_left:last').click();;
+ }
+ if (event.key == "ArrowRight") { //swipes right
+ $('.swipe_right:last').click();
+ }
});
})
diff --git a/public/settings.json b/public/settings.json
index 0b363013a..12d216b48 100644
--- a/public/settings.json
+++ b/public/settings.json
@@ -1 +1 @@
-{"username":"You","api_server":"http://localhost:5000/api","api_server_textgenerationwebui":"","preset_settings":"gui","preset_settings_novel":"Classic-Euterpe","user_avatar":"legat.png","temp":0.43,"amount_gen":180,"max_context":2048,"anchor_order":0,"style_anchor":false,"character_anchor":false,"auto_connect":true,"auto_load_chat":true,"main_api":"kobold","api_key_novel":"","rep_pen":1.17,"rep_pen_size":1024,"model_novel":"euterpe-v2","temp_novel":1.11,"rep_pen_novel":1.11,"rep_pen_size_novel":320,"world_info":null,"world_info_depth":2,"world_info_budget":200,"active_character":"0","textgenerationwebui_settings":{"temp":0.5,"top_p":0.9,"top_k":0,"typical_p":1,"rep_pen":1.1,"rep_pen_size":0,"penalty_alpha":0}}
\ No newline at end of file
+{"username":"You","api_server":"http://127.0.0.1:5000/api","api_server_textgenerationwebui":"","preset_settings":"Classic-Pygmalion-2.7b","preset_settings_novel":"Classic-Euterpe","user_avatar":"legat.png","temp":0.43,"amount_gen":180,"max_context":2048,"anchor_order":0,"style_anchor":false,"character_anchor":false,"main_api":"kobold","api_key_novel":"","rep_pen":1.17,"rep_pen_size":1024,"model_novel":"euterpe-v2","temp_novel":0.5,"rep_pen_novel":1,"rep_pen_size_novel":100,"world_info":"Toaru","world_info_depth":1,"world_info_budget":200,"active_character":"0","textgenerationwebui_settings":{"temp":0.5,"top_p":0.9,"top_k":0,"typical_p":1,"rep_pen":1.1,"rep_pen_size":0,"penalty_alpha":0},"swipes":true}
\ No newline at end of file
diff --git a/public/style.css b/public/style.css
index 29a4f90b9..9f66d9c01 100644
--- a/public/style.css
+++ b/public/style.css
@@ -341,13 +341,50 @@ code {
.mes {
display: grid;
- grid-template-columns: min-content min-content auto;
+ grid-template-columns: min-content min-content auto min-content min-content;
padding: 10px 10px 0 10px;
vertical-align: top;
width: 100%;
color: var(--ivory, white);
}
+.last_mes .mes_text {
+ min-height: 7em;
+}
+
+.last_mes{
+ grid-template-columns: [checkbox] fit-content(60px) [avatar] 50px [msg_block] auto [rightswipe] fit-content(48px);
+
+}
+/* SWIPE RELATED STYLES*/
+
+.swipe_right,.swipe_left {
+ height: 30px;
+ width: 30px;
+ opacity: 0.36;
+ position: absolute;
+ right: 15px;
+ margin-top: 62px;
+ left: auto;
+ background-color: var(--black50a);
+ padding: 20px;
+ border-radius: 50%;
+ align-items: center;
+ justify-content: center;
+ /* display: none; */
+ border: 1px solid grey;
+}
+
+.swipe_right img, .swipe_left img {
+ height: 30px;
+ width: 30px;
+}
+
+.swipe_left {
+ left: 20px;
+ right: auto;
+}
+
.avatar {
width: 50px;
height: 50px;
@@ -367,15 +404,14 @@ code {
}
.avatar.selected img {
- outline-style: solid;
+/* outline-style: solid;
outline-color: rgb(255 255 255 / 70%);
- outline-width: 2px;
+ outline-width: 2px; */
}
.mes_block {
-
padding-top: 0;
- padding-left: 10px;
+ padding-left: 20px;
}
.ch_name {
@@ -386,8 +422,8 @@ code {
.mes_text {
font-weight: 400;
line-height: 1.25rem;
- padding-right: 40px;
- padding-left: 5px;
+ padding-right: 60px;
+ padding-left: 0;
padding-top: 5px;
padding-bottom: 5px;
max-width: 720px;
@@ -1527,8 +1563,10 @@ input[type='checkbox']:not(#nav-toggle):not(#rm_button_panel_pin):checked::after
#user_avatar_block .avatar {
cursor: pointer;
- width: 60px;
- height: 60px;
+ width: 64px;
+ height: 64px;
+ border: 2px solid rgba(255,255,255,0.7);
+ border-radius: 50%;
}
#user_avatar_block .avatar img {
@@ -2491,6 +2529,8 @@ a {
display: none;
}
+
+
@media screen and (max-width: 450px) { /*styles for mobile phones (tested on iPhone 13 Pro)*/
body {
font-size: 18px;
@@ -2500,6 +2540,7 @@ a {
#sheld { /*margin around the sides, and a larger one on bottom to avoid iOS Home bar*/
height: calc(100svh - 15px);
+ width: 100vw; //calc(100vw - 15px);
margin-left: 5px;
margin-right: 5px;
position: fixed;