mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#652 Add custom stop strings
This commit is contained in:
@@ -1915,6 +1915,20 @@
|
||||
Show reply prefix in chat
|
||||
</span>
|
||||
</label>
|
||||
<h4>
|
||||
<span data-i18n="Custom Stopping Strings">
|
||||
Custom Stopping Strings (KoboldAI/TextGen)
|
||||
</span>
|
||||
<div>
|
||||
<small>
|
||||
<span data-i18n="JSON serialized array of strings">JSON serialized array of strings, for example:</span><br>
|
||||
<span class="monospace">["\n", "\nUser:", "\nChar:"]</span>
|
||||
</small>
|
||||
</div>
|
||||
</h4>
|
||||
<div>
|
||||
<textarea id="custom_stopping_strings" rows="2" class="text_pole textarea_compact" placeholder="["Ford", "BMW", "Fiat"]"></textarea>
|
||||
</div>
|
||||
<h4>
|
||||
<span data-i18n="Pygmalion Formatting">
|
||||
Pygmalion Formatting
|
||||
|
@@ -74,6 +74,7 @@ import {
|
||||
formatInstructModePrompt,
|
||||
persona_description_positions,
|
||||
loadMovingUIState,
|
||||
getCustomStoppingStrings,
|
||||
} from "./scripts/power-user.js";
|
||||
|
||||
import {
|
||||
@@ -1624,6 +1625,11 @@ function getStoppingStrings(isImpersonate, addSpace) {
|
||||
}
|
||||
}
|
||||
|
||||
if (power_user.custom_stopping_strings) {
|
||||
const customStoppingStrings = getCustomStoppingStrings();
|
||||
result.push(...customStoppingStrings);
|
||||
}
|
||||
|
||||
return addSpace ? result.map(x => `${x} `) : result;
|
||||
}
|
||||
|
||||
|
@@ -186,6 +186,8 @@ let power_user = {
|
||||
|
||||
persona_description: '',
|
||||
persona_description_position: persona_description_positions.BEFORE_CHAR,
|
||||
|
||||
custom_stopping_strings: '',
|
||||
};
|
||||
|
||||
let themes = [];
|
||||
@@ -651,6 +653,7 @@ function loadPowerUserSettings(settings, data) {
|
||||
$('#auto_swipe_minimum_length').val(power_user.auto_swipe_minimum_length);
|
||||
$('#auto_swipe_blacklist').val(power_user.auto_swipe_blacklist.join(", "));
|
||||
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
|
||||
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
||||
|
||||
$("#console_log_prompts").prop("checked", power_user.console_log_prompts);
|
||||
$('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown);
|
||||
@@ -1381,6 +1384,25 @@ function setAvgBG() {
|
||||
|
||||
}
|
||||
|
||||
export function getCustomStoppingStrings() {
|
||||
try {
|
||||
// Parse the JSON string
|
||||
const strings = JSON.parse(power_user.custom_stopping_strings);
|
||||
|
||||
// Make sure it's an array
|
||||
if (!Array.isArray(strings)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Make sure all the elements are strings
|
||||
return strings.filter((s) => typeof s === 'string');
|
||||
} catch (error) {
|
||||
// If there's an error, return an empty array
|
||||
console.warn('Error parsing custom stopping strings:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
|
||||
$(window).on('resize', async () => {
|
||||
@@ -1832,6 +1854,11 @@ $(document).ready(() => {
|
||||
$(this).toggleClass('fa-eye fa-eye-slash');
|
||||
});
|
||||
|
||||
$('#custom_stopping_strings').on('input', function () {
|
||||
power_user.custom_stopping_strings = $(this).val();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(window).on('focus', function () {
|
||||
browser_has_focus = true;
|
||||
});
|
||||
|
Reference in New Issue
Block a user