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 -4Ignore whitespace
public/script.js+4 -4
@@ -4497,7 +4497,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4497 // For prompt bit itemization4497 // For prompt bit itemization
4498 let mesSendString = '';4498 let mesSendString = '';
44994499
4500 function getCombinedPrompt(isNegative) {4500 async function getCombinedPrompt(isNegative) {
4501 // Only return if the guidance scale doesn't exist or the value is 14501 // Only return if the guidance scale doesn't exist or the value is 1
4502 // Also don't return if constructing the neutral prompt4502 // Also don't return if constructing the neutral prompt
4503 if (isNegative && !useCfgPrompt) {4503 if (isNegative && !useCfgPrompt) {
@@ -4606,13 +4606,13 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4606 };4606 };
46074607
4608 // Before returning the combined prompt, give available context related information to all subscribers.4608 // Before returning the combined prompt, give available context related information to all subscribers.
4609 eventSource.emitAndWait(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data);4609 await eventSource.emit(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data);
46104610
4611 // If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context.4611 // If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context.
4612 return !data.combinedPrompt ? combine() : data.combinedPrompt;4612 return !data.combinedPrompt ? combine() : data.combinedPrompt;
4613 }4613 }
46144614
4615 let finalPrompt = getCombinedPrompt(false);4615 let finalPrompt = await getCombinedPrompt(false);
46164616
4617 const eventData = { prompt: finalPrompt, dryRun: dryRun };4617 const eventData = { prompt: finalPrompt, dryRun: dryRun };
4618 await eventSource.emit(event_types.GENERATE_AFTER_COMBINE_PROMPTS, eventData);4618 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
4646 }4646 }
4647 break;4647 break;
4648 case 'textgenerationwebui': {4648 case 'textgenerationwebui': {
4649 const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: getCombinedPrompt(true) } : null;4649 const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;
4650 generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);4650 generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
4651 break;4651 break;
4652 }4652 }