mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'SL-TAI-RA-Mods' into dev
This commit is contained in:
@ -1,2 +0,0 @@
|
|||||||
{"user_name":"You","character_name":"Aqua","create_date":1674559896839}
|
|
||||||
{"name":"Aqua","is_user":false,"is_name":true,"send_date":1674563371558,"mes":"*I am in the town square at a city named \"Axel\". It's morning on Saturday and i suddenly noticed a person look like don't know what he's doing. I approached to him and speak* Are you new here? Do you need help? Don't worry, I, aqua the goddess of water, shall help you! Do i look beautiful? *strikes a pose and look at him with puppy eyes*"}
|
|
@ -1,2 +0,0 @@
|
|||||||
{"user_name":"You","character_name":"Darkness","create_date":1674559899431}
|
|
||||||
{"name":"Darkness","is_user":false,"is_name":true,"send_date":1674564914912,"mes":"*It's a sunny day, in a big park on which there are many people, some walking and others lying in the sun. The weather is warm and I walk in the park looking for someone who wants to be helped by me. Suddenly realise that someone is looking at me.* Hello, I am Darkness, a Crusader, and would you like some help?"}
|
|
@ -1,2 +0,0 @@
|
|||||||
{"user_name":"You","character_name":"Megumin","create_date":1674559900991}
|
|
||||||
{"name":"Megumin","is_user":false,"is_name":true,"send_date":1674563153854,"mes":"*It was day, the weather was sunny and windless. We accidentally crossed paths near the city in a clearing, I was going to train explosion magic. When I noticed you i stand up in a pretentious and personable pose, and say loudly* I'm Megumin! The Arch Wizard of the Crimson Magic Clan! And i the best at explosion magic!! What are you doing here?"}
|
|
BIN
public/img/swipe_left.png
Normal file
BIN
public/img/swipe_left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 497 B |
BIN
public/img/swipe_right.png
Normal file
BIN
public/img/swipe_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 520 B |
@ -754,6 +754,8 @@
|
|||||||
</label>
|
</label>
|
||||||
<label for="force-pygmalion-formatting-checkbox"><input id="force-pygmalion-formatting-checkbox" type="checkbox" />
|
<label for="force-pygmalion-formatting-checkbox"><input id="force-pygmalion-formatting-checkbox" type="checkbox" />
|
||||||
<h4>Force Pygmalion formatting for any model</h4>
|
<h4>Force Pygmalion formatting for any model</h4>
|
||||||
|
<label for="swipes-checkbox"><input id="swipes-checkbox" type="checkbox" />
|
||||||
|
<h4>Swipes</h4>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
669
public/script.js
669
public/script.js
@ -125,7 +125,12 @@ const system_messages = {
|
|||||||
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 target="_blank" 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 href=\"https://github.com/TavernAI/TavernAI/wiki\">TavernAI Wiki</a>!</p>`,
|
||||||
},
|
},
|
||||||
welcome:
|
welcome:
|
||||||
{
|
{
|
||||||
@ -235,6 +240,8 @@ var if_typing_text = false;
|
|||||||
const tokens_cycle_count = 30;
|
const tokens_cycle_count = 30;
|
||||||
var cycle_count_generation = 0;
|
var cycle_count_generation = 0;
|
||||||
|
|
||||||
|
var swipes = false;
|
||||||
|
|
||||||
var anchor_order = 0;
|
var anchor_order = 0;
|
||||||
var style_anchor = true;
|
var style_anchor = true;
|
||||||
var character_anchor = true;
|
var character_anchor = true;
|
||||||
@ -490,15 +497,7 @@ function printCharacters() {
|
|||||||
this_avatar = "characters/" + item.avatar + "?" + Date.now();
|
this_avatar = "characters/" + item.avatar + "?" + Date.now();
|
||||||
} //RossAscends: changed 'prepend' to 'append' to make alphabetical sorting display correctly.
|
} //RossAscends: changed 'prepend' to 'append' to make alphabetical sorting display correctly.
|
||||||
$("#rm_print_characters_block").append(
|
$("#rm_print_characters_block").append(
|
||||||
"<div class=character_select chid=" +
|
`<div class=character_select chid=${i} id="CharID${i}"><div class=avatar><img src="${this_avatar}"></div><div class=ch_name>${item.name}</div></div>`
|
||||||
i +
|
|
||||||
' id="CharID' +
|
|
||||||
i +
|
|
||||||
'"><div class=avatar><img src="' +
|
|
||||||
this_avatar +
|
|
||||||
'"></div><div class=ch_name>' +
|
|
||||||
item.name +
|
|
||||||
"</div></div>"
|
|
||||||
);
|
);
|
||||||
//console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')');
|
//console.log('printcharacters() -- printing -- ChID '+i+' ('+item.name+')');
|
||||||
});
|
});
|
||||||
@ -778,18 +777,33 @@ function addOneMessage(mes) {
|
|||||||
);
|
);
|
||||||
const bias = messageFormating(mes.extra?.bias ?? "");
|
const bias = messageFormating(mes.extra?.bias ?? "");
|
||||||
|
|
||||||
$("#chat").append(
|
var HTMLForEachMes =
|
||||||
"<div class='mes' mesid=" +
|
'<div class="mes" mesid="' + count_view_mes + '" ch_name="' + characterName + '" is_user="' + mes["is_user"] + '">' +
|
||||||
count_view_mes +
|
'<div class="for_checkbox"></div>' +
|
||||||
" ch_name=" +
|
'<input type="checkbox" class="del_checkbox">' +
|
||||||
|
'<div class="avatar">' +
|
||||||
|
'<img src="' + avatarImg + '">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="swipe_left">' +
|
||||||
|
'<img src="img/swipe_left.png">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="mes_block">' +
|
||||||
|
'<div class="ch_name">' +
|
||||||
characterName +
|
characterName +
|
||||||
"><div class='for_checkbox'></div><input type='checkbox' class='del_checkbox'><div class=avatar><img src='" +
|
'<div title=Edit class=mes_edit></div>' +
|
||||||
avatarImg +
|
'<div class=mes_edit_cancel><img src=img/cancel.png></div>' +
|
||||||
"'></div><div class=mes_block><div class=ch_name>" +
|
'<div class=mes_edit_done><img src=img/done.png></div>' +
|
||||||
characterName +
|
'</div>' +
|
||||||
"<div title=Edit class=mes_edit></div><div class=mes_edit_cancel><img src=img/cancel.png></div><div class=mes_edit_done><img src=img/done.png></div></div><div class=mes_text>" +
|
'<div class=mes_text></div>' +
|
||||||
`</div><div class='mes_bias'>${bias}</div></div></div>`
|
'</div>' +
|
||||||
);
|
'<div class="mes_bias">' + bias + '</div>' +
|
||||||
|
'<div class="swipe_right">' +
|
||||||
|
' <img src="img/swipe_right.png">' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
if (type !== 'swipe') {
|
||||||
|
$("#chat").append(HTMLForEachMes);
|
||||||
|
}
|
||||||
|
|
||||||
const newMessage = $(`#chat [mesid="${count_view_mes}"]`);
|
const newMessage = $(`#chat [mesid="${count_view_mes}"]`);
|
||||||
newMessage.data("isSystem", isSystem);
|
newMessage.data("isSystem", isSystem);
|
||||||
@ -800,57 +814,64 @@ function addOneMessage(mes) {
|
|||||||
newMessage.find(".mes_edit").hide();
|
newMessage.find(".mes_edit").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
newMessage.find('.avatar img').on('error', function() {
|
newMessage.find('.avatar img').on('error', function () {
|
||||||
$(this).attr("src", "/img/user-slash-solid.svg");
|
$(this).attr("src", "/img/user-slash-solid.svg");
|
||||||
$(this).css('filter', 'invert(1)');
|
$(this).css('filter', 'invert(1)');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!if_typing_text) {
|
//////// swipecode inside addOneMessage - to keep swipes displayed while
|
||||||
//console.log(messageText);
|
// SWIPE BUTTON DISPLAY SHOULD BE HANDLED IN showSwipeButtons/hideSwipeButtons, not here. Commented out duplicate code.
|
||||||
$("#chat")
|
|
||||||
.children()
|
//console.log('addOneMessage -- type = '+type);
|
||||||
.filter('[mesid="' + count_view_mes + '"]')
|
if (type === 'swipe') {
|
||||||
.children(".mes_block")
|
//console.log('addOneMessage -- detected adding one swipe message')
|
||||||
.children(".mes_text")
|
$("#chat").children().filter('[mesid="' + (count_view_mes - 1) + '"]').children('.mes_block').children('.mes_text').html('');
|
||||||
.append(messageText);
|
$("#chat").children().filter('[mesid="' + (count_view_mes - 1) + '"]').children('.mes_block').children('.mes_text').append(messageText);
|
||||||
} else {
|
|
||||||
typeWriter(
|
/* if(mes['swipe_id'] !== 0 && swipes){
|
||||||
$("#chat")
|
console.log('addOneMessage -- swipe_id is not 0, adding both buttons');
|
||||||
.children()
|
$("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_right').css('display', 'flex');
|
||||||
.filter('[mesid="' + count_view_mes + '"]')
|
$("#chat").children().filter('[mesid="'+(count_view_mes-1)+'"]').children('.swipe_left').css('display', 'flex');
|
||||||
.children(".mes_block")
|
} */
|
||||||
.children(".mes_text"),
|
} else { //if this is not a display of a new swipe message..
|
||||||
messageText,
|
//console.log('addOneMessage -- adding message');
|
||||||
50,
|
$("#chat").children().filter('[mesid="' + count_view_mes + '"]').children('.mes_block').children('.mes_text').append(messageText);
|
||||||
0
|
//console.log('addOneMessage - hiding swipe buttons');
|
||||||
);
|
hideSwipeButtons(); //disabling this leaves buttons visibile on all messages, breaks swipes
|
||||||
|
//console.log('addOneMessage -- checking for swipes');
|
||||||
|
/* if(parseInt(chat.length-1) === parseInt(count_view_mes) && !mes['is_user'] && swipes){
|
||||||
|
console.log('chat length - 1 = '+(chat[chat.length-1]['mesid']));
|
||||||
|
if(chat[chat.length-1]['mesid'] !==undefined){
|
||||||
|
if(mes['swipe_id'] === undefined && count_view_mes !== 0){
|
||||||
|
console.log('addOneMessage -- no swipes here, showing right button for possible generation');
|
||||||
|
$("#chat").children().filter('[mesid="'+(count_view_mes)+'"]').children('.swipe_right').css('display', 'flex');
|
||||||
|
}else if(mes['swipe_id'] !== undefined){ // if swipes aren't undefined == swipes exist at this node
|
||||||
|
console.log('addOneMessage -- found swipes')
|
||||||
|
if(mes['swipe_id'] === 0){ //if we are viewing the first swipe message, display right
|
||||||
|
console.log('addOneMessage -- found lone swipe, displaying right button');
|
||||||
|
$("#chat").children().filter('[mesid="'+(count_view_mes)+'"]').children('.swipe_right').css('display', 'flex');
|
||||||
|
}else { // if swipe_id is more than 0, than means we must have multiple swipes, so show both items
|
||||||
|
console.log('addOneMessage -- found multiple swipes, showing both buttons');
|
||||||
|
$("#chat").children().filter('[mesid="'+(count_view_mes)+'"]').children('.swipe_right').css('display', 'flex');
|
||||||
|
$("#chat").children().filter('[mesid="'+(count_view_mes)+'"]').children('.swipe_left').css('display', 'flex');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{console.log('apparently no swipes found, and not a valid mesage to add hideSwipeButtons, so skipping');} */
|
||||||
|
count_view_mes++;
|
||||||
}
|
}
|
||||||
count_view_mes++;
|
/* } */
|
||||||
//console.log('add mes without animation = '+add_mes_without_animation);
|
// if(type !== 'swipe'){count_view_mes++;}
|
||||||
//console.log(!add_mes_without_animation);
|
|
||||||
if (!add_mes_without_animation) {
|
|
||||||
console.log('adding mes with animation')
|
|
||||||
//$('#chat').children().last().css('transition','all 2s ease-in-out');
|
|
||||||
$('#chat').children().last().css("opacity", "1");
|
|
||||||
//$('#chat').children().last().css('transition','all 2s ease-in-out');
|
|
||||||
|
|
||||||
|
|
||||||
}else {
|
|
||||||
console.log('add mes with animation was false, and is set to false again')
|
|
||||||
add_mes_without_animation = false;
|
|
||||||
}
|
|
||||||
var $textchat = $("#chat");
|
var $textchat = $("#chat");
|
||||||
|
$('#chat .mes').last().addClass('last_mes');
|
||||||
|
$('#chat .mes').eq(-2).removeClass('last_mes');
|
||||||
//$('#chat').children().last().css("opacity", "1");
|
//$('#chat').children().last().css("opacity", "1");
|
||||||
$textchat.scrollTop(($textchat[0].scrollHeight));
|
$textchat.scrollTop(($textchat[0].scrollHeight));
|
||||||
}
|
|
||||||
|
|
||||||
function typeWriter(target, text, speed, i) {
|
hideSwipeButtons(); //disabling this prevents left button from correctly removing on last message without swipe to the left...
|
||||||
if (i < text.length) {
|
showSwipeButtons();
|
||||||
//target.append(text.charAt(i));
|
|
||||||
target.html(target.html() + text.charAt(i));
|
|
||||||
i++;
|
|
||||||
setTimeout(() => typeWriter(target, text, speed, i), speed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function newMesPattern(name) {
|
function newMesPattern(name) {
|
||||||
@ -886,6 +907,7 @@ function sendSystemMessage(type, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chat.push(newMessage);
|
chat.push(newMessage);
|
||||||
|
console.log('sendSystemMessage calls addOneMessage');
|
||||||
addOneMessage(newMessage);
|
addOneMessage(newMessage);
|
||||||
is_send_press = false;
|
is_send_press = false;
|
||||||
}
|
}
|
||||||
@ -912,6 +934,7 @@ function extractMessageBias(message) {
|
|||||||
|
|
||||||
async function Generate(type, automatic_trigger) {
|
async function Generate(type, automatic_trigger) {
|
||||||
//encode("dsfs").length
|
//encode("dsfs").length
|
||||||
|
console.log('Generate entered');
|
||||||
tokens_already_generated = 0;
|
tokens_already_generated = 0;
|
||||||
message_already_generated = name2 + ": ";
|
message_already_generated = name2 + ": ";
|
||||||
|
|
||||||
@ -942,15 +965,14 @@ async function Generate(type, automatic_trigger) {
|
|||||||
if (chat[chat.length - 1]["is_user"]) {
|
if (chat[chat.length - 1]["is_user"]) {
|
||||||
//If last message from You
|
//If last message from You
|
||||||
} else {
|
} else {
|
||||||
//console.log('about to remove last msg')
|
|
||||||
chat.length = chat.length - 1;
|
chat.length = chat.length - 1;
|
||||||
count_view_mes -= 1;
|
count_view_mes -= 1;
|
||||||
//$('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
|
//$('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
|
||||||
//$('#chat').children().last().css({'transform':'translateX(100vh) scale(0.1,0.1)'});
|
//$('#chat').children().last().css({'transform':'translateX(100vh) scale(0.1,0.1)'});
|
||||||
//$('#chat').children().last().css({'opacity':'0'});
|
//$('#chat').children().last().css({'opacity':'0'});
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
$('#chat').children().last().remove();
|
$('#chat').children().last().remove();
|
||||||
},1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,9 +1004,11 @@ async function Generate(type, automatic_trigger) {
|
|||||||
var topAnchorDepth = 8;
|
var topAnchorDepth = 8;
|
||||||
|
|
||||||
if (character_anchor && !is_pygmalion) {
|
if (character_anchor && !is_pygmalion) {
|
||||||
|
console.log('saw not pyg');
|
||||||
if (anchor_order === 0) {
|
if (anchor_order === 0) {
|
||||||
anchorTop = name2 + " " + postAnchorChar;
|
anchorTop = name2 + " " + postAnchorChar;
|
||||||
} else {
|
} else {
|
||||||
|
console.log('saw pyg, adding anchors')
|
||||||
anchorBottom = "[" + name2 + " " + postAnchorChar + "]";
|
anchorBottom = "[" + name2 + " " + postAnchorChar + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1009,100 +1033,72 @@ async function Generate(type, automatic_trigger) {
|
|||||||
chat[chat.length - 1]["extra"] = {};
|
chat[chat.length - 1]["extra"] = {};
|
||||||
|
|
||||||
if (messageBias) {
|
if (messageBias) {
|
||||||
|
console.log('checking bias');
|
||||||
chat[chat.length - 1]["extra"]["bias"] = messageBias;
|
chat[chat.length - 1]["extra"]["bias"] = messageBias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Generate calls addOneMessage');
|
||||||
addOneMessage(chat[chat.length - 1]);
|
addOneMessage(chat[chat.length - 1]);
|
||||||
}
|
}
|
||||||
var chatString = "";
|
var chatString = "";
|
||||||
var arrMes = [];
|
var arrMes = [];
|
||||||
var mesSend = [];
|
var mesSend = [];
|
||||||
var charDescription = $.trim(characters[this_chid].description);
|
|
||||||
var charPersonality = $.trim(characters[this_chid].personality);
|
|
||||||
var Scenario = $.trim(characters[this_chid].scenario);
|
|
||||||
var mesExamples = $.trim(characters[this_chid].mes_example);
|
|
||||||
var checkMesExample = $.trim(mesExamples.replace(/<START>/gi, "")); //for check length without tag
|
|
||||||
if (checkMesExample.length == 0) mesExamples = "";
|
|
||||||
var mesExamplesArray = [];
|
var mesExamplesArray = [];
|
||||||
//***Base replace***
|
var charDescription = baseChatReplaceAndSplit($.trim(characters[this_chid].description), name1, name2);
|
||||||
if (mesExamples !== undefined) {
|
var charPersonality = baseChatReplaceAndSplit($.trim(characters[this_chid].personality), name1, name2);
|
||||||
if (mesExamples.length > 0) {
|
var Scenario = baseChatReplaceAndSplit($.trim(characters[this_chid].scenario), name1, name2);
|
||||||
|
var mesExamples = baseChatReplaceAndSplit($.trim(characters[this_chid].mes_example.replace(/<START>/gi, '')), name1, name2);
|
||||||
|
|
||||||
|
function baseChatReplaceAndSplit(value, name1, name2) {
|
||||||
|
if (value !== undefined && value.length > 0) {
|
||||||
if (is_pygmalion) {
|
if (is_pygmalion) {
|
||||||
mesExamples = mesExamples.replace(/{{user}}:/gi, "You:");
|
value = value.replace(/{{user}}:/gi, "You:");
|
||||||
mesExamples = mesExamples.replace(/<USER>:/gi, "You:");
|
value = value.replace(/<USER>:/gi, "You:");
|
||||||
}
|
}
|
||||||
mesExamples = mesExamples.replace(/{{user}}/gi, name1);
|
value = value.replace(/{{user}}/gi, name1);
|
||||||
mesExamples = mesExamples.replace(/{{char}}/gi, name2);
|
value = value.replace(/{{char}}/gi, name2);
|
||||||
mesExamples = mesExamples.replace(/<USER>/gi, name1);
|
value = value.replace(/<USER>/gi, name1);
|
||||||
mesExamples = mesExamples.replace(/<BOT>/gi, name2);
|
value = value.replace(/<BOT>/gi, name2);
|
||||||
//mesExamples = mesExamples.replaceAll('<START>', '[An example of how '+name2+' responds]');
|
let blocks = value.split(/<START>/gi);
|
||||||
let blocks = mesExamples.split(/<START>/gi);
|
return blocks.slice(1).map(block => `<START>\n${block.trim()}\n`).join('');
|
||||||
mesExamplesArray = blocks
|
|
||||||
.slice(1)
|
|
||||||
.map((block) => `<START>\n${block.trim()}\n`);
|
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
if (charDescription !== undefined) {
|
|
||||||
if (charDescription.length > 0) {
|
function appendToStoryString(value, prefix) {
|
||||||
charDescription = charDescription.replace(/{{user}}/gi, name1);
|
if (value !== undefined && value.length > 0) {
|
||||||
charDescription = charDescription.replace(/{{char}}/gi, name2);
|
return prefix + value + '\n';
|
||||||
charDescription = charDescription.replace(/<USER>/gi, name1);
|
|
||||||
charDescription = charDescription.replace(/<BOT>/gi, name2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (charPersonality !== undefined) {
|
|
||||||
if (charPersonality.length > 0) {
|
|
||||||
charPersonality = charPersonality.replace(/{{user}}/gi, name1);
|
|
||||||
charPersonality = charPersonality.replace(/{{char}}/gi, name2);
|
|
||||||
charPersonality = charPersonality.replace(/<USER>/gi, name1);
|
|
||||||
charPersonality = charPersonality.replace(/<BOT>/gi, name2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Scenario !== undefined) {
|
|
||||||
if (Scenario.length > 0) {
|
|
||||||
Scenario = Scenario.replace(/{{user}}/gi, name1);
|
|
||||||
Scenario = Scenario.replace(/{{char}}/gi, name2);
|
|
||||||
Scenario = Scenario.replace(/<USER>/gi, name1);
|
|
||||||
Scenario = Scenario.replace(/<BOT>/gi, name2);
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_pygmalion) {
|
if (is_pygmalion) {
|
||||||
if (charDescription.length > 0) {
|
storyString += appendToStoryString(charDescription, name2 + "'s Persona: ");
|
||||||
storyString = name2 + "'s Persona: " + charDescription + "\n";
|
storyString += appendToStoryString(charPersonality, 'Personality: ');
|
||||||
}
|
storyString += appendToStoryString(Scenario, 'Scenario: ');
|
||||||
if (charPersonality.length > 0) {
|
|
||||||
storyString += "Personality: " + charPersonality + "\n";
|
|
||||||
}
|
|
||||||
if (Scenario.length > 0) {
|
|
||||||
storyString += "Scenario: " + Scenario + "\n";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (charDescription !== undefined) {
|
if (charDescription !== undefined) {
|
||||||
if (charPersonality.length > 0) {
|
if (charPersonality.length > 0) {
|
||||||
charPersonality = name2 + "'s personality: " + charPersonality; //"["+name2+"'s personality: "+charPersonality+"]";
|
charPersonality = name2 + "'s personality: " + charPersonality;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (charDescription !== undefined) {
|
|
||||||
if ($.trim(charDescription).length > 0) {
|
|
||||||
if (
|
|
||||||
charDescription.slice(-1) !== "]" ||
|
|
||||||
charDescription.substr(0, 1) !== "["
|
|
||||||
) {
|
|
||||||
//charDescription = '['+charDescription+']';
|
|
||||||
}
|
|
||||||
storyString += charDescription + "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storyString += appendToStoryString(charDescription, '');
|
||||||
|
|
||||||
|
if (storyString.endsWith('\n')) {
|
||||||
|
storyString = storyString.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (count_view_mes < topAnchorDepth) {
|
if (count_view_mes < topAnchorDepth) {
|
||||||
storyString += charPersonality + "\n";
|
storyString += '\n' + appendToStoryString(charPersonality, '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var count_exm_add = 0;
|
var count_exm_add = 0;
|
||||||
|
console.log('emptying chat2');
|
||||||
var chat2 = [];
|
var chat2 = [];
|
||||||
var j = 0;
|
var j = 0;
|
||||||
|
console.log('pre-replace chat.length = ' + chat.length);
|
||||||
for (var i = chat.length - 1; i >= 0; i--) {
|
for (var i = chat.length - 1; i >= 0; i--) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
chat[j]["mes"] = chat[j]["mes"].replace(/{{user}}/gi, name1);
|
chat[j]["mes"] = chat[j]["mes"].replace(/{{user}}/gi, name1);
|
||||||
@ -1129,6 +1125,7 @@ async function Generate(type, automatic_trigger) {
|
|||||||
chat2[i] = (chat2[i] ?? "").replace(/{([^}]+)}/g, "");
|
chat2[i] = (chat2[i] ?? "").replace(/{([^}]+)}/g, "");
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
console.log('post replace chat.length = ' + chat.length);
|
||||||
//chat2 = chat2.reverse();
|
//chat2 = chat2.reverse();
|
||||||
var this_max_context = 1487;
|
var this_max_context = 1487;
|
||||||
if (main_api == "kobold") this_max_context = max_context;
|
if (main_api == "kobold") this_max_context = max_context;
|
||||||
@ -1147,6 +1144,16 @@ async function Generate(type, automatic_trigger) {
|
|||||||
|
|
||||||
let extension_prompt = getExtensionPrompt();
|
let extension_prompt = getExtensionPrompt();
|
||||||
|
|
||||||
|
/////////////////////// swipecode
|
||||||
|
if (type == 'swipe') {
|
||||||
|
|
||||||
|
console.log('pre swipe shift: ' + chat2.length);
|
||||||
|
console.log('shifting swipe chat2');
|
||||||
|
chat2.shift();
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log('post swipe shift:' + chat2.length);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
for (var item of chat2) {
|
for (var item of chat2) {
|
||||||
@ -1173,6 +1180,7 @@ async function Generate(type, automatic_trigger) {
|
|||||||
//if (is_pygmalion && i == chat2.length-1) item='<START>\n'+item;
|
//if (is_pygmalion && i == chat2.length-1) item='<START>\n'+item;
|
||||||
arrMes[arrMes.length] = item;
|
arrMes[arrMes.length] = item;
|
||||||
} else {
|
} else {
|
||||||
|
console.log('reducing chat.length by 1');
|
||||||
i = chat.length - 1;
|
i = chat.length - 1;
|
||||||
}
|
}
|
||||||
await delay(1); //For disable slow down (encode gpt-2 need fix)
|
await delay(1); //For disable slow down (encode gpt-2 need fix)
|
||||||
@ -1183,6 +1191,7 @@ async function Generate(type, automatic_trigger) {
|
|||||||
let mesExmString = "";
|
let mesExmString = "";
|
||||||
for (let iii = 0; iii < mesExamplesArray.length; iii++) {
|
for (let iii = 0; iii < mesExamplesArray.length; iii++) {
|
||||||
//mesExamplesArray It need to make from end to start
|
//mesExamplesArray It need to make from end to start
|
||||||
|
console.log('checking prompt tokens');
|
||||||
mesExmString = mesExmString + mesExamplesArray[iii];
|
mesExmString = mesExmString + mesExamplesArray[iii];
|
||||||
if (
|
if (
|
||||||
encode(
|
encode(
|
||||||
@ -1233,8 +1242,10 @@ async function Generate(type, automatic_trigger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runGenerate(cycleGenerationPromt = "") {
|
function runGenerate(cycleGenerationPromt = "") {
|
||||||
|
console.log('rungenerate entered');
|
||||||
generatedPromtCache += cycleGenerationPromt;
|
generatedPromtCache += cycleGenerationPromt;
|
||||||
if (generatedPromtCache.length == 0) {
|
if (generatedPromtCache.length == 0) {
|
||||||
|
console.log('generating prompt');
|
||||||
chatString = "";
|
chatString = "";
|
||||||
arrMes = arrMes.reverse();
|
arrMes = arrMes.reverse();
|
||||||
var is_add_personality = false;
|
var is_add_personality = false;
|
||||||
@ -1389,6 +1400,8 @@ async function Generate(type, automatic_trigger) {
|
|||||||
generatedPromtCache +
|
generatedPromtCache +
|
||||||
promptBias;
|
promptBias;
|
||||||
finalPromt = finalPromt.replace(/\r/gm, "");
|
finalPromt = finalPromt.replace(/\r/gm, "");
|
||||||
|
console.log('final prompt decided');
|
||||||
|
|
||||||
|
|
||||||
//if we aren't using the kobold GUI settings...
|
//if we aren't using the kobold GUI settings...
|
||||||
if (
|
if (
|
||||||
@ -1621,42 +1634,77 @@ async function Generate(type, automatic_trigger) {
|
|||||||
if (type === "force_name2") this_mes_is_name = true;
|
if (type === "force_name2") this_mes_is_name = true;
|
||||||
//getMessage = getMessage.replace(/^\s+/g, '');
|
//getMessage = getMessage.replace(/^\s+/g, '');
|
||||||
if (getMessage.length > 0) {
|
if (getMessage.length > 0) {
|
||||||
chat[chat.length] = {};
|
if (chat[chat.length - 1]['swipe_id'] === undefined ||
|
||||||
chat[chat.length - 1]["name"] = name2;
|
chat[chat.length - 1]['is_user']) { type = 'normal'; }
|
||||||
chat[chat.length - 1]["is_user"] = false;
|
if (type === 'swipe') {
|
||||||
chat[chat.length - 1]["is_name"] = this_mes_is_name;
|
|
||||||
chat[chat.length - 1]["send_date"] = humanizedDateTime();
|
|
||||||
getMessage = $.trim(getMessage);
|
|
||||||
chat[chat.length - 1]["mes"] = getMessage;
|
|
||||||
|
|
||||||
if (selected_group) {
|
chat[chat.length - 1]['swipes'][chat[chat.length - 1]['swipes'].length] = getMessage;
|
||||||
let avatarImg = default_avatar;
|
if (chat[chat.length - 1]['swipe_id'] === chat[chat.length - 1]['swipes'].length - 1) {
|
||||||
if (characters[this_chid].avatar != "none") {
|
//console.log(getMessage);
|
||||||
avatarImg = `characters/${characters[this_chid].avatar}?${Date.now()}`;
|
chat[chat.length - 1]['mes'] = getMessage;
|
||||||
|
console.log('runGenerate calls addOneMessage for swipe');
|
||||||
|
addOneMessage(chat[chat.length - 1], 'swipe');
|
||||||
|
} else {
|
||||||
|
chat[chat.length - 1]['mes'] = getMessage;
|
||||||
}
|
}
|
||||||
chat[chat.length - 1]["is_name"] = true;
|
is_send_press = false;
|
||||||
chat[chat.length - 1]["force_avatar"] = avatarImg;
|
|
||||||
}
|
|
||||||
|
|
||||||
addOneMessage(chat[chat.length - 1]);
|
|
||||||
$("#send_but").css("display", "inline");
|
|
||||||
$("#loading_mes").css("display", "none");
|
|
||||||
|
|
||||||
if (selected_group) {
|
|
||||||
saveGroupChat(selected_group);
|
|
||||||
} else {
|
} else {
|
||||||
saveChat();
|
console.log('entering chat update routine for non-swipe post');
|
||||||
|
is_send_press = false;
|
||||||
|
chat[chat.length] = {};
|
||||||
|
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"] = humanizedDateTime();
|
||||||
|
getMessage = $.trim(getMessage);
|
||||||
|
chat[chat.length - 1]["mes"] = getMessage;
|
||||||
|
|
||||||
|
if (selected_group) {
|
||||||
|
console.log('entering chat update for groups');
|
||||||
|
let avatarImg = default_avatar;
|
||||||
|
if (characters[this_chid].avatar != "none") {
|
||||||
|
avatarImg = `characters/${characters[this_chid].avatar}?${Date.now()}`;
|
||||||
|
}
|
||||||
|
chat[chat.length - 1]["is_name"] = true;
|
||||||
|
chat[chat.length - 1]["force_avatar"] = avatarImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('runGenerate calls addOneMessage');
|
||||||
|
addOneMessage(chat[chat.length - 1]);
|
||||||
|
console.log('should hide loading mes and return with send button now');
|
||||||
|
$("#send_but").css("display", "inline");
|
||||||
|
$("#loading_mes").css("display", "none");
|
||||||
|
|
||||||
|
if (selected_group) {
|
||||||
|
saveGroupChat(selected_group);
|
||||||
|
} /*else {
|
||||||
|
saveChat();
|
||||||
|
}*/
|
||||||
|
//console.log('/savechat called by /Generate');
|
||||||
|
//let final_message_length = encode(JSON.stringify(getMessage)).length;
|
||||||
|
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
|
||||||
}
|
}
|
||||||
//console.log('/savechat called by /Generate');
|
}
|
||||||
//let final_message_length = encode(JSON.stringify(getMessage)).length;
|
else {
|
||||||
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
|
|
||||||
} else {
|
|
||||||
Generate("force_name2");
|
Generate("force_name2");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.log('final re-setting of send button due to error');
|
||||||
$("#send_but").css("display", "inline");
|
$("#send_but").css("display", "inline");
|
||||||
$("#loading_mes").css("display", "none");
|
$("#loading_mes").css("display", "none");
|
||||||
|
showSwipeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('/savechat called by /Generate');
|
||||||
|
saveChat();
|
||||||
|
//let final_message_length = encode(JSON.stringify(getMessage)).length;
|
||||||
|
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
|
||||||
|
|
||||||
|
$("#send_but").css("display", "inline");
|
||||||
|
console.log('attempting to show swipes');
|
||||||
|
showSwipeButtons();
|
||||||
|
|
||||||
|
$("#loading_mes").css("display", "none");
|
||||||
},
|
},
|
||||||
error: function (jqXHR, exception) {
|
error: function (jqXHR, exception) {
|
||||||
$("#send_textarea").removeAttr("disabled");
|
$("#send_textarea").removeAttr("disabled");
|
||||||
@ -1758,10 +1806,13 @@ async function saveChat() {
|
|||||||
alert('Trying to save group chat with regular saveChat function. Aborting to prevent corruption.');
|
alert('Trying to save group chat with regular saveChat function. Aborting to prevent corruption.');
|
||||||
throw new Error('Group chat saved from saveChat');
|
throw new Error('Group chat saved from saveChat');
|
||||||
}
|
}
|
||||||
if (item["is_user"]) {
|
if (item.is_user) {
|
||||||
var str = item["mes"].replace(name1 + ":", default_user_name + ":");
|
var str = item.mes.replace(`${name1}:`, `${default_user_name}:`);
|
||||||
chat[i]["mes"] = str;
|
chat[i].mes = str;
|
||||||
chat[i]["name"] = default_user_name;
|
chat[i].name = default_user_name;
|
||||||
|
} else if (i !== chat.length - 1 && chat[i].swipe_id !== undefined) {
|
||||||
|
delete chat[i].swipes;
|
||||||
|
delete chat[i].swipe_id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var save_chat = [
|
var save_chat = [
|
||||||
@ -1836,12 +1887,8 @@ async function getChat() {
|
|||||||
//console.log(data);
|
//console.log(data);
|
||||||
//chat.length = 0;
|
//chat.length = 0;
|
||||||
if (data[0] !== undefined) {
|
if (data[0] !== undefined) {
|
||||||
for (let key in data) {
|
chat.push(...response);
|
||||||
chat.push(data[key]);
|
chat_create_date = chat[0]['create_date'];
|
||||||
}
|
|
||||||
//chat = data;
|
|
||||||
chat_create_date = chat[0]["create_date"];
|
|
||||||
//console.log('/getchat saw chat_create_date: '+chat_create_date);
|
|
||||||
chat.shift();
|
chat.shift();
|
||||||
} else {
|
} else {
|
||||||
chat_create_date = humanizedDateTime();
|
chat_create_date = humanizedDateTime();
|
||||||
@ -1860,25 +1907,22 @@ async function getChat() {
|
|||||||
function getChatResult() {
|
function getChatResult() {
|
||||||
name2 = characters[this_chid].name;
|
name2 = characters[this_chid].name;
|
||||||
if (chat.length > 1) {
|
if (chat.length > 1) {
|
||||||
chat.forEach(function (item, i) {
|
for (let i = 0; i < chat.length; i++) {
|
||||||
|
const item = chat[i];
|
||||||
if (item["is_user"]) {
|
if (item["is_user"]) {
|
||||||
var str = item["mes"].replace(default_user_name + ":", name1 + ":");
|
item['mes'] = item['mes'].replace(default_user_name + ':', name1 + ':');
|
||||||
chat[i]["mes"] = str;
|
item['name'] = name1;
|
||||||
chat[i]["name"] = name1;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
//console.log(characters[this_chid].first_mes);
|
|
||||||
chat[0] = {};
|
|
||||||
chat[0]["name"] = name2;
|
|
||||||
chat[0]["is_user"] = false;
|
|
||||||
chat[0]["is_name"] = true;
|
|
||||||
chat[0]["send_date"] = humanizedDateTime();
|
|
||||||
if (characters[this_chid].first_mes != "") {
|
|
||||||
chat[0]["mes"] = characters[this_chid].first_mes;
|
|
||||||
} else {
|
|
||||||
chat[0]["mes"] = default_ch_mes;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const firstMes = characters[this_chid].first_mes || default_ch_mes;
|
||||||
|
chat[0] = {
|
||||||
|
name: name2,
|
||||||
|
is_user: false,
|
||||||
|
is_name: true,
|
||||||
|
send_date: humanizedDateTime(),
|
||||||
|
mes: firstMes
|
||||||
|
};
|
||||||
}
|
}
|
||||||
printMessages();
|
printMessages();
|
||||||
select_selected_character(this_chid);
|
select_selected_character(this_chid);
|
||||||
@ -2104,6 +2148,12 @@ async function getSettings(type) {
|
|||||||
$("#rep_pen_size").val(rep_pen_size);
|
$("#rep_pen_size").val(rep_pen_size);
|
||||||
$("#rep_pen_size_counter").html(rep_pen_size + " Tokens");
|
$("#rep_pen_size_counter").html(rep_pen_size + " Tokens");
|
||||||
|
|
||||||
|
swipes = !!settings.swipes; //// swipecode
|
||||||
|
$('#swipes-checkbox').prop('checked', swipes); /// swipecode
|
||||||
|
console.log('getSettings -- swipes = ' + swipes + '. toggling box');
|
||||||
|
hideSwipeButtons();
|
||||||
|
showSwipeButtons();
|
||||||
|
|
||||||
//Novel
|
//Novel
|
||||||
temp_novel = settings.temp_novel;
|
temp_novel = settings.temp_novel;
|
||||||
rep_pen_novel = settings.rep_pen_novel;
|
rep_pen_novel = settings.rep_pen_novel;
|
||||||
@ -2265,6 +2315,7 @@ async function saveSettings(type) {
|
|||||||
world_info_budget: world_info_budget,
|
world_info_budget: world_info_budget,
|
||||||
active_character: active_character,
|
active_character: active_character,
|
||||||
textgenerationwebui_settings: textgenerationwebui_settings,
|
textgenerationwebui_settings: textgenerationwebui_settings,
|
||||||
|
swipes: swipes,
|
||||||
}),
|
}),
|
||||||
beforeSend: function () {
|
beforeSend: function () {
|
||||||
//console.log('saveSettings() -- active_character -- '+active_character);
|
//console.log('saveSettings() -- active_character -- '+active_character);
|
||||||
@ -2771,6 +2822,238 @@ window["TavernAI"].getContext = function () {
|
|||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$('#swipes-checkbox').change(function () {
|
||||||
|
console.log('detected swipes-checkbox changed values')
|
||||||
|
swipes = !!$('#swipes-checkbox').prop('checked');
|
||||||
|
if (swipes) {
|
||||||
|
showSwipeButtons();
|
||||||
|
} else {
|
||||||
|
hideSwipeButtons();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
///// SWIPE BUTTON CLICKS ///////
|
||||||
|
|
||||||
|
$(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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("#character_search_bar").on("input", function () {
|
$("#character_search_bar").on("input", function () {
|
||||||
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(',');
|
||||||
const searchValue = $(this).val().trim().toLowerCase();
|
const searchValue = $(this).val().trim().toLowerCase();
|
||||||
@ -2790,8 +3073,8 @@ $(document).ready(function () {
|
|||||||
window.open("https://boosty.to/tavernai", "_blank");
|
window.open("https://boosty.to/tavernai", "_blank");
|
||||||
});
|
});
|
||||||
$("#send_but").click(function () {
|
$("#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) {
|
if (is_send_press == false) {
|
||||||
|
hideSwipeButtons();
|
||||||
is_send_press = true;
|
is_send_press = true;
|
||||||
|
|
||||||
Generate();
|
Generate();
|
||||||
@ -2806,12 +3089,8 @@ $(document).ready(function () {
|
|||||||
//maybe a way to simulate this would be to disable the eventListener for people iOS.
|
//maybe a way to simulate this would be to disable the eventListener for people iOS.
|
||||||
|
|
||||||
$("#send_textarea").keydown(function (e) {
|
$("#send_textarea").keydown(function (e) {
|
||||||
if (
|
if (!e.shiftKey && !e.ctrlKey && e.key == "Enter" && is_send_press == false) {
|
||||||
!e.shiftKey &&
|
hideSwipeButtons();
|
||||||
!e.ctrlKey &&
|
|
||||||
e.key == "Enter" &&
|
|
||||||
is_send_press == false
|
|
||||||
) {
|
|
||||||
is_send_press = true;
|
is_send_press = true;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
Generate();
|
Generate();
|
||||||
@ -3467,6 +3746,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$("#option_regenerate").click(function () {
|
$("#option_regenerate").click(function () {
|
||||||
if (is_send_press == false) {
|
if (is_send_press == false) {
|
||||||
|
hideSwipeButtons();
|
||||||
is_send_press = true;
|
is_send_press = true;
|
||||||
Generate("regenerate");
|
Generate("regenerate");
|
||||||
}
|
}
|
||||||
@ -3474,6 +3754,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
// this function hides the input form, and shows the delete/cancel buttons for deleting messages from chat
|
// this function hides the input form, and shows the delete/cancel buttons for deleting messages from chat
|
||||||
$("#option_delete_mes").click(function () {
|
$("#option_delete_mes").click(function () {
|
||||||
|
hideSwipeButtons();
|
||||||
if (
|
if (
|
||||||
(this_chid != undefined && !is_send_press) ||
|
(this_chid != undefined && !is_send_press) ||
|
||||||
(selected_group && !is_group_generating)
|
(selected_group && !is_group_generating)
|
||||||
@ -3500,6 +3781,7 @@ $(document).ready(function () {
|
|||||||
$(this).prop("checked", false);
|
$(this).prop("checked", false);
|
||||||
});
|
});
|
||||||
this_del_mes = 0;
|
this_del_mes = 0;
|
||||||
|
showSwipeButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
//confirms message delation with the "ok" button
|
//confirms message delation with the "ok" button
|
||||||
@ -3528,6 +3810,9 @@ $(document).ready(function () {
|
|||||||
$textchat.scrollTop($textchat[0].scrollHeight);
|
$textchat.scrollTop($textchat[0].scrollHeight);
|
||||||
}
|
}
|
||||||
this_del_mes = 0;
|
this_del_mes = 0;
|
||||||
|
$('#chat .mes').last().addClass('last_mes');
|
||||||
|
$('#chat .mes').eq(-2).removeClass('last_mes');
|
||||||
|
showSwipeButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#settings_perset").change(function () {
|
$("#settings_perset").change(function () {
|
||||||
@ -3778,6 +4063,16 @@ $(document).ready(function () {
|
|||||||
.children(".mes_block")
|
.children(".mes_block")
|
||||||
.children(".ch_name")
|
.children(".ch_name")
|
||||||
.children(".mes_edit_done");
|
.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);
|
messageEditDone(mes_edited);
|
||||||
}
|
}
|
||||||
$(this).parent().parent().children(".mes_text").empty();
|
$(this).parent().parent().children(".mes_text").empty();
|
||||||
|
@ -40,7 +40,21 @@ var create_save_scenario;
|
|||||||
var create_save_mes_example;
|
var create_save_mes_example;
|
||||||
var count_tokens;
|
var count_tokens;
|
||||||
var perm_tokens;
|
var perm_tokens;
|
||||||
var ALC_Done;
|
|
||||||
|
const observerConfig = { childList: true, subtree: true };
|
||||||
|
|
||||||
|
const observer = new MutationObserver(function(mutations) {
|
||||||
|
mutations.forEach(function(mutation) {
|
||||||
|
if (mutation.target.id === "online_status_text2") {
|
||||||
|
RA_checkOnlineStatus();
|
||||||
|
} else if (mutation.target.parentNode === SelectedCharacterTab) {
|
||||||
|
setTimeout(RA_CountCharTokens, 200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.documentElement, observerConfig);
|
||||||
|
|
||||||
|
|
||||||
//RossAscends: Added function to format dates used in files and chat timestamps to a humanized format.
|
//RossAscends: Added function to format dates used in files and chat timestamps to a humanized format.
|
||||||
//Mostly I wanted this to be for file names, but couldn't figure out exactly where the filename save code was as everything seemed to be connected.
|
//Mostly I wanted this to be for file names, but couldn't figure out exactly where the filename save code was as everything seemed to be connected.
|
||||||
@ -64,7 +78,6 @@ export function humanizedDateTime() {
|
|||||||
return HumanizedDateTime;
|
return HumanizedDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
//RA_CountCharTokens -- faster counting characters. Works for unsaved characters, and counts permanent and ephemeral tokens separately.
|
|
||||||
|
|
||||||
// triggers:
|
// triggers:
|
||||||
$("#rm_button_create").on("click", function () { //when "+New Character" is clicked
|
$("#rm_button_create").on("click", function () { //when "+New Character" is clicked
|
||||||
@ -79,15 +92,8 @@ $("#rm_button_create").on("click", function () { //when "+New Character" is
|
|||||||
create_save_mes_example="";
|
create_save_mes_example="";
|
||||||
$("#result_info").html('Type to start counting tokens!');
|
$("#result_info").html('Type to start counting tokens!');
|
||||||
});
|
});
|
||||||
$(SelectedCharacterTab).children("h2").on("DOMSubtreeModified", function () { // when the nav's 3rd panel tab header changes (when a char is selected from the char list)
|
|
||||||
//console.log('3rd tab name changed - counting tokens');
|
|
||||||
//SaveLocal('ActiveChar',active_character);
|
|
||||||
setTimeout(RA_CountCharTokens,200); //delay to allow textareas to fill out, so we don't show a previous char's count
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#rm_ch_create_block").on("input", function () {RA_CountCharTokens();}); //when any input is made to the create/edit character form textareas
|
$("#rm_ch_create_block").on("input", function () {RA_CountCharTokens();}); //when any input is made to the create/edit character form textareas
|
||||||
$("#character_popup").on("input", function () {RA_CountCharTokens();}); //when any input is made to the advanced editing popup textareas
|
$("#character_popup").on("input", function () {RA_CountCharTokens();}); //when any input is made to the advanced editing popup textareas
|
||||||
|
|
||||||
//function:
|
//function:
|
||||||
function RA_CountCharTokens() {
|
function RA_CountCharTokens() {
|
||||||
$("#result_info").html("");
|
$("#result_info").html("");
|
||||||
@ -151,9 +157,6 @@ function RA_CountCharTokens() {
|
|||||||
$("#result_info").html(count_tokens + " Tokens (" + perm_tokens + " Permanent Tokens)"); //display normal if both counts are under 1024
|
$("#result_info").html(count_tokens + " Tokens (" + perm_tokens + " Permanent Tokens)"); //display normal if both counts are under 1024
|
||||||
} else {$("#result_info").html("<font color=red>" +count_tokens +" Tokens (" +perm_tokens +" Permanent Tokens)(TOO MANY)</font>");} //warn if either are over 1024
|
} else {$("#result_info").html("<font color=red>" +count_tokens +" Tokens (" +perm_tokens +" Permanent Tokens)(TOO MANY)</font>");} //warn if either are over 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Auto Load Last Charcter -- (fires when active_character is defined and auto_load_chat is true)
|
//Auto Load Last Charcter -- (fires when active_character is defined and auto_load_chat is true)
|
||||||
async function RA_autoloadchat() {
|
async function RA_autoloadchat() {
|
||||||
if (document.getElementById('CharID0') !== null){
|
if (document.getElementById('CharID0') !== null){
|
||||||
@ -170,7 +173,6 @@ async function RA_autoloadchat() {
|
|||||||
setTimeout(RA_autoloadchat,100) // if the charcter list hadn't been loaded yet, try again.
|
setTimeout(RA_autoloadchat,100) // if the charcter list hadn't been loaded yet, try again.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//only triggers when AutoLoadChat is enabled, consider adding this as an independent feature later.
|
//only triggers when AutoLoadChat is enabled, consider adding this as an independent feature later.
|
||||||
function RestoreNavTab(){
|
function RestoreNavTab(){
|
||||||
if($(rm_button_selected_ch).children("h2").text()!==''){ //check for a change in the character edit tab name
|
if($(rm_button_selected_ch).children("h2").text()!==''){ //check for a change in the character edit tab name
|
||||||
@ -180,9 +182,7 @@ function RestoreNavTab(){
|
|||||||
setTimeout(RestoreNavTab,100) //if not changed yet, check again after 100ms
|
setTimeout(RestoreNavTab,100) //if not changed yet, check again after 100ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//changes input bar and send button display depending on connection status
|
//changes input bar and send button display depending on connection status
|
||||||
$("#online_status_text2").on("DOMSubtreeModified", function () {RA_checkOnlineStatus();});
|
|
||||||
function RA_checkOnlineStatus() {
|
function RA_checkOnlineStatus() {
|
||||||
if (online_status == "no_connection") {
|
if (online_status == "no_connection") {
|
||||||
$("#send_textarea").attr("placeholder", "Not connected to API!"); //Input bar placeholder tells users they are not connected
|
$("#send_textarea").attr("placeholder", "Not connected to API!"); //Input bar placeholder tells users they are not connected
|
||||||
@ -199,66 +199,44 @@ function RA_checkOnlineStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Auto-connect to API (when set to kobold, API URL exists, and auto_connect is true)
|
//Auto-connect to API (when set to kobold, API URL exists, and auto_connect is true)
|
||||||
function RA_autoconnect() {
|
|
||||||
//console.log('RA_AC -- starting..')
|
|
||||||
if(online_status !== undefined && api_server !== ''){
|
|
||||||
if (online_status == "no_connection") {
|
|
||||||
if (LoadLocalBool('AutoConnectEnabled') === true) {
|
|
||||||
if (main_api === "kobold") {
|
|
||||||
if (api_server !== "") {
|
|
||||||
$("#api_url_text").val(api_server);
|
|
||||||
console.log('clicking API-button');
|
|
||||||
$("#api_button").click();
|
|
||||||
//console.log("clicked KAI connect for you");
|
|
||||||
} else {
|
|
||||||
console.log(main_api+' '+api_server);
|
|
||||||
console.log("RA_AC - KAI API not specificed");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//console.log("RA_AC - not kobold. skipping to novel.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (main_api === "novel") {
|
function RA_autoconnect() {
|
||||||
if (api_key_novel !== "") {
|
if (typeof online_status !== 'undefined' && (api_server !== '' || api_key_novel !== '')) {
|
||||||
$("#api_key_novel").val(api_key_novel);
|
if (online_status === "no_connection" && LoadLocalBool('AutoConnectEnabled')) {
|
||||||
console.log('clicking novel API-button');
|
if (isUrlOrAPIKey(api_server) && main_api === "kobold") {
|
||||||
$("#api_button").click();
|
$("#api_url_text").val(api_server);
|
||||||
// console.log("clicked NAI connect for you");
|
$("#api_button").click();
|
||||||
} else {
|
//} else if (isUrlOrAPIKey(api_key_novel) && main_api === "novel") {
|
||||||
console.log("RA_AC - no novel API key");
|
// $("#api_key_novel").val(api_key_novel);
|
||||||
}
|
// $("#api_button").click();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log("RA_AC - is disabled. stopping.");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("RA_AC -- Already online, nothing to do.");
|
setTimeout(RA_autoconnect, 100);
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
console.log('RA_AC -- settings not loaded yet...trying again..');
|
|
||||||
setTimeout(RA_autoconnect,100);
|
|
||||||
} // if onlinbe_staus hadn't been declared yet, try again..
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function isUrlOrAPIKey(string) {
|
||||||
|
//const pattern = /^\d{3}-\d{3}-\d{3}-\d{3}$/; //need a sample novelAI key to set this format
|
||||||
|
try {
|
||||||
|
new URL(string);
|
||||||
|
return true;
|
||||||
|
} catch (_) {
|
||||||
|
// return pattern.test(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("document").ready(function () {
|
$("document").ready(function () {
|
||||||
|
|
||||||
// read the state of Nav Lock and whether the nav was open or not before page load.
|
// read the state of Nav Lock and whether the nav was open or not before page load.
|
||||||
$(PanelPin).prop('checked', LoadLocalBool("NavLockOn"));
|
$(PanelPin).prop('checked', LoadLocalBool("NavLockOn"));
|
||||||
if (LoadLocalBool("NavLockOn") == true){
|
if (LoadLocalBool("NavLockOn") == true){$(NavToggle).prop("checked", LoadLocalBool("NavOpened"));}
|
||||||
$(NavToggle).prop("checked", LoadLocalBool("NavOpened"));
|
|
||||||
}
|
|
||||||
// read the state of AutoConnect and AutoLoadChat.
|
// read the state of AutoConnect and AutoLoadChat.
|
||||||
$(AutoConnectCheckbox).prop("checked",LoadLocalBool("AutoConnectEnabled"));
|
$(AutoConnectCheckbox).prop("checked",LoadLocalBool("AutoConnectEnabled"));
|
||||||
$(AutoLoadChatCheckbox).prop("checked",LoadLocalBool("AutoLoadChatEnabled"));
|
$(AutoLoadChatCheckbox).prop("checked",LoadLocalBool("AutoLoadChatEnabled"));
|
||||||
|
|
||||||
|
if (LoadLocalBool('AutoLoadChatEnabled') == true) {RA_autoloadchat();}
|
||||||
if (LoadLocalBool('AutoLoadChatEnabled') == true) {
|
|
||||||
console.log('calling RA_ALC');
|
|
||||||
RA_autoloadchat();
|
|
||||||
}
|
|
||||||
//Autoconnect on page load if enabled, or when api type is changed
|
//Autoconnect on page load if enabled, or when api type is changed
|
||||||
if (LoadLocalBool("AutoConnectEnabled") == true) {RA_autoconnect()}
|
if (LoadLocalBool("AutoConnectEnabled") == true) {RA_autoconnect()}
|
||||||
$("#main_api").change(function () {RA_autoconnect();});
|
$("#main_api").change(function () {RA_autoconnect();});
|
||||||
@ -266,92 +244,59 @@ $("document").ready(function () {
|
|||||||
|
|
||||||
//close the RightNav panel when user clicks outside of it or related panels (adv editing popup, or dialog popups)
|
//close the RightNav panel when user clicks outside of it or related panels (adv editing popup, or dialog popups)
|
||||||
$("html").click(function (e) {
|
$("html").click(function (e) {
|
||||||
//console.log('clicking'+$(this));
|
if ($(NavToggle).prop("checked") &&
|
||||||
if ($(NavToggle).prop("checked") === true && $(PanelPin).prop("checked") === false) {
|
!$(PanelPin).prop("checked") &&
|
||||||
if ($(e.target).attr("id") !== "nav-toggle") {
|
$(e.target).attr("id") !== "nav-toggle" &&
|
||||||
if (RightNavPanel.contains(e.target) === false) {
|
!RightNavPanel.contains(e.target) &&
|
||||||
if (AdvancedCharDefsPopup.contains(e.target) === false) {
|
!AdvancedCharDefsPopup.contains(e.target) &&
|
||||||
if (ConfirmationPopup.contains(e.target) === false) {
|
!ConfirmationPopup.contains(e.target)) {
|
||||||
NavToggle.click();
|
NavToggle.click();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//save NavLock prefs and record state of the Nav being open or closed
|
//save NavLock prefs and record state of the Nav being open or closed
|
||||||
$(NavToggle).on("change", function () {
|
$(NavToggle).on("change", function () {SaveLocal("NavOpened", $(NavToggle).prop("checked")); });
|
||||||
SaveLocal("NavOpened", $(NavToggle).prop("checked"));
|
$(PanelPin).on("change",function () {SaveLocal("NavLockOn", $(PanelPin).prop("checked")); });
|
||||||
});
|
|
||||||
$(PanelPin).on("change",function () {
|
|
||||||
SaveLocal("NavLockOn", $(PanelPin).prop("checked"));
|
|
||||||
});
|
|
||||||
|
|
||||||
//save AutoConnect and AutoLoadChat prefs
|
//save AutoConnect and AutoLoadChat prefs
|
||||||
$(AutoConnectCheckbox).on("change",function () {
|
$(AutoConnectCheckbox).on("change",function () {SaveLocal("AutoConnectEnabled", $(AutoConnectCheckbox).prop("checked")); });
|
||||||
SaveLocal("AutoConnectEnabled", $(AutoConnectCheckbox).prop("checked"));
|
$(AutoLoadChatCheckbox).on("change",function () {SaveLocal("AutoLoadChatEnabled", $(AutoLoadChatCheckbox).prop("checked")); });
|
||||||
});
|
|
||||||
$(AutoLoadChatCheckbox).on("change",function () {
|
|
||||||
SaveLocal("AutoLoadChatEnabled", $(AutoLoadChatCheckbox).prop("checked"));
|
|
||||||
});
|
|
||||||
|
|
||||||
//save the clicked Nav Tab as the tab to auto-open on page reload
|
|
||||||
$("#rm_button_settings").click( function (){
|
|
||||||
SaveLocal('SelectedNavTab','rm_button_settings');
|
|
||||||
});
|
|
||||||
$(SelectedCharacterTab).click(function () {
|
|
||||||
console.log('3rd tab clicked - saving selnavtab');
|
|
||||||
//SaveLocal('ActiveChar',this_chid);
|
|
||||||
SaveLocal('SelectedNavTab','rm_button_selected_ch');
|
|
||||||
});
|
|
||||||
$("#rm_button_extensions").click(function() {
|
$("#rm_button_extensions").click(function() {
|
||||||
SaveLocal('SelectedNavTab','rm_button_extensions');
|
SaveLocal('SelectedNavTab','rm_button_extensions');
|
||||||
});
|
});
|
||||||
|
$("#rm_button_settings").click( function (){SaveLocal('SelectedNavTab','rm_button_settings'); });
|
||||||
|
$(SelectedCharacterTab).click(function () {SaveLocal('SelectedNavTab','rm_button_selected_ch'); });
|
||||||
$("#rm_button_characters").click( function () { //if char list is clicked, in addition to saving it...
|
$("#rm_button_characters").click( function () { //if char list is clicked, in addition to saving it...
|
||||||
SaveLocal('SelectedNavTab','rm_button_characters');
|
SaveLocal('SelectedNavTab','rm_button_characters');
|
||||||
characters.sort(Intl.Collator().compare); // we sort the list
|
characters.sort(Intl.Collator().compare); // we sort the list
|
||||||
});
|
});
|
||||||
// when a char is selected from the list, save them as the auto-load character for next page load
|
// when a char is selected from the list, save them as the auto-load character for next page load
|
||||||
$(document).on("click", ".character_select",function () {
|
$(document).on("click", ".character_select",function () {SaveLocal('ActiveChar',$(this).attr('chid')); });
|
||||||
console.log('char clicked in charlist - saving local activechar');
|
|
||||||
SaveLocal('ActiveChar',$(this).attr('chid'));
|
|
||||||
});
|
|
||||||
|
|
||||||
//this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
//this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
||||||
$('#send_textarea').on('input', function () {
|
$('#send_textarea').on('input', function () {
|
||||||
this.style.height = '40px';
|
this.style.height = '40px';
|
||||||
this.style.height =
|
this.style.height = (this.scrollHeight) + 'px';
|
||||||
(this.scrollHeight) + 'px';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Regenerate if user swipes on the last mesage in chat
|
//Regenerate if user swipes on the last mesage in chat
|
||||||
//TODO:
|
|
||||||
//1. Make it detect if the last message is from user, and ignore swipes then...
|
|
||||||
//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) {
|
document.addEventListener('swiped-left', function(e) {
|
||||||
var SwipeTargetMesClassParent = e.target.closest('.mes');
|
var SwipeButR = $('.swipe_right:last');
|
||||||
if (is_send_press == false){
|
var SwipeTargetMesClassParent = e.target.closest('.last_mes');
|
||||||
if (SwipeTargetMesClassParent !== null && SwipeTargetMesClassParent.nextSibling == null ){
|
if (SwipeTargetMesClassParent !== null){
|
||||||
$('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
|
if(SwipeButR.attr('style')=='display: flex;' == true){
|
||||||
$('#chat').children().last().css({'transform':'translateX(-100vw) scale(0,0)','overflow':'hidden'});
|
SwipeButR.click();
|
||||||
$('#chat').children().last().css({'opacity':'0'});
|
|
||||||
|
|
||||||
Generate('regenerate');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.addEventListener('swiped-right', function(e) {
|
document.addEventListener('swiped-right', function(e) {
|
||||||
var SwipeTargetMesClassParent = e.target.closest('.mes');
|
var SwipeButL = $('.swipe_left:last');
|
||||||
console.log(is_send_press);
|
var SwipeTargetMesClassParent = e.target.closest('.last_mes');
|
||||||
if (is_send_press === false){
|
if (SwipeTargetMesClassParent !== null){
|
||||||
if (SwipeTargetMesClassParent !== null && SwipeTargetMesClassParent.nextSibling == null){
|
if(SwipeButL.attr('style')=='display: flex;' == true){
|
||||||
$('#chat').children().last().css({'transition':'all 0.5s ease-in-out'});
|
SwipeButL.click();
|
||||||
$('#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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -377,6 +322,12 @@ $("document").ready(function () {
|
|||||||
if (event.ctrlKey && event.key == "ArrowRight") { //for debug, empty local storage state
|
if (event.ctrlKey && event.key == "ArrowRight") { //for debug, empty local storage state
|
||||||
ClearLocal();
|
ClearLocal();
|
||||||
}
|
}
|
||||||
|
if (event.key == "ArrowLeft") { //swipes left
|
||||||
|
$('.swipe_left:last').click();
|
||||||
|
}
|
||||||
|
if (event.key == "ArrowRight") { //swipes right
|
||||||
|
$('.swipe_right:last').click();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -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}}
|
{"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}
|
@ -345,13 +345,50 @@ code {
|
|||||||
|
|
||||||
.mes {
|
.mes {
|
||||||
display: grid;
|
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;
|
padding: 10px 10px 0 10px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
color: var(--ivory, white);
|
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 {
|
.avatar {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
@ -371,15 +408,14 @@ code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.avatar.selected img {
|
.avatar.selected img {
|
||||||
outline-style: solid;
|
/* outline-style: solid;
|
||||||
outline-color: rgb(255 255 255 / 70%);
|
outline-color: rgb(255 255 255 / 70%);
|
||||||
outline-width: 2px;
|
outline-width: 2px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.mes_block {
|
.mes_block {
|
||||||
|
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
padding-left: 10px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ch_name {
|
.ch_name {
|
||||||
@ -390,8 +426,8 @@ code {
|
|||||||
.mes_text {
|
.mes_text {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 1.25rem;
|
line-height: 1.25rem;
|
||||||
padding-right: 40px;
|
padding-right: 60px;
|
||||||
padding-left: 5px;
|
padding-left: 0;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
max-width: 720px;
|
max-width: 720px;
|
||||||
@ -1533,8 +1569,10 @@ input[type='checkbox']:not(#nav-toggle):not(#rm_button_panel_pin):checked::after
|
|||||||
|
|
||||||
#user_avatar_block .avatar {
|
#user_avatar_block .avatar {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 60px;
|
width: 64px;
|
||||||
height: 60px;
|
height: 64px;
|
||||||
|
border: 2px solid rgba(255,255,255,0.7);
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#user_avatar_block .avatar img {
|
#user_avatar_block .avatar img {
|
||||||
@ -2521,6 +2559,8 @@ a {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@media screen and (max-width: 450px) { /*styles for mobile phones (tested on iPhone 13 Pro)*/
|
@media screen and (max-width: 450px) { /*styles for mobile phones (tested on iPhone 13 Pro)*/
|
||||||
body {
|
body {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
@ -2530,6 +2570,7 @@ a {
|
|||||||
|
|
||||||
#sheld { /*margin around the sides, and a larger one on bottom to avoid iOS Home bar*/
|
#sheld { /*margin around the sides, and a larger one on bottom to avoid iOS Home bar*/
|
||||||
height: calc(100svh - 15px);
|
height: calc(100svh - 15px);
|
||||||
|
width: 100vw; //calc(100vw - 15px);
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
Reference in New Issue
Block a user