replaced disable placeholder card with Narrator mode (changes prompt a bit to support open ended rpgs/narrator cards that don't have defined characters better)

This commit is contained in:
munimunigamer
2025-12-26 01:31:16 -06:00
parent c73260b2c6
commit d10d4e876f
6 changed files with 43 additions and 14 deletions
+3 -3
View File
@@ -331,8 +331,8 @@ async function initUI() {
updateSectionVisibility(); updateSectionVisibility();
}); });
$('#rpg-toggle-placeholder-card').on('change', function() { $('#rpg-toggle-narrator-mode').on('change', function() {
extensionSettings.showPlaceholderCharacterCard = $(this).prop('checked'); extensionSettings.narratorMode = $(this).prop('checked');
saveSettings(); saveSettings();
}); });
@@ -493,7 +493,7 @@ async function initUI() {
$('#rpg-toggle-user-stats').prop('checked', extensionSettings.showUserStats); $('#rpg-toggle-user-stats').prop('checked', extensionSettings.showUserStats);
$('#rpg-toggle-info-box').prop('checked', extensionSettings.showInfoBox); $('#rpg-toggle-info-box').prop('checked', extensionSettings.showInfoBox);
$('#rpg-toggle-thoughts').prop('checked', extensionSettings.showCharacterThoughts); $('#rpg-toggle-thoughts').prop('checked', extensionSettings.showCharacterThoughts);
$('#rpg-toggle-placeholder-card').prop('checked', extensionSettings.showPlaceholderCharacterCard); $('#rpg-toggle-narrator-mode').prop('checked', extensionSettings.narratorMode);
$('#rpg-toggle-inventory').prop('checked', extensionSettings.showInventory); $('#rpg-toggle-inventory').prop('checked', extensionSettings.showInventory);
$('#rpg-toggle-quests').prop('checked', extensionSettings.showQuests); $('#rpg-toggle-quests').prop('checked', extensionSettings.showQuests);
$('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat); $('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat);
+1 -1
View File
@@ -21,7 +21,7 @@ export let extensionSettings = {
showInventory: true, // Show inventory section (v2 system) showInventory: true, // Show inventory section (v2 system)
showQuests: true, // Show quests section showQuests: true, // Show quests section
showThoughtsInChat: true, // Show thoughts overlay in chat showThoughtsInChat: true, // Show thoughts overlay in chat
showPlaceholderCharacterCard: true, // Show placeholder character card when no characters detected narratorMode: false, // Use character card as narrator instead of fixed character references
enableHtmlPrompt: false, // Enable immersive HTML prompt injection enableHtmlPrompt: false, // Enable immersive HTML prompt injection
customHtmlPrompt: '', // Custom HTML prompt text (empty = use default) customHtmlPrompt: '', // Custom HTML prompt text (empty = use default)
skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility) skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility)
+2 -2
View File
@@ -29,8 +29,8 @@
"template.settingsModal.display.showUserStats": "Show User Stats", "template.settingsModal.display.showUserStats": "Show User Stats",
"template.settingsModal.display.showInfoBox": "Show Info Box", "template.settingsModal.display.showInfoBox": "Show Info Box",
"template.settingsModal.display.showPresentCharacters": "Show Present Characters", "template.settingsModal.display.showPresentCharacters": "Show Present Characters",
"template.settingsModal.display.showPlaceholderCharacterCard": "Show Placeholder Character Card", "template.settingsModal.display.narratorMode": "Narrator Mode",
"template.settingsModal.display.showPlaceholderCharacterCardNote": "When no characters are detected, show a placeholder character card. Disable for narrator-only stories.", "template.settingsModal.display.narratorModeNote": "Use character card as narrator. Infer characters from context instead of using fixed character references.",
"template.settingsModal.display.showInventory": "Show Inventory", "template.settingsModal.display.showInventory": "Show Inventory",
"template.settingsModal.display.showQuests": "Show Quests", "template.settingsModal.display.showQuests": "Show Quests",
"template.settingsModal.display.showThoughtsInChat": "Show Thoughts in Chat", "template.settingsModal.display.showThoughtsInChat": "Show Thoughts in Chat",
+31 -2
View File
@@ -23,6 +23,27 @@ export const DEFAULT_HTML_PROMPT = `If appropriate, include inline HTML, CSS, an
async function getCharacterCardsInfo() { async function getCharacterCardsInfo() {
let characterInfo = ''; let characterInfo = '';
// Narrator mode: use character card as narrator context, infer characters from story context
if (extensionSettings.narratorMode) {
if (this_chid !== undefined && characters && characters[this_chid]) {
const character = characters[this_chid];
characterInfo += 'You are acting as the narrator for this story. The narrator card provides context for the story tone and style:\n\n';
characterInfo += `<narrator>\n`;
if (character.description) {
characterInfo += `${character.description}\n`;
}
if (character.personality) {
characterInfo += `${character.personality}\n`;
}
characterInfo += `</narrator>\n\n`;
characterInfo += `Infer the identity and details of characters present in each scene from the story context below. Do not use fixed character references - instead, identify characters naturally based on their actions, dialogue, and descriptions in the narrative.\n\n`;
}
return characterInfo;
}
// Check if in group chat // Check if in group chat
if (selected_group) { if (selected_group) {
// Find the current group directly from the groups array // Find the current group directly from the groups array
@@ -331,7 +352,11 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
.join(' | '); .join(' | ');
// Character block format // Character block format
instructions += `- [Name (do not include ${userName}; state "Unavailable" if no major characters are present in the scene)]\n`; if (extensionSettings.narratorMode) {
instructions += `- [Character Name (infer from story context; do not include ${userName}; state "Unavailable" if no other characters are present in the scene)]\n`;
} else {
instructions += `- [Name (do not include ${userName}; state "Unavailable" if no major characters are present in the scene)]\n`;
}
// Details line with emoji and custom fields // Details line with emoji and custom fields
if (fieldPlaceholders) { if (fieldPlaceholders) {
@@ -358,7 +383,11 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
instructions += `${thoughtsName}: [${thoughtsDescription}]\n`; instructions += `${thoughtsName}: [${thoughtsDescription}]\n`;
} }
instructions += `- … (Repeat the format above for every other present major character)\n`; if (extensionSettings.narratorMode) {
instructions += `- … (Repeat the format above for every other character present in the scene, inferred from story context)\n`;
} else {
instructions += `- … (Repeat the format above for every other present major character)\n`;
}
instructions += codeBlockMarker + '\n\n'; instructions += codeBlockMarker + '\n\n';
} }
+2 -2
View File
@@ -441,8 +441,8 @@ export function renderThoughts() {
debugLog('[RPG Thoughts] ==================== BUILDING HTML ===================='); debugLog('[RPG Thoughts] ==================== BUILDING HTML ====================');
debugLog('[RPG Thoughts] Starting HTML generation for', presentCharacters.length + ' characters'); debugLog('[RPG Thoughts] Starting HTML generation for', presentCharacters.length + ' characters');
// If no characters parsed, show a placeholder editable card (if enabled) // If no characters parsed, show a placeholder editable card (if narrator mode is disabled)
if (presentCharacters.length === 0 && extensionSettings.showPlaceholderCharacterCard) { if (presentCharacters.length === 0 && !extensionSettings.narratorMode) {
debugLog('[RPG Thoughts] ⚠ No characters parsed - showing placeholder card'); debugLog('[RPG Thoughts] ⚠ No characters parsed - showing placeholder card');
// Get default character portrait // Get default character portrait
let defaultPortrait = FALLBACK_AVATAR_DATA_URI; let defaultPortrait = FALLBACK_AVATAR_DATA_URI;
+4 -4
View File
@@ -181,11 +181,11 @@
</label> </label>
<label class="checkbox_label"> <label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-placeholder-card" /> <input type="checkbox" id="rpg-toggle-narrator-mode" />
<span data-i18n-key="template.settingsModal.display.showPlaceholderCharacterCard">Show Placeholder Character Card</span> <span data-i18n-key="template.settingsModal.display.narratorMode">Narrator Mode</span>
</label> </label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.display.showPlaceholderCharacterCardNote"> <small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.display.narratorModeNote">
When no characters are detected, show a placeholder character card. Disable for narrator-only stories. Use character card as narrator. Infer characters from context instead of using fixed character references.
</small> </small>
<label class="checkbox_label"> <label class="checkbox_label">