mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Normalize SD prompt strings
This commit is contained in:
@ -2178,6 +2178,11 @@ function getQuietPrompt(mode, trigger) {
|
|||||||
return stringFormat(extension_settings.sd.prompts[mode], trigger);
|
return stringFormat(extension_settings.sd.prompts[mode], trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitizes generated prompt for image generation.
|
||||||
|
* @param {string} str String to process
|
||||||
|
* @returns {string} Processed reply
|
||||||
|
*/
|
||||||
function processReply(str) {
|
function processReply(str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return '';
|
return '';
|
||||||
@ -2187,6 +2192,7 @@ function processReply(str) {
|
|||||||
str = str.replaceAll('“', '');
|
str = str.replaceAll('“', '');
|
||||||
str = str.replaceAll('.', ',');
|
str = str.replaceAll('.', ',');
|
||||||
str = str.replaceAll('\n', ', ');
|
str = str.replaceAll('\n', ', ');
|
||||||
|
str = str.normalize('NFD');
|
||||||
str = str.replace(/[^a-zA-Z0-9,:_(){}<>[\]\-']+/g, ' ');
|
str = str.replace(/[^a-zA-Z0-9,:_(){}<>[\]\-']+/g, ' ');
|
||||||
str = str.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one
|
str = str.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
|
Reference in New Issue
Block a user