diff --git a/public/index.html b/public/index.html
index 7f6c54a25..33fb88cb5 100644
--- a/public/index.html
+++ b/public/index.html
@@ -33,6 +33,7 @@
var default_ch_mes = "Hello";
var count_view_mes = 0;
var mesStr = '';
+ var generatedPromtCache = '';
var characters = [];
var this_chid;
var backgrounds = [];
@@ -125,7 +126,6 @@
var colab_ini_step = 1;
setInterval(function() {
- console.log(colab_ini_step);
switch(colab_ini_step){
case 0:
$('#colab_popup_text').html('
Initialization
');
@@ -362,7 +362,7 @@
if (response.ok === true) {
const getData = await response.json();
if(getData.colaburl != false){
- $('colab_shadow_popup').css('display', 'none');
+ $('#colab_shadow_popup').css('display', 'none');
is_colab = true;
let url = String(getData.colaburl).split("flare.com")[0] + "flare.com";
$('#api_url_text').val(url);
@@ -445,8 +445,7 @@
$('#chat').html('');
}
function messageFormating(mes, ch_name){
- if(this_chid != undefined)
- mes = mes.replaceAll("<", "<").replaceAll(">", ">");
+ if(this_chid != undefined) mes = mes.replaceAll("<", "<").replaceAll(">", ">");
mes = mes.replace(/\*\*(.+?)\*\*/g, '$1').replace(/\*(.+?)\*/g, '$1').replace(/\n/g, '
');
if(ch_name !== name1){
mes = mes.replaceAll(name2+":", "");
@@ -460,6 +459,7 @@
var messageText = mes['mes'];
var characterName = name1;
var avatarImg = "User Avatars/"+user_avatar;
+ generatedPromtCache = '';
//thisText = thisText.split("\n").join("
");
var avatarImg = "User Avatars/"+user_avatar;
if(!mes['is_user']){
@@ -485,6 +485,12 @@
//messageText = messageText.replaceAll(name2+":", "");
//}
//console.log(messageText);
+ if(count_view_mes == 0){
+ messageText = messageText.replace(/{{user}}/gi, name1);
+ messageText = messageText.replace(/{{char}}/gi, name2);
+ messageText = messageText.replace(//gi, name1);
+ messageText = messageText.replace(//gi, name2);
+ }
messageText = messageFormating(messageText, characterName);
$("#chat").append( "" );
@@ -607,8 +613,13 @@
var checkMesExample = $.trim(mesExamples.replace(//gi, ''));//for check length without tag
if(checkMesExample.length == 0) mesExamples = '';
var mesExamplesArray = [];
+ //***Base replace***
if(mesExamples !== undefined){
if(mesExamples.length > 0){
+ if(is_pugmalion){
+ mesExamples = mesExamples.replace(/{{user}}:/gi, 'You:');
+ mesExamples = mesExamples.replace(/:/gi, 'You:');
+ }
mesExamples = mesExamples.replace(/{{user}}/gi, name1);
mesExamples = mesExamples.replace(/{{char}}/gi, name2);
mesExamples = mesExamples.replace(//gi, name1);
@@ -618,6 +629,31 @@
mesExamplesArray = blocks.slice(1).map(block => `\n${block.trim()}\n`);
}
}
+ if(charDescription !== undefined){
+ if(charDescription.length > 0){
+ charDescription = charDescription.replace(/{{user}}/gi, name1);
+ charDescription = charDescription.replace(/{{char}}/gi, name2);
+ charDescription = charDescription.replace(//gi, name1);
+ charDescription = charDescription.replace(//gi, name2);
+ }
+ }
+ if(charPersonality !== undefined){
+ if(charPersonality.length > 0){
+ charPersonality = charPersonality.replace(/{{user}}/gi, name1);
+ charPersonality = charPersonality.replace(/{{char}}/gi, name2);
+ charPersonality = charPersonality.replace(//gi, name1);
+ charPersonality = charPersonality.replace(//gi, name2);
+ }
+ }
+ if(Scenario !== undefined){
+ if(Scenario.length > 0){
+ Scenario = Scenario.replace(/{{user}}/gi, name1);
+ Scenario = Scenario.replace(/{{char}}/gi, name2);
+ Scenario = Scenario.replace(//gi, name1);
+ Scenario = Scenario.replace(//gi, name2);
+ }
+ }
+
if(is_pygmalion){
if(charDescription.length > 0){
@@ -655,6 +691,12 @@
var chat2 = [];
var j = 0;
for(var i = chat.length-1; i >= 0; i--){
+ if(j == 0){
+ chat[j]['mes'] = chat[j]['mes'].replace(/{{user}}/gi, name1);
+ chat[j]['mes'] = chat[j]['mes'].replace(/{{char}}/gi, name2);
+ chat[j]['mes'] = chat[j]['mes'].replace(//gi, name1);
+ chat[j]['mes'] = chat[j]['mes'].replace(//gi, name2);
+ }
let this_mes_ch_name = '';
if(chat[j]['is_user']){
this_mes_ch_name = name1;
@@ -733,9 +775,10 @@
}
+
function runGenerate(cycleGenerationPromt = ''){
-
- if(cycleGenerationPromt.length == 0){
+ generatedPromtCache+=cycleGenerationPromt;
+ if(generatedPromtCache.length == 0){
chatString = "";
arrMes = arrMes.reverse();
var is_add_personality = false;
@@ -800,17 +843,17 @@
mesSendString+=mesSend[j];
}
}
- function checkProptSize(){
+ function checkPromtSize(){
setPromtString();
- let thisPromtContextSize = encode(JSON.stringify(storyString+mesExmString+mesSendString+anchorTop+anchorBottom+charPersonality+cycleGenerationPromt)).length+120;
+ let thisPromtContextSize = encode(JSON.stringify(storyString+mesExmString+mesSendString+anchorTop+anchorBottom+charPersonality+generatedPromtCache)).length+120;
if(thisPromtContextSize > this_max_context){
if(count_exm_add > 0){
//mesExamplesArray.length = mesExamplesArray.length-1;
count_exm_add--;
- checkProptSize();
+ checkPromtSize();
}else if(mesSend.length > 0){
mesSend.shift();
- checkProptSize();
+ checkPromtSize();
}else{
//end
}
@@ -819,8 +862,8 @@
- if(cycleGenerationPromt.length > 0){
- checkProptSize();
+ if(generatedPromtCache.length > 0){
+ checkPromtSize();
}else{
setPromtString();
}
@@ -830,7 +873,7 @@
}else{
mesSendString = '\n'+mesSendString;
}
- finalPromt = storyString+mesExmString+mesSendString+cycleGenerationPromt;
+ finalPromt = storyString+mesExmString+mesSendString+generatedPromtCache;
var generate_data;
if(main_api == 'kobold'){
@@ -2704,7 +2747,7 @@