Normalize SD prompt strings

9f170979767282de625d32659dfbb6bf0ea01a49

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +6 -0Ignore whitespace
public/scripts/extensions/stable-diffusion/index.js+6 -0
@@ -2178,6 +2178,11 @@ function getQuietPrompt(mode, trigger) {
21782178 return stringFormat(extension_settings.sd.prompts[mode], trigger);
21792179}
21802180
2181+/**
2182+ * Sanitizes generated prompt for image generation.
2183+ * @param {string} str String to process
2184+ * @returns {string} Processed reply
2185+ */
21812186function processReply(str) {
21822187 if (!str) {
21832188 return '';
@@ -2187,6 +2192,7 @@ function processReply(str) {
21872192 str = str.replaceAll('“', '');
21882193 str = str.replaceAll('.', ',');
21892194 str = str.replaceAll('\n', ', ');
2195+ str = str.normalize('NFD');
21902196 str = str.replace(/[^a-zA-Z0-9,:_(){}<>[\]\-']+/g, ' ');
21912197 str = str.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one
21922198 str = str.trim();