Merge pull request #3430 from qvink/generate_before_combine_prompts_await await GENERATE_BEFORE_COMBINE_PROMPTS

d9fc76f336a72d60b446e284360b20f3fbf5ca8c

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +4 -4Showing whitespace changes
public/script.js+4 -4
@@ -4497,7 +4497,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
44974497 // For prompt bit itemization
44984498 let mesSendString = '';
44994499
45004500 async function getCombinedPrompt(isNegative) {
45014501 // Only return if the guidance scale doesn't exist or the value is 1
45024502 // Also don't return if constructing the neutral prompt
45034503 if (isNegative && !useCfgPrompt) {
@@ -4606,13 +4606,13 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
46064606 };
46074607
46084608 // Before returning the combined prompt, give available context related information to all subscribers.
46094609 await eventSource.emitAndWaitemit(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data);
46104610
46114611 // If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context.
46124612 return !data.combinedPrompt ? combine() : data.combinedPrompt;
46134613 }
46144614
46154615 let finalPrompt = await getCombinedPrompt(false);
46164616
46174617 const eventData = { prompt: finalPrompt, dryRun: dryRun };
46184618 await eventSource.emit(event_types.GENERATE_AFTER_COMBINE_PROMPTS, eventData);
@@ -4646,7 +4646,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
46464646 }
46474647 break;
46484648 case 'textgenerationwebui': {
46494649 const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;
46504650 generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
46514651 break;
46524652 }