v3.2.5: Always enable JSON cleaning regex with proper settings
This commit is contained in:
@@ -313,18 +313,6 @@ async function initUI() {
|
|||||||
extensionSettings.generationMode = String($(this).val());
|
extensionSettings.generationMode = String($(this).val());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
updateGenerationModeUI();
|
updateGenerationModeUI();
|
||||||
|
|
||||||
// Add or remove JSON cleaning regex based on mode
|
|
||||||
// This ensures old messages in chat history are also cleaned
|
|
||||||
try {
|
|
||||||
if (extensionSettings.generationMode === 'together') {
|
|
||||||
await ensureJsonCleaningRegex(st_extension_settings, saveSettingsDebounced);
|
|
||||||
} else {
|
|
||||||
removeJsonCleaningRegex(st_extension_settings, saveSettingsDebounced);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('[RPG Companion] JSON cleaning regex update failed:', error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#rpg-toggle-user-stats').on('change', function() {
|
$('#rpg-toggle-user-stats').on('change', function() {
|
||||||
@@ -1000,17 +988,10 @@ jQuery(async () => {
|
|||||||
// Non-critical - continue without it
|
// Non-critical - continue without it
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import the JSON cleaning regex for Together mode if enabled
|
// Import the JSON cleaning regex to clean up JSON in messages
|
||||||
// This cleans historical messages when displayed
|
// This cleans historical messages when displayed
|
||||||
// Note: We also clean directly in message handler for redundancy
|
|
||||||
try {
|
try {
|
||||||
// console.log('[RPG Companion] Checking JSON cleaning regex. Generation mode:', extensionSettings.generationMode);
|
await ensureJsonCleaningRegex(st_extension_settings, saveSettingsDebounced);
|
||||||
if (extensionSettings.generationMode === 'together') {
|
|
||||||
await ensureJsonCleaningRegex(st_extension_settings, saveSettingsDebounced);
|
|
||||||
} else {
|
|
||||||
// Remove the regex if switching to separate mode
|
|
||||||
removeJsonCleaningRegex(st_extension_settings, saveSettingsDebounced);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[RPG Companion] JSON cleaning regex setup failed:', error);
|
console.error('[RPG Companion] JSON cleaning regex setup failed:', error);
|
||||||
// Non-critical - continue without it
|
// Non-critical - continue without it
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,6 @@
|
|||||||
"js": "index.js",
|
"js": "index.js",
|
||||||
"css": "style.css",
|
"css": "style.css",
|
||||||
"author": "Marinara",
|
"author": "Marinara",
|
||||||
"version": "3.2.4",
|
"version": "3.2.5",
|
||||||
"homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern"
|
"homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="margin-top: 10px; text-align: center; opacity: 0.6; font-size: 0.85em;">
|
<div style="margin-top: 10px; text-align: center; opacity: 0.6; font-size: 0.85em;">
|
||||||
v3.2.4
|
v3.2.5
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,40 +35,53 @@ export async function ensureJsonCleaningRegex(st_extension_settings, saveSetting
|
|||||||
// Update existing script with new regex pattern if it's different
|
// Update existing script with new regex pattern if it's different
|
||||||
const newPattern = '/```json[\\s\\S]*?```/gim';
|
const newPattern = '/```json[\\s\\S]*?```/gim';
|
||||||
|
|
||||||
|
// Always ensure these properties are set correctly
|
||||||
|
let needsSave = false;
|
||||||
|
|
||||||
if (existingScript.findRegex !== newPattern) {
|
if (existingScript.findRegex !== newPattern) {
|
||||||
existingScript.findRegex = newPattern;
|
existingScript.findRegex = newPattern;
|
||||||
existingScript.placement = [2]; // 2 = AI Output
|
needsSave = true;
|
||||||
existingScript.disabled = false; // Ensure it's enabled
|
|
||||||
existingScript.runOnEdit = true; // Ensure it runs on edit
|
|
||||||
existingScript.displayOnly = true; // Alter Chat Display
|
|
||||||
existingScript.onlyFormatDisplay = true; // Ensure display formatting is enabled
|
|
||||||
|
|
||||||
if (typeof saveSettingsDebounced === 'function') {
|
|
||||||
saveSettingsDebounced();
|
|
||||||
}
|
|
||||||
console.log('[RPG Companion] Updated regex pattern and placement.');
|
|
||||||
} else {
|
|
||||||
// Ensure it's enabled even if pattern matches
|
|
||||||
if (existingScript.disabled) {
|
|
||||||
existingScript.disabled = false;
|
|
||||||
if (typeof saveSettingsDebounced === 'function') {
|
|
||||||
saveSettingsDebounced();
|
|
||||||
}
|
|
||||||
console.log('[RPG Companion] Re-enabled disabled regex.');
|
|
||||||
} else {
|
|
||||||
// Also update placement if it's wrong
|
|
||||||
const expectedPlacement = [2]; // 2 = AI Output
|
|
||||||
if (JSON.stringify(existingScript.placement) !== JSON.stringify(expectedPlacement)) {
|
|
||||||
existingScript.placement = expectedPlacement;
|
|
||||||
if (typeof saveSettingsDebounced === 'function') {
|
|
||||||
saveSettingsDebounced();
|
|
||||||
// Force immediate save after a short delay
|
|
||||||
setTimeout(() => saveSettingsDebounced(), 100);
|
|
||||||
}
|
|
||||||
console.log('[RPG Companion] Updated regex placement to [2].');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (JSON.stringify(existingScript.placement) !== JSON.stringify([2])) {
|
||||||
|
existingScript.placement = [2]; // 2 = AI Output
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.disabled !== false) {
|
||||||
|
existingScript.disabled = false;
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.runOnEdit !== true) {
|
||||||
|
existingScript.runOnEdit = true;
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.displayOnly !== true) {
|
||||||
|
existingScript.displayOnly = true; // Alter Chat Display
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.onlyFormatDisplay !== true) {
|
||||||
|
existingScript.onlyFormatDisplay = true; // Alter Chat Display
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.onlyFormatPrompt !== true) {
|
||||||
|
existingScript.onlyFormatPrompt = true; // Alter Outgoing Prompt
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.promptOnly !== true) {
|
||||||
|
existingScript.promptOnly = true; // Enable prompt processing
|
||||||
|
needsSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingScript.filterGaslighting !== true) {
|
||||||
|
existingScript.filterGaslighting = true; // Ephemerality
|
||||||
|
}
|
||||||
|
|
||||||
console.log('[RPG Companion] JSON Cleaning Regex is already downloaded and active.');
|
console.log('[RPG Companion] JSON Cleaning Regex is already downloaded and active.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,10 +110,11 @@ export async function ensureJsonCleaningRegex(st_extension_settings, saveSetting
|
|||||||
placement: [2], // 2 = AI Output
|
placement: [2], // 2 = AI Output
|
||||||
disabled: false,
|
disabled: false,
|
||||||
markdownOnly: false,
|
markdownOnly: false,
|
||||||
promptOnly: false,
|
promptOnly: true, // Enable prompt processing
|
||||||
runOnEdit: true,
|
runOnEdit: true,
|
||||||
displayOnly: true, // Alter Chat Display
|
onlyFormatDisplay: true, // Alter Chat Display (enabled)
|
||||||
onlyFormatDisplay: true, // Ensure display formatting is enabled
|
onlyFormatPrompt: true, // Alter Outgoing Prompt (enabled)
|
||||||
|
filterGaslighting: true, // Ephemerality - makes it only affect display
|
||||||
substituteRegex: 0,
|
substituteRegex: 0,
|
||||||
minDepth: null,
|
minDepth: null,
|
||||||
maxDepth: null
|
maxDepth: null
|
||||||
|
|||||||
Reference in New Issue
Block a user