ImageGen: Add a placeholder for {{prefixedPrompt}} in the message template Closes #2946
| @@ -2309,14 +2309,14 @@ async function generatePicture(initiator, args, trigger, message, callback) { | |||
| 2309 | 2309 | ||
| 2310 | if (generationType == generationMode.BACKGROUND) { | 2310 | if (generationType == generationMode.BACKGROUND) { |
| 2311 | const callbackOriginal = callback; | 2311 | const callbackOriginal = callback; |
| 2312 | callback = async function (prompt, imagePath, generationType) { | 2312 | callback = async function (prompt, imagePath, generationType, _negativePromptPrefix, _initiator, prefixedPrompt) { |
| 2313 | const imgUrl = `url("${encodeURI(imagePath)}")`; | 2313 | const imgUrl = `url("${encodeURI(imagePath)}")`; |
| 2314 | eventSource.emit(event_types.FORCE_SET_BACKGROUND, { url: imgUrl, path: imagePath }); | 2314 | eventSource.emit(event_types.FORCE_SET_BACKGROUND, { url: imgUrl, path: imagePath }); |
| 2315 | 2315 | ||
| 2316 | if (typeof callbackOriginal === 'function') { | 2316 | if (typeof callbackOriginal === 'function') { |
| 2317 | await callbackOriginal(prompt, imagePath, generationType, negativePromptPrefix, initiator); | 2317 | await callbackOriginal(prompt, imagePath, generationType, negativePromptPrefix, initiator, prefixedPrompt); |
| 2318 | } else { | 2318 | } else { |
| 2319 | await sendMessage(prompt, imagePath, generationType, negativePromptPrefix, initiator); | 2319 | await sendMessage(prompt, imagePath, generationType, negativePromptPrefix, initiator, prefixedPrompt); |
| 2320 | } | 2320 | } |
| 2321 | }; | 2321 | }; |
| 2322 | } | 2322 | } |
| @@ -2646,8 +2646,8 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP | |||
| 2646 | const filename = `${characterName}_${humanizedDateTime()}`; | 2646 | const filename = `${characterName}_${humanizedDateTime()}`; |
| 2647 | const base64Image = await saveBase64AsFile(result.data, characterName, filename, result.format); | 2647 | const base64Image = await saveBase64AsFile(result.data, characterName, filename, result.format); |
| 2648 | callback | 2648 | callback |
| 2649 | ? await callback(prompt, base64Image, generationType, additionalNegativePrefix, initiator) | 2649 | ? await callback(prompt, base64Image, generationType, additionalNegativePrefix, initiator, prefixedPrompt) |
| 2650 | : await sendMessage(prompt, base64Image, generationType, additionalNegativePrefix, initiator); | 2650 | : await sendMessage(prompt, base64Image, generationType, additionalNegativePrefix, initiator, prefixedPrompt); |
| 2651 | return base64Image; | 2651 | return base64Image; |
| 2652 | } | 2652 | } |
| 2653 | 2653 | ||
| @@ -3435,12 +3435,13 @@ async function onComfyDeleteWorkflowClick() { | |||
| 3435 | * @param {number} generationType Generation type of the image | 3435 | * @param {number} generationType Generation type of the image |
| 3436 | * @param {string} additionalNegativePrefix Additional negative prompt used for the image generation | 3436 | * @param {string} additionalNegativePrefix Additional negative prompt used for the image generation |
| 3437 | * @param {string} initiator The initiator of the image generation | 3437 | * @param {string} initiator The initiator of the image generation |
| 3438 | * @param {string} prefixedPrompt Prompt with an attached specific prefix | ||
| 3438 | */ | 3439 | */ |
| 3439 | async function sendMessage(prompt, image, generationType, additionalNegativePrefix, initiator) { | 3440 | async function sendMessage(prompt, image, generationType, additionalNegativePrefix, initiator, prefixedPrompt) { |
| 3440 | const context = getContext(); | 3441 | const context = getContext(); |
| 3441 | const name = context.groupId ? systemUserName : context.name2; | 3442 | const name = context.groupId ? systemUserName : context.name2; |
| 3442 | const template = extension_settings.sd.prompts[generationMode.MESSAGE] || '{{prompt}}'; | 3443 | const template = extension_settings.sd.prompts[generationMode.MESSAGE] || '{{prompt}}'; |
| 3443 | const messageText = substituteParamsExtended(template, { char: name, prompt: prompt }); | 3444 | const messageText = substituteParamsExtended(template, { char: name, prompt: prompt, prefixedPrompt: prefixedPrompt }); |
| 3444 | const message = { | 3445 | const message = { |
| 3445 | name: name, | 3446 | name: name, |
| 3446 | is_user: false, | 3447 | is_user: false, |