mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/Cohee1207/SillyTavern into dev
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sillytavern",
|
"name": "sillytavern",
|
||||||
"version": "1.6.6",
|
"version": "1.6.7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sillytavern",
|
"name": "sillytavern",
|
||||||
"version": "1.6.6",
|
"version": "1.6.7",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dqbd/tiktoken": "^1.0.2",
|
"@dqbd/tiktoken": "^1.0.2",
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
||||||
},
|
},
|
||||||
"version": "1.6.6",
|
"version": "1.6.7",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"pkg": "pkg --compress Gzip --no-bytecode --public ."
|
"pkg": "pkg --compress Gzip --no-bytecode --public ."
|
||||||
|
@@ -1768,7 +1768,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex1 range-block flex-container flexFlowColumn">
|
<div class="flex1 range-block flex-container">
|
||||||
<label title="Entries can activate other entries by mentioning their keywords" class="checkbox_label">
|
<label title="Entries can activate other entries by mentioning their keywords" class="checkbox_label">
|
||||||
<input id="world_info_recursive" type="checkbox" />
|
<input id="world_info_recursive" type="checkbox" />
|
||||||
<span>
|
<span>
|
||||||
@@ -1787,6 +1787,14 @@
|
|||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label title="If the entry key consists of only one word, it would not be matched as part of other words" class="checkbox_label">
|
||||||
|
<input id="world_info_match_whole_words" type="checkbox" />
|
||||||
|
<span>
|
||||||
|
Match whole words
|
||||||
|
<a href="https://docs.sillytavern.app/usage/guidebook/#match-whole-words" class="notes-link" target="_blank">
|
||||||
|
<span class="note-link-span">?</span>
|
||||||
|
</a>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -3055,4 +3063,4 @@
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@@ -27,6 +27,7 @@ import {
|
|||||||
deleteWorldInfo,
|
deleteWorldInfo,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
|
world_info_match_whole_words,
|
||||||
} from "./scripts/world-info.js";
|
} from "./scripts/world-info.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -1391,10 +1392,10 @@ function getStoppingStrings(isImpersonate, addSpace) {
|
|||||||
|
|
||||||
if (power_user.instruct.enabled) {
|
if (power_user.instruct.enabled) {
|
||||||
if (power_user.instruct.input_sequence) {
|
if (power_user.instruct.input_sequence) {
|
||||||
result.push(wrap(power_user.instruct.input_sequence));
|
result.push(substituteParams(wrap(power_user.instruct.input_sequence), name1, name2));
|
||||||
}
|
}
|
||||||
if (power_user.instruct.output_sequence) {
|
if (power_user.instruct.output_sequence) {
|
||||||
result.push(wrap(power_user.instruct.output_sequence));
|
result.push(substituteParams(wrap(power_user.instruct.output_sequence), name1, name2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1808,7 +1809,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
const magName = isImpersonate ? (is_pygmalion ? 'You' : name1) : name2;
|
const magName = isImpersonate ? (is_pygmalion ? 'You' : name1) : name2;
|
||||||
|
|
||||||
if (isInstruct) {
|
if (isInstruct) {
|
||||||
message_already_generated = formatInstructModePrompt(magName, isImpersonate);
|
message_already_generated = formatInstructModePrompt(magName, isImpersonate, false, name1, name2);
|
||||||
} else {
|
} else {
|
||||||
message_already_generated = `${magName}: `;
|
message_already_generated = `${magName}: `;
|
||||||
}
|
}
|
||||||
@@ -2151,14 +2152,14 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
// Add quiet generation prompt at depth 0
|
// Add quiet generation prompt at depth 0
|
||||||
if (quiet_prompt && quiet_prompt.length) {
|
if (quiet_prompt && quiet_prompt.length) {
|
||||||
const name = is_pygmalion ? 'You' : name1;
|
const name = is_pygmalion ? 'You' : name1;
|
||||||
const quietAppend = isInstruct ? formatInstructModeChat(name, quiet_prompt, false, true, false) : `\n${name}: ${quiet_prompt}`;
|
const quietAppend = isInstruct ? formatInstructModeChat(name, quiet_prompt, false, true, false, name1, name2) : `\n${name}: ${quiet_prompt}`;
|
||||||
mesSendString += quietAppend;
|
mesSendString += quietAppend;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get instruct mode line
|
// Get instruct mode line
|
||||||
if (isInstruct && tokens_already_generated === 0) {
|
if (isInstruct && tokens_already_generated === 0) {
|
||||||
const name = isImpersonate ? (is_pygmalion ? 'You' : name1) : name2;
|
const name = isImpersonate ? (is_pygmalion ? 'You' : name1) : name2;
|
||||||
mesSendString += formatInstructModePrompt(name, isImpersonate, promptBias);
|
mesSendString += formatInstructModePrompt(name, isImpersonate, promptBias, name1, name2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get non-instruct impersonation line
|
// Get non-instruct impersonation line
|
||||||
@@ -2574,7 +2575,7 @@ function formatMessageHistoryItem(chatItem, isInstruct) {
|
|||||||
let textResult = shouldPrependName ? `${itemName}: ${chatItem.mes}\n` : `${chatItem.mes}\n`;
|
let textResult = shouldPrependName ? `${itemName}: ${chatItem.mes}\n` : `${chatItem.mes}\n`;
|
||||||
|
|
||||||
if (isInstruct) {
|
if (isInstruct) {
|
||||||
textResult = formatInstructModeChat(itemName, chatItem.mes, chatItem.is_user, isNarratorType, chatItem.force_avatar);
|
textResult = formatInstructModeChat(itemName, chatItem.mes, chatItem.is_user, isNarratorType, chatItem.force_avatar, name1, name2);
|
||||||
}
|
}
|
||||||
|
|
||||||
textResult = replaceBiasMarkup(textResult);
|
textResult = replaceBiasMarkup(textResult);
|
||||||
@@ -4080,6 +4081,7 @@ async function saveSettings(type) {
|
|||||||
world_info_budget: world_info_budget,
|
world_info_budget: world_info_budget,
|
||||||
world_info_recursive: world_info_recursive,
|
world_info_recursive: world_info_recursive,
|
||||||
world_info_case_sensitive: world_info_case_sensitive,
|
world_info_case_sensitive: world_info_case_sensitive,
|
||||||
|
world_info_match_whole_words: world_info_match_whole_words,
|
||||||
textgenerationwebui_settings: textgenerationwebui_settings,
|
textgenerationwebui_settings: textgenerationwebui_settings,
|
||||||
swipes: swipes,
|
swipes: swipes,
|
||||||
horde_settings: horde_settings,
|
horde_settings: horde_settings,
|
||||||
|
@@ -649,9 +649,14 @@ function loadInstructMode() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvatar) {
|
export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvatar, name1, name2) {
|
||||||
const includeNames = isNarrator ? false : (power_user.instruct.names || !!selected_group || !!forceAvatar);
|
const includeNames = isNarrator ? false : (power_user.instruct.names || !!selected_group || !!forceAvatar);
|
||||||
const sequence = (isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
|
const sequence = substituteParams(
|
||||||
|
(isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence,
|
||||||
|
name1,
|
||||||
|
name2
|
||||||
|
);
|
||||||
|
|
||||||
const separator = power_user.instruct.wrap ? '\n' : '';
|
const separator = power_user.instruct.wrap ? '\n' : '';
|
||||||
const separatorSequence = power_user.instruct.separator_sequence && !isUser
|
const separatorSequence = power_user.instruct.separator_sequence && !isUser
|
||||||
? power_user.instruct.separator_sequence
|
? power_user.instruct.separator_sequence
|
||||||
@@ -672,9 +677,14 @@ export function formatInstructStoryString(story, systemPrompt) {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatInstructModePrompt(name, isImpersonate, promptBias) {
|
export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, name2) {
|
||||||
const includeNames = power_user.instruct.names || !!selected_group;
|
const includeNames = power_user.instruct.names || !!selected_group;
|
||||||
const sequence = isImpersonate ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
|
const sequence = substituteParams(
|
||||||
|
isImpersonate ? power_user.instruct.input_sequence : power_user.instruct.output_sequence,
|
||||||
|
name1,
|
||||||
|
name2
|
||||||
|
);
|
||||||
|
|
||||||
const separator = power_user.instruct.wrap ? '\n' : '';
|
const separator = power_user.instruct.wrap ? '\n' : '';
|
||||||
let text = includeNames ? (separator + sequence + separator + `${name}:`) : (separator + sequence);
|
let text = includeNames ? (separator + sequence + separator + `${name}:`) : (separator + sequence);
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ export {
|
|||||||
world_info_depth,
|
world_info_depth,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
|
world_info_match_whole_words,
|
||||||
world_names,
|
world_names,
|
||||||
imported_world_name,
|
imported_world_name,
|
||||||
checkWorldInfo,
|
checkWorldInfo,
|
||||||
@@ -25,6 +26,7 @@ let world_info_budget = 128;
|
|||||||
let is_world_edit_open = false;
|
let is_world_edit_open = false;
|
||||||
let world_info_recursive = false;
|
let world_info_recursive = false;
|
||||||
let world_info_case_sensitive = false;
|
let world_info_case_sensitive = false;
|
||||||
|
let world_info_match_whole_words = false;
|
||||||
let imported_world_name = "";
|
let imported_world_name = "";
|
||||||
const saveWorldDebounced = debounce(async () => await _save(), 500);
|
const saveWorldDebounced = debounce(async () => await _save(), 500);
|
||||||
const saveSettingsDebounced = debounce(() => saveSettings(), 500);
|
const saveSettingsDebounced = debounce(() => saveSettings(), 500);
|
||||||
@@ -55,6 +57,8 @@ function setWorldInfoSettings(settings, data) {
|
|||||||
world_info_recursive = Boolean(settings.world_info_recursive);
|
world_info_recursive = Boolean(settings.world_info_recursive);
|
||||||
if (settings.world_info_case_sensitive !== undefined)
|
if (settings.world_info_case_sensitive !== undefined)
|
||||||
world_info_case_sensitive = Boolean(settings.world_info_case_sensitive);
|
world_info_case_sensitive = Boolean(settings.world_info_case_sensitive);
|
||||||
|
if (settings.world_info_match_whole_words !== undefined)
|
||||||
|
world_info_match_whole_words = Boolean(settings.world_info_match_whole_words);
|
||||||
|
|
||||||
$("#world_info_depth_counter").text(world_info_depth);
|
$("#world_info_depth_counter").text(world_info_depth);
|
||||||
$("#world_info_depth").val(world_info_depth);
|
$("#world_info_depth").val(world_info_depth);
|
||||||
@@ -64,6 +68,7 @@ function setWorldInfoSettings(settings, data) {
|
|||||||
|
|
||||||
$("#world_info_recursive").prop('checked', world_info_recursive);
|
$("#world_info_recursive").prop('checked', world_info_recursive);
|
||||||
$("#world_info_case_sensitive").prop('checked', world_info_case_sensitive);
|
$("#world_info_case_sensitive").prop('checked', world_info_case_sensitive);
|
||||||
|
$("#world_info_match_whole_words").prop('checked', world_info_match_whole_words);
|
||||||
|
|
||||||
world_names = data.world_names?.length ? data.world_names : [];
|
world_names = data.world_names?.length ? data.world_names : [];
|
||||||
|
|
||||||
@@ -517,7 +522,7 @@ function checkWorldInfo(chat) {
|
|||||||
if (Array.isArray(entry.key) && entry.key.length) {
|
if (Array.isArray(entry.key) && entry.key.length) {
|
||||||
primary: for (let key of entry.key) {
|
primary: for (let key of entry.key) {
|
||||||
const substituted = substituteParams(key);
|
const substituted = substituteParams(key);
|
||||||
if (substituted && textToScan.includes(transformString(substituted.trim()))) {
|
if (substituted && matchKeys(textToScan, substituted.trim())) {
|
||||||
if (
|
if (
|
||||||
entry.selective &&
|
entry.selective &&
|
||||||
Array.isArray(entry.keysecondary) &&
|
Array.isArray(entry.keysecondary) &&
|
||||||
@@ -525,10 +530,7 @@ function checkWorldInfo(chat) {
|
|||||||
) {
|
) {
|
||||||
secondary: for (let keysecondary of entry.keysecondary) {
|
secondary: for (let keysecondary of entry.keysecondary) {
|
||||||
const secondarySubstituted = substituteParams(keysecondary);
|
const secondarySubstituted = substituteParams(keysecondary);
|
||||||
if (
|
if (secondarySubstituted && matchKeys(textToScan, secondarySubstituted.trim())) {
|
||||||
secondarySubstituted &&
|
|
||||||
textToScan.includes(transformString(secondarySubstituted.trim()))
|
|
||||||
) {
|
|
||||||
activatedNow.add(entry.uid);
|
activatedNow.add(entry.uid);
|
||||||
break secondary;
|
break secondary;
|
||||||
}
|
}
|
||||||
@@ -576,6 +578,29 @@ function checkWorldInfo(chat) {
|
|||||||
return { worldInfoBefore, worldInfoAfter };
|
return { worldInfoBefore, worldInfoAfter };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function matchKeys(haystack, needle) {
|
||||||
|
const transformedString = transformString(needle);
|
||||||
|
|
||||||
|
if (world_info_match_whole_words) {
|
||||||
|
const keyWords = transformedString.split(/\s+/);
|
||||||
|
|
||||||
|
if (keyWords.length > 1) {
|
||||||
|
return haystack.includes(transformedString);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const regex = new RegExp(`\\b${transformedString}\\b`);
|
||||||
|
if (regex.test(haystack)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return haystack.includes(transformedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function selectImportedWorldInfo() {
|
function selectImportedWorldInfo() {
|
||||||
if (!imported_world_name) {
|
if (!imported_world_name) {
|
||||||
return;
|
return;
|
||||||
@@ -699,4 +724,9 @@ jQuery(() => {
|
|||||||
world_info_case_sensitive = !!$(this).prop('checked');
|
world_info_case_sensitive = !!$(this).prop('checked');
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('#world_info_match_whole_words').on('input', function () {
|
||||||
|
world_info_match_whole_words = !!$(this).prop('checked');
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user