From b069ea9f55ed923c536cd5b23d6454e7e40d6b9f Mon Sep 17 00:00:00 2001 From: Grzegorz Gidel Date: Wed, 19 Apr 2023 23:39:58 +0200 Subject: [PATCH 1/4] Fix extra space in the prompt before top anchor if personality is missing --- public/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/script.js b/public/script.js index a61a136f6..2a06a29bd 100644 --- a/public/script.js +++ b/public/script.js @@ -1682,9 +1682,9 @@ async function Generate(type, automatic_trigger, force_name2) { is_add_personality = true; //chatString = chatString.substr(0,chatString.length-1); //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; - if ((anchorTop != "" || charPersonality != "") && !is_pygmalion) { - if (anchorTop != "") charPersonality += ' '; - item += "[" + charPersonality + anchorTop + ']\n'; + let personalityAndAnchor = [ charPersonality, anchorTop ].filter(x => x).join(' '); + if (personalityAndAnchor && !is_pygmalion) { + item += "[" + personalityAndAnchor + ']\n'; } } if (i >= arrMes.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":" && !is_pygmalion) {//For add anchor in end From d10dc611317f00690540a20b9c26dcb3ec223084 Mon Sep 17 00:00:00 2001 From: Grzegorz Gidel Date: Wed, 19 Apr 2023 21:17:42 +0200 Subject: [PATCH 2/4] Fix conjoined words and some excessive newlines around various parts of the prompt --- public/script.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/public/script.js b/public/script.js index 2a06a29bd..d8b77de81 100644 --- a/public/script.js +++ b/public/script.js @@ -1458,21 +1458,8 @@ async function Generate(type, automatic_trigger, force_name2) { storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : 'Personality: '); storyString += appendToStoryString(Scenario, power_user.disable_scenario_formatting ? '' : 'Scenario: '); } else { - if (charDescription !== undefined) { - if (charPersonality.length > 0 && !power_user.disable_personality_formatting) { - charPersonality = name2 + "'s personality: " + charPersonality; - } - } - storyString += appendToStoryString(charDescription, ''); - - if (storyString.endsWith('\n')) { - storyString = storyString.slice(0, -1); - } - - if (count_view_mes < topAnchorDepth) { - storyString += '\n' + appendToStoryString(charPersonality, ''); - } + storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : name2 + "'s personality: "); } if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) { @@ -1484,9 +1471,6 @@ async function Generate(type, automatic_trigger, force_name2) { if (power_user.pin_examples && main_api !== 'openai') { for (let example of mesExamplesArray) { if (!is_pygmalion) { - if (!storyString.endsWith('\n')) { - storyString += '\n'; - } const replaceString = power_user.disable_examples_formatting ? '' : `This is how ${name2} should talk`; example = example.replace(//i, replaceString); } @@ -1645,9 +1629,6 @@ async function Generate(type, automatic_trigger, force_name2) { } } if (!is_pygmalion && Scenario && Scenario.length > 0) { - if (!storyString.endsWith('\n')) { - storyString += '\n'; - } storyString += !power_user.disable_scenario_formatting ? `Circumstances and context of the dialogue: ${Scenario}\n` : `${Scenario}\n`; } console.log('calling runGenerate'); From 4f145570111ac115bc7abb4004e5df4c7aa2d4be Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 21 Apr 2023 11:51:52 +0300 Subject: [PATCH 3/4] Fix zindex for backgrounds --- public/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/style.css b/public/style.css index 19f0eda50..22532129c 100644 --- a/public/style.css +++ b/public/style.css @@ -169,12 +169,12 @@ code { #bg1 { background-image: url(backgrounds/tavern1.jpg); - z-index: 0; + z-index: -2; } #bg_custom { background-image: none; - z-index: 1; + z-index: -1; } /*TOPPER margin*/ From 50526a16b94a06ebc4b4966da1b59a0fd9ea546f Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 21 Apr 2023 14:38:38 +0300 Subject: [PATCH 4/4] Fix oobabooga --- public/script.js | 18 ++++++++++-------- public/scripts/kai-settings.js | 2 +- public/scripts/textgen-settings.js | 4 ++-- server.js | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/public/script.js b/public/script.js index d8b77de81..0769ea982 100644 --- a/public/script.js +++ b/public/script.js @@ -1028,7 +1028,7 @@ function getStoppingStrings(isImpersonate, addSpace) { const charString = `\n${name2}:`; const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`; const result = isImpersonate ? charString : userString; - return addSpace ? `${result} ` : result; + return [addSpace ? `${result} ` : result]; } function getSlashCommand(message, type) { @@ -1879,7 +1879,7 @@ async function Generate(type, automatic_trigger, force_name2) { 'early_stopping': textgenerationwebui_settings.early_stopping, 'seed': textgenerationwebui_settings.seed, 'add_bos_token': textgenerationwebui_settings.add_bos_token, - 'custom_stopping_strings': JSON.stringify(getStoppingStrings(isImpersonate, false)), + 'stopping_strings': getStoppingStrings(isImpersonate, false), 'truncation_length': max_context, 'ban_eos_token': textgenerationwebui_settings.ban_eos_token, 'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens, @@ -2177,13 +2177,15 @@ function cleanUpMessage(getMessage, isImpersonate) { getMessage = getMessage.trim(); } - const stoppingString = getStoppingStrings(isImpersonate, false); + const stoppingStrings = getStoppingStrings(isImpersonate, false); - if (stoppingString.length) { - for (let j = stoppingString.length - 1; j > 0; j--) { - if (getMessage.slice(-j) === stoppingString.slice(0, j)) { - getMessage = getMessage.slice(0, -j); - break; + for (const stoppingString of stoppingStrings) { + if (stoppingString.length) { + for (let j = stoppingString.length - 1; j > 0; j--) { + if (getMessage.slice(-j) === stoppingString.slice(0, j)) { + getMessage = getMessage.slice(0, -j); + break; + } } } } diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 654d36a1a..842a571e2 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -85,7 +85,7 @@ function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, thi s7: this_settings.sampler_order[6], use_world_info: false, singleline: kai_settings.single_line, - stop_sequence: kai_settings.use_stop_sequence ? [getStoppingStrings(isImpersonate, false)] : undefined, + stop_sequence: kai_settings.use_stop_sequence ? getStoppingStrings(isImpersonate, false) : undefined, }; return generate_data; } diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 918d1995e..687bdf7f8 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -26,11 +26,11 @@ let textgenerationwebui_settings = { seed: -1, preset: 'Default', add_bos_token: true, - custom_stopping_strings: [], + stopping_strings: [], truncation_length: 2048, ban_eos_token: false, streaming: false, - fn_index: 34, + fn_index: 43, skip_special_tokens: true, }; diff --git a/server.js b/server.js index 7031a752f..c42ac630a 100644 --- a/server.js +++ b/server.js @@ -424,7 +424,7 @@ app.post("/generate_textgenerationwebui", jsonParser, async function (request, r let result = JSON.parse(request.body.data)[0]; let prompt = result; - let stopping_strings = JSON.parse(request.body.data)[1].custom_stopping_strings; + let stopping_strings = JSON.parse(request.body.data)[1].stopping_strings; try { for await (const text of readWebsocket()) {