Merge pull request #3430 from qvink/generate_before_combine_prompts_await await GENERATE_BEFORE_COMBINE_PROMPTS
Signed| @@ -4497,7 +4497,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 4497 | 4497 | // For prompt bit itemization |
| 4498 | 4498 | let mesSendString = ''; |
| 4499 | 4499 | |
| 4500 | 4500 | async function getCombinedPrompt(isNegative) { |
| 4501 | 4501 | // Only return if the guidance scale doesn't exist or the value is 1 |
| 4502 | 4502 | // Also don't return if constructing the neutral prompt |
| 4503 | 4503 | if (isNegative && !useCfgPrompt) { |
| @@ -4606,13 +4606,13 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 4606 | 4606 | }; |
| 4607 | 4607 | |
| 4608 | 4608 | // Before returning the combined prompt, give available context related information to all subscribers. |
| 4609 | 4609 | await eventSource.emitAndWaitemit(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data); |
| 4610 | 4610 | |
| 4611 | 4611 | // If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context. |
| 4612 | 4612 | return !data.combinedPrompt ? combine() : data.combinedPrompt; |
| 4613 | 4613 | } |
| 4614 | 4614 | |
| 4615 | 4615 | let finalPrompt = await getCombinedPrompt(false); |
| 4616 | 4616 | |
| 4617 | 4617 | const eventData = { prompt: finalPrompt, dryRun: dryRun }; |
| 4618 | 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 | 4647 | break; |
| 4648 | 4648 | case 'textgenerationwebui': { |
| 4649 | 4649 | const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null; |
| 4650 | 4650 | generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type); |
| 4651 | 4651 | break; |
| 4652 | 4652 | } |