From 308c780d69df6f796452a714bba17fde31faa564 Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 12 Jan 2023 20:25:09 +0400 Subject: [PATCH] @1.1.3 1) Corrected message breaks for Pygmalion models 2) Fixed NovelAI max context overflow --- .../Classic-Pygmalion-2.7b.settings | 2 +- .../Classic-Pygmalion-6b.settings | 2 +- .../Merchant-FSD-2.7B-Nerys.settings | 54 ------- public/index.html | 152 ++++++++++++------ public/style.css | 17 ++ 5 files changed, 120 insertions(+), 107 deletions(-) delete mode 100644 public/KoboldAI Settings/Merchant-FSD-2.7B-Nerys.settings diff --git a/public/KoboldAI Settings/Classic-Pygmalion-2.7b.settings b/public/KoboldAI Settings/Classic-Pygmalion-2.7b.settings index 73666d353..f7d8c8349 100644 --- a/public/KoboldAI Settings/Classic-Pygmalion-2.7b.settings +++ b/public/KoboldAI Settings/Classic-Pygmalion-2.7b.settings @@ -2,7 +2,7 @@ "file_version": 2, "max_length": 2048, "ikmax": 3000, - "genamt": 80, + "genamt": 180, "ikgen": 200, "rep_pen": 1.17, "rep_pen_slope": 0.2, diff --git a/public/KoboldAI Settings/Classic-Pygmalion-6b.settings b/public/KoboldAI Settings/Classic-Pygmalion-6b.settings index ece9bf736..df9b72035 100644 --- a/public/KoboldAI Settings/Classic-Pygmalion-6b.settings +++ b/public/KoboldAI Settings/Classic-Pygmalion-6b.settings @@ -2,7 +2,7 @@ "file_version": 2, "max_length": 2048, "ikmax": 3000, - "genamt": 80, + "genamt": 180, "ikgen": 200, "rep_pen": 1.08, "rep_pen_slope": 0.9, diff --git a/public/KoboldAI Settings/Merchant-FSD-2.7B-Nerys.settings b/public/KoboldAI Settings/Merchant-FSD-2.7B-Nerys.settings deleted file mode 100644 index 6f4cd2331..000000000 --- a/public/KoboldAI Settings/Merchant-FSD-2.7B-Nerys.settings +++ /dev/null @@ -1,54 +0,0 @@ -{ - "apikey": "", - "andepth": 1, - "sampler_order": [ - 6, - 4, - 3, - 2, - 0, - 1, - 5 - ], - "temp": 0.8, - "top_p": 0.90, - "top_k": 0.0, - "tfs": 0.96, - "typical": 0.98, - "top_a": 0.02, - "rep_pen": 1.01, - "rep_pen_slope": 0.8, - "rep_pen_range": 448.0, - "genamt": 90, - "max_length": 2048, - "ikgen": 200, - "formatoptns": { - "frmttriminc": true, - "frmtrmblln": false, - "frmtrmspch": false, - "frmtadsnsp": true, - "singleline": false - }, - "numseqs": 1, - "widepth": 3, - "useprompt": false, - "adventure": false, - "chatmode": false, - "chatname": "You", - "dynamicscan": false, - "nopromptgen": false, - "rngpersist": false, - "nogenmod": false, - "fulldeterminism": false, - "autosave": false, - "welcome": "## Warning: This model has a very heavy NSFW bias and is not suitable for use by minors!\n\nYou are currently running story-writing model `Erebus, version 1 (20B).`\n\n This model is made by [Mr. Seeker](https://www.patreon.com/mrseeker) with help of ProudNoob and the KoboldAI team.\n\n### How to use this model\n\nErebus is designed to generate short stories and novels. Use the author's note to give it a certain genre to follow, use memory to give an overview of the story and use World Information to give specific details about the characters. To start off, give the AI an idea of what you are writing about by setting the scene. Give the AI around 10 sentences that make your story interesting to read. Introduce your character, describe the world, blow something up, or let the AI use its creative mind.", - "output_streaming": true, - "show_probs": false, - "show_budget": false, - "seed": null, - "newlinemode": "n", - "antemplate": "", - "userscripts": [], - "corescript": "default.lua", - "softprompt": "" -} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 9d55a611a..62eca2130 100644 --- a/public/index.html +++ b/public/index.html @@ -92,6 +92,11 @@ var rep_pen_size = 100; var is_pygmalion = false; + var tokens_already_generated = 0; + var message_already_generated = ''; + var if_typing_text = false; + const tokens_cycle_count = 30; + var cycle_count_generation = 0; var anchor_order = 0; var style_anchor = true; @@ -416,7 +421,13 @@ //} messageText = messageFormating(messageText, characterName); - $("#chat").append( "
"+characterName+"
"+messageText+"
" ); + $("#chat").append( "
"+characterName+"
"+"
" ); + + if(!if_typing_text){ + $("#chat").children().filter('[mesid="'+count_view_mes+'"]').children('.mes_block').children('.mes_text').append(messageText); + }else{ + typeWriter($("#chat").children().filter('[mesid="'+count_view_mes+'"]').children('.mes_block').children('.mes_text'), messageText, 50, 0); + } count_view_mes++; if(!add_mes_without_animation){ $('#chat').children().last().css("opacity",1.0); @@ -432,7 +443,14 @@ var $textchat = $('#chat'); $textchat.scrollTop($textchat[0].scrollHeight); } - + function typeWriter(target, text, speed, i) { + if (i < text.length) { + //target.append(text.charAt(i)); + target.html(target.html() + text.charAt(i)); + i++; + setTimeout(() => typeWriter(target, text, speed, i), speed); + } + } function newMesPattern(name){ //Patern which denotes a new message name = name+':'; return name; @@ -447,7 +465,8 @@ } }); async function Generate(type) {//encode("dsfs").length - + tokens_already_generated = 0; + message_already_generated = name2+': '; if(online_status != 'no_connection' && this_chid != undefined){ if(type != 'regenerate'){ var textareaText = $("#send_textarea").val(); @@ -512,7 +531,7 @@ var charPersonality = characters[this_chid].personality; if(is_pygmalion){ - storyString = name2+"'s Persona: "+$.trim(characters[this_chid].description)+"\n\n"; + storyString = name2+"'s Persona: "+$.trim(characters[this_chid].description)+" "+name2+" is "+charPersonality+".\n\n"; }else{ if($.trim(charPersonality.length) > 0){ charPersonality = "["+name2+" is "+charPersonality+"]";//"["+name2+"'s personality: "+charPersonality+"]"; @@ -544,7 +563,7 @@ if(novel_tier === 1){ this_max_context = 1024; }else{ - this_max_context = 2048; + this_max_context = 2048-60;//fix for fat tokens } } @@ -563,68 +582,83 @@ i++; } - function runGenerate(){ + function runGenerate(cycleGenerationPromt = ''){ + if(cycleGenerationPromt === ''){ + chatString = ""; + arrMes = arrMes.reverse(); + var is_add_personality = false; + arrMes.forEach(function(item, i, arr) {//For added anchors and others - chatString = ""; - arrMes = arrMes.reverse(); - var is_add_personality = false; - arrMes.forEach(function(item, i, arr) {//For added anchors and others - - if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) != name1+":"){ - if(textareaText == ""){ - item = item.substr(0,item.length-1); - } - } - if(i === arrMes.length-topAnchorDepth && count_view_mes>=topAnchorDepth && !is_add_personality){ - - is_add_personality = true; - //chatString = chatString.substr(0,chatString.length-1); - //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; - item+=charPersonality+anchorTop+'\n'; - } - if(i >= arrMes.length-1 && count_view_mes>=4 && $.trim(item).substr(0, (name1+":").length) == name1+":" && !is_pygmalion){//For add anchor in end - item = item.substr(0,item.length-1); - //chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n"; - item =item+" "+ anchorBottom+"\n"; - } - if(is_pygmalion){ - if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) == name1+":"){//for add name2 when user sent - item =item+name2+":"; - } - if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) != name1+":"){//for add name2 when continue + if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) != name1+":"){ if(textareaText == ""){ - item =item+'\n'+name2+":"; + item = item.substr(0,item.length-1); } } - if($.trim(item).indexOf(name1) === 0){ - item = item.replace(name1+':', 'You:'); + if(i === arrMes.length-topAnchorDepth && count_view_mes>=topAnchorDepth && !is_add_personality){ + + is_add_personality = true; + //chatString = chatString.substr(0,chatString.length-1); + //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; + item+=charPersonality+anchorTop+'\n'; } + if(i >= arrMes.length-1 && count_view_mes>=4 && $.trim(item).substr(0, (name1+":").length) == name1+":" && !is_pygmalion){//For add anchor in end + item = item.substr(0,item.length-1); + //chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n"; + item =item+" "+ anchorBottom+"\n"; + } + if(is_pygmalion){ + if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) == name1+":"){//for add name2 when user sent + item =item+name2+":"; + } + if(i >= arrMes.length-1 && $.trim(item).substr(0, (name1+":").length) != name1+":"){//for add name2 when continue + if(textareaText == ""){ + item =item+'\n'+name2+":"; + } + } + if($.trim(item).indexOf(name1) === 0){ + item = item.replace(name1+':', 'You:'); + } + } + chatString = chatString+item; + }); + + storyString+=chatString; + + + //console.log(encode(characters[this_chid].description+chatString).length); + //console.log(encode(JSON.stringify(characters[this_chid].description+chatString)).length); + if(type == 'force_name2'){ + storyString+= name2+':'; } - chatString = chatString+item; - }); - - storyString+=chatString; - - - //console.log(encode(characters[this_chid].description+chatString).length); - //console.log(encode(JSON.stringify(characters[this_chid].description+chatString)).length); - if(type == 'force_name2'){ - storyString+= name2+':'; + //console.log(JSON.stringify(storyString)); + //Send story string + }else{ + storyString = cycleGenerationPromt; } - //console.log(JSON.stringify(storyString)); - //Send story string var generate_data; if(main_api == 'kobold'){ var generate_data = {prompt: storyString, gui_settings: true,max_length: amount_gen,temperature: temp, max_context_length: max_context}; if(preset_settings != 'gui'){ var this_settings = koboldai_settings[koboldai_setting_names[preset_settings]]; - + var this_amount_gen = parseInt(amount_gen); + if(is_pygmalion){ + if(tokens_already_generated === 0){ + if(parseInt(amount_gen) >= 90){ + this_amount_gen = 90; + }else{ + this_amount_gen = parseInt(amount_gen); + } + + }else{ + this_amount_gen = tokens_cycle_count; + } + } generate_data = {prompt: storyString, gui_settings: false, sampler_order: this_settings.sampler_order, max_context_length: parseInt(max_context),//this_settings.max_length, - max_length: parseInt(amount_gen), + max_length: this_amount_gen,//parseInt(amount_gen), rep_pen: parseFloat(rep_pen), rep_pen_range: parseInt(rep_pen_size), rep_pen_slope: this_settings.rep_pen_slope, @@ -697,6 +731,22 @@ if(main_api == 'novel'){ var getMessage = data.output; } + + //Pygmalion run again + if(is_pygmalion){ + if_typing_text = false; + message_already_generated +=getMessage; + if(message_already_generated.indexOf('You:') === -1 && tokens_already_generated < parseInt(amount_gen)){ + if(tokens_already_generated === 0){ + getMessage = getMessage.trimStart(); + getMessage = ' '+getMessage; + } + tokens_already_generated += tokens_cycle_count; + runGenerate(storyString+getMessage); + return; + } + getMessage = message_already_generated; + } //Formating getMessage = $.trim(getMessage); if(is_pygmalion){ @@ -2329,7 +2379,7 @@
-
+

Pro Settings

Amount generation

select
diff --git a/public/style.css b/public/style.css index b91c2f9ca..fbe758bda 100644 --- a/public/style.css +++ b/public/style.css @@ -274,6 +274,23 @@ body { padding-right: 40px; max-width: 720px; word-wrap: break-word; + animation: typing 3.5s steps(40, end), blink-caret .75s step-end infinite; +} + +.mes_text::after { + content: "▋"; + animation: blink 1s steps(1) infinite; + opacity: 0.7; + display: none; +} + +@keyframes blink { + 60% { + visibility: hidden; + } +} +.mes_text i{ + //color: rgb(229, 224, 216, 0.5); } br { display: block;