diff --git a/klite.embd b/klite.embd index 90fd9d46736b0..937423ce8e75d 100644 --- a/klite.embd +++ b/klite.embd @@ -8960,7 +8960,7 @@ Current version: 78 } else { - document.getElementById("chat_msg_body").innerHTML = render_enhanced_chat_instruct(textToRender); + document.getElementById("chat_msg_body").innerHTML = render_enhanced_chat_instruct(textToRender,false); } // Show the 'AI is typing' message if an answer is pending, and prevent the 'send button' from being clicked again. @@ -9754,8 +9754,9 @@ Current version: 78 } } - function render_enhanced_chat_instruct(input, classSuffixStr="") //class suffix string used to prevent defined styles from leaking into global scope + function render_enhanced_chat_instruct(input, isPreview) //class suffix string used to prevent defined styles from leaking into global scope { + let classSuffixStr = isPreview ? "prv" : ""; const contextDict = { sysOpen: '', youOpen: '', AIOpen: '', closeTag: '' } let you = get_instruct_starttag(); let bot = get_instruct_endtag(); // Instruct tags will be used to wrap text in styled bubbles. @@ -9802,7 +9803,7 @@ Current version: 78 let noSystemPrompt = input.trim().startsWith(you.trim()) || input.trim().startsWith(bot.trim()); let newbodystr = noSystemPrompt ? input : style('sys') + input; // First, create the string we'll transform. Style system bubble if we should. if (newbodystr.endsWith(bot)) { newbodystr = newbodystr.slice(0, -bot.length); } // Remove the last chat bubble if prompt ends with `end_sequence`. - newbodystr = transformInputToAestheticStyle(newbodystr); // Transform input to aesthetic style, reduce any unnecessary spaces or newlines, and trim empty replies if they exist. + newbodystr = transformInputToAestheticStyle(newbodystr,isPreview); // Transform input to aesthetic style, reduce any unnecessary spaces or newlines, and trim empty replies if they exist. if (synchro_pending_stream != "") { newbodystr += getStreamingText(); } // Add the pending stream if it's needed. This will add any streamed text to a new bubble for the AI. @@ -9833,7 +9834,8 @@ Current version: 78 let fontStyle = type=='action'?'italic':'normal'; let injectQuotes1 = type=='speech'?'“':''; let injectQuotes2 = type=='speech'?'”':''; - let textCol = as[`${type}_tcolor_${role}`]; return `${injectQuotes1}$1${injectQuotes2}`; + let textCol = as[`${type}_tcolor_${role}`]; + return `${injectQuotes1}$1${injectQuotes2}`; } function image(role) { if (!as[`${role}_portrait`] || as.border_style == 'None' || role == 'sys') { return ''; } @@ -9852,10 +9854,10 @@ Current version: 78 } return blocks.join(''); } - function transformInputToAestheticStyle(bodyStr) { // Trim unnecessary empty space and new lines, and append * or " to each bubble if start/end sequence ends with * or ", to preserve styling. + function transformInputToAestheticStyle(bodyStr, isPreview) { // Trim unnecessary empty space and new lines, and append * or " to each bubble if start/end sequence ends with * or ", to preserve styling. bodyStr = bodyStr.replaceAll(you + '\n', you).replaceAll(you + ' ', you).replaceAll(you, style('you') + `${you.endsWith('*') ? '*' : ''}` + `${you.endsWith('"') ? '"' : ''}`); bodyStr = bodyStr.replaceAll(bot + '\n', bot).replaceAll(bot + ' ', bot).replaceAll(bot, style('AI') + `${bot.endsWith('*') ? '*' : ''}` + `${bot.endsWith('"') ? '"' : ''}`); - if(gametext_arr.length==0) + if(gametext_arr.length==0 && !isPreview) { return bodyStr; //to allow html in the welcome text } @@ -9871,8 +9873,8 @@ Current version: 78 } function updateTextPreview() { - let preview = `You are Mikago, a prestigious bot that's a supervillain.\n\nRoleplay in first person, be prestigious, don't be a bot. This is a fantasy world.\n\nCode blocks should be wrapped in triple backticks, like so:\nqqq\n