Merge branch 'main' of https://github.com/Cohee1207/SillyTavern into mark-favorite-filter-by-favorite

This commit is contained in:
Wilfred Chen
2023-04-21 21:13:22 +08:00
5 changed files with 20 additions and 37 deletions

View File

@ -1031,7 +1031,7 @@ function getStoppingStrings(isImpersonate, addSpace) {
const charString = `\n${name2}:`; const charString = `\n${name2}:`;
const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`; const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`;
const result = isImpersonate ? charString : userString; const result = isImpersonate ? charString : userString;
return addSpace ? `${result} ` : result; return [addSpace ? `${result} ` : result];
} }
function getSlashCommand(message, type) { function getSlashCommand(message, type) {
@ -1461,21 +1461,8 @@ async function Generate(type, automatic_trigger, force_name2) {
storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : 'Personality: '); storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : 'Personality: ');
storyString += appendToStoryString(Scenario, power_user.disable_scenario_formatting ? '' : 'Scenario: '); storyString += appendToStoryString(Scenario, power_user.disable_scenario_formatting ? '' : 'Scenario: ');
} else { } else {
if (charDescription !== undefined) {
if (charPersonality.length > 0 && !power_user.disable_personality_formatting) {
charPersonality = name2 + "'s personality: " + charPersonality;
}
}
storyString += appendToStoryString(charDescription, ''); storyString += appendToStoryString(charDescription, '');
storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : name2 + "'s personality: ");
if (storyString.endsWith('\n')) {
storyString = storyString.slice(0, -1);
}
if (count_view_mes < topAnchorDepth) {
storyString += '\n' + appendToStoryString(charPersonality, '');
}
} }
if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) { if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) {
@ -1487,9 +1474,6 @@ async function Generate(type, automatic_trigger, force_name2) {
if (power_user.pin_examples && main_api !== 'openai') { if (power_user.pin_examples && main_api !== 'openai') {
for (let example of mesExamplesArray) { for (let example of mesExamplesArray) {
if (!is_pygmalion) { if (!is_pygmalion) {
if (!storyString.endsWith('\n')) {
storyString += '\n';
}
const replaceString = power_user.disable_examples_formatting ? '' : `This is how ${name2} should talk`; const replaceString = power_user.disable_examples_formatting ? '' : `This is how ${name2} should talk`;
example = example.replace(/<START>/i, replaceString); example = example.replace(/<START>/i, replaceString);
} }
@ -1648,9 +1632,6 @@ async function Generate(type, automatic_trigger, force_name2) {
} }
} }
if (!is_pygmalion && Scenario && Scenario.length > 0) { 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`; storyString += !power_user.disable_scenario_formatting ? `Circumstances and context of the dialogue: ${Scenario}\n` : `${Scenario}\n`;
} }
console.log('calling runGenerate'); console.log('calling runGenerate');
@ -1685,9 +1666,9 @@ async function Generate(type, automatic_trigger, force_name2) {
is_add_personality = true; is_add_personality = true;
//chatString = chatString.substr(0,chatString.length-1); //chatString = chatString.substr(0,chatString.length-1);
//anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]"; //anchorAndPersonality = "[Genre: roleplay chat][Tone: very long messages with descriptions]";
if ((anchorTop != "" || charPersonality != "") && !is_pygmalion) { let personalityAndAnchor = [ charPersonality, anchorTop ].filter(x => x).join(' ');
if (anchorTop != "") charPersonality += ' '; if (personalityAndAnchor && !is_pygmalion) {
item += "[" + charPersonality + anchorTop + ']\n'; 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 if (i >= arrMes.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":" && !is_pygmalion) {//For add anchor in end
@ -1901,7 +1882,7 @@ async function Generate(type, automatic_trigger, force_name2) {
'early_stopping': textgenerationwebui_settings.early_stopping, 'early_stopping': textgenerationwebui_settings.early_stopping,
'seed': textgenerationwebui_settings.seed, 'seed': textgenerationwebui_settings.seed,
'add_bos_token': textgenerationwebui_settings.add_bos_token, '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, 'truncation_length': max_context,
'ban_eos_token': textgenerationwebui_settings.ban_eos_token, 'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens, 'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
@ -2199,13 +2180,15 @@ function cleanUpMessage(getMessage, isImpersonate) {
getMessage = getMessage.trim(); getMessage = getMessage.trim();
} }
const stoppingString = getStoppingStrings(isImpersonate, false); const stoppingStrings = getStoppingStrings(isImpersonate, false);
if (stoppingString.length) { for (const stoppingString of stoppingStrings) {
for (let j = stoppingString.length - 1; j > 0; j--) { if (stoppingString.length) {
if (getMessage.slice(-j) === stoppingString.slice(0, j)) { for (let j = stoppingString.length - 1; j > 0; j--) {
getMessage = getMessage.slice(0, -j); if (getMessage.slice(-j) === stoppingString.slice(0, j)) {
break; getMessage = getMessage.slice(0, -j);
break;
}
} }
} }
} }

View File

@ -85,7 +85,7 @@ function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, thi
s7: this_settings.sampler_order[6], s7: this_settings.sampler_order[6],
use_world_info: false, use_world_info: false,
singleline: kai_settings.single_line, 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; return generate_data;
} }

View File

@ -26,11 +26,11 @@ let textgenerationwebui_settings = {
seed: -1, seed: -1,
preset: 'Default', preset: 'Default',
add_bos_token: true, add_bos_token: true,
custom_stopping_strings: [], stopping_strings: [],
truncation_length: 2048, truncation_length: 2048,
ban_eos_token: false, ban_eos_token: false,
streaming: false, streaming: false,
fn_index: 34, fn_index: 43,
skip_special_tokens: true, skip_special_tokens: true,
}; };

View File

@ -169,12 +169,12 @@ code {
#bg1 { #bg1 {
background-image: url(backgrounds/tavern1.jpg); background-image: url(backgrounds/tavern1.jpg);
z-index: 0; z-index: -2;
} }
#bg_custom { #bg_custom {
background-image: none; background-image: none;
z-index: 1; z-index: -1;
} }
/*TOPPER margin*/ /*TOPPER margin*/

View File

@ -424,7 +424,7 @@ app.post("/generate_textgenerationwebui", jsonParser, async function (request, r
let result = JSON.parse(request.body.data)[0]; let result = JSON.parse(request.body.data)[0];
let prompt = result; 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 { try {
for await (const text of readWebsocket()) { for await (const text of readWebsocket()) {