Don't double-expand prompts if reusing

This commit is contained in:
Cohee
2023-10-20 15:43:55 +03:00
parent c4e6b565a5
commit 0b0b125bca

View File

@ -321,8 +321,14 @@ async function expandPrompt(prompt) {
} }
} }
async function refinePrompt(prompt) { /**
if (extension_settings.sd.expand) { * Modifies prompt based on auto-expansion and user inputs.
* @param {string} prompt Prompt to refine
* @param {boolean} allowExpand Whether to allow auto-expansion
* @returns {Promise<string>} Refined prompt
*/
async function refinePrompt(prompt, allowExpand) {
if (allowExpand && extension_settings.sd.expand) {
prompt = await expandPrompt(prompt); prompt = await expandPrompt(prompt);
} }
@ -1159,7 +1165,7 @@ async function getPrompt(generationType, message, trigger, quiet_prompt) {
} }
if (generationType !== generationMode.FREE) { if (generationType !== generationMode.FREE) {
prompt = await refinePrompt(prompt); prompt = await refinePrompt(prompt, true);
} }
return prompt; return prompt;
@ -1553,7 +1559,7 @@ async function sdMessageButton(e) {
try { try {
setBusyIcon(true); setBusyIcon(true);
if (hasSavedImage) { if (hasSavedImage) {
const prompt = await refinePrompt(message.extra.title); const prompt = await refinePrompt(message.extra.title, false);
message.extra.title = prompt; message.extra.title = prompt;
console.log('Regenerating an image, using existing prompt:', prompt); console.log('Regenerating an image, using existing prompt:', prompt);