mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-16 11:47:20 +02:00
Merge pull request #3430 from qvink/generate_before_combine_prompts_await
await GENERATE_BEFORE_COMBINE_PROMPTS
This commit is contained in:
commit
d9fc76f336
@ -4497,7 +4497,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
// For prompt bit itemization
|
// For prompt bit itemization
|
||||||
let mesSendString = '';
|
let mesSendString = '';
|
||||||
|
|
||||||
function getCombinedPrompt(isNegative) {
|
async function getCombinedPrompt(isNegative) {
|
||||||
// Only return if the guidance scale doesn't exist or the value is 1
|
// Only return if the guidance scale doesn't exist or the value is 1
|
||||||
// Also don't return if constructing the neutral prompt
|
// Also don't return if constructing the neutral prompt
|
||||||
if (isNegative && !useCfgPrompt) {
|
if (isNegative && !useCfgPrompt) {
|
||||||
@ -4606,13 +4606,13 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Before returning the combined prompt, give available context related information to all subscribers.
|
// Before returning the combined prompt, give available context related information to all subscribers.
|
||||||
eventSource.emitAndWait(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data);
|
await eventSource.emit(event_types.GENERATE_BEFORE_COMBINE_PROMPTS, data);
|
||||||
|
|
||||||
// If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context.
|
// If one or multiple subscribers return a value, forfeit the responsibillity of flattening the context.
|
||||||
return !data.combinedPrompt ? combine() : data.combinedPrompt;
|
return !data.combinedPrompt ? combine() : data.combinedPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
let finalPrompt = getCombinedPrompt(false);
|
let finalPrompt = await getCombinedPrompt(false);
|
||||||
|
|
||||||
const eventData = { prompt: finalPrompt, dryRun: dryRun };
|
const eventData = { prompt: finalPrompt, dryRun: dryRun };
|
||||||
await eventSource.emit(event_types.GENERATE_AFTER_COMBINE_PROMPTS, eventData);
|
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
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'textgenerationwebui': {
|
case 'textgenerationwebui': {
|
||||||
const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: getCombinedPrompt(true) } : null;
|
const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;
|
||||||
generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
|
generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user