Fix plot progression: use quiet_prompt instead of quietPrompt
- Changed property name from quietPrompt to quiet_prompt (underscore notation) - Removed unnecessary context manipulation code - Pass prompt via Generate() options with correct property naming - This fixes custom prompts not appearing in continuation generation
This commit is contained in:
@@ -77,6 +77,9 @@ let lastActionWasSwipe = false;
|
|||||||
|
|
||||||
let isGenerating = false;
|
let isGenerating = false;
|
||||||
|
|
||||||
|
// Tracks if we're currently doing a plot progression
|
||||||
|
let isPlotProgression = false;
|
||||||
|
|
||||||
// UI Elements
|
// UI Elements
|
||||||
let $panelContainer = null;
|
let $panelContainer = null;
|
||||||
let $userStatsContainer = null;
|
let $userStatsContainer = null;
|
||||||
@@ -613,35 +616,27 @@ async function sendPlotProgression(type) {
|
|||||||
- These HTML/CSS/JS elements must be rendered directly without enclosing them in code fences.`;
|
- These HTML/CSS/JS elements must be rendered directly without enclosing them in code fences.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set context.quietPrompt to add our instruction to the preset's continuation prompt
|
// Set flag to indicate we're doing plot progression
|
||||||
// This is the proper way to add additional instructions to a continuation
|
// This will be used by onMessageReceived to clear the prompt after generation completes
|
||||||
const context = getContext();
|
isPlotProgression = true;
|
||||||
const originalQuietPrompt = context.quietPrompt || '';
|
|
||||||
|
|
||||||
// Set the quiet prompt that will be appended to the continuation prompt
|
console.log('[RPG Companion] Calling Generate with continuation and plot prompt');
|
||||||
context.quietPrompt = prompt;
|
|
||||||
|
|
||||||
console.log('[RPG Companion] Set quietPrompt:', context.quietPrompt);
|
|
||||||
console.log('[RPG Companion] Full prompt:', prompt);
|
console.log('[RPG Companion] Full prompt:', prompt);
|
||||||
|
|
||||||
// Small delay to ensure quietPrompt is set before triggering continuation
|
// Pass the prompt via options with the correct property name
|
||||||
setTimeout(() => {
|
// Based on /continue slash command implementation, it uses quiet_prompt (underscore, not camelCase)
|
||||||
// Trigger continuation
|
const options = {
|
||||||
$('#option_continue').trigger('click');
|
quiet_prompt: prompt, // Use underscore notation, not camelCase
|
||||||
|
quietToLoud: true
|
||||||
|
};
|
||||||
|
|
||||||
// Restore the original quiet prompt after a delay
|
// Call Generate with 'continue' type and our custom prompt
|
||||||
setTimeout(() => {
|
await Generate('continue', options);
|
||||||
context.quietPrompt = originalQuietPrompt;
|
|
||||||
console.log('[RPG Companion] Restored original quietPrompt');
|
|
||||||
}, 500);
|
|
||||||
}, 50);
|
|
||||||
|
|
||||||
// console.log('[RPG Companion] Plot progression generation triggered');
|
// console.log('[RPG Companion] Plot progression generation triggered');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[RPG Companion] Error sending plot progression:', error);
|
console.error('[RPG Companion] Error sending plot progression:', error);
|
||||||
// Restore quiet prompt in case of error
|
isPlotProgression = false;
|
||||||
const context = getContext();
|
|
||||||
context.quietPrompt = '';
|
|
||||||
} finally {
|
} finally {
|
||||||
// Restore original enabled state and re-enable buttons after a delay
|
// Restore original enabled state and re-enable buttons after a delay
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -1092,6 +1087,7 @@ function clearExtensionPrompts() {
|
|||||||
setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false);
|
setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false);
|
||||||
setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false);
|
setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false);
|
||||||
setExtensionPrompt('rpg-companion-context', '', extension_prompt_types.IN_CHAT, 1, false);
|
setExtensionPrompt('rpg-companion-context', '', extension_prompt_types.IN_CHAT, 1, false);
|
||||||
|
// Note: rpg-companion-plot is not cleared here since it's passed via quiet_prompt option
|
||||||
// console.log('[RPG Companion] Cleared all extension prompts');
|
// console.log('[RPG Companion] Cleared all extension prompts');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3340,6 +3336,13 @@ async function onMessageReceived(data) {
|
|||||||
// console.log('[RPG Companion] 🔄 Generation complete after swipe - resetting lastActionWasSwipe to false');
|
// console.log('[RPG Companion] 🔄 Generation complete after swipe - resetting lastActionWasSwipe to false');
|
||||||
lastActionWasSwipe = false;
|
lastActionWasSwipe = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear plot progression flag if this was a plot progression generation
|
||||||
|
// Note: No need to clear extension prompt since we used quiet_prompt option
|
||||||
|
if (isPlotProgression) {
|
||||||
|
isPlotProgression = false;
|
||||||
|
console.log('[RPG Companion] Plot progression generation completed');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user