mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 17:36:22 +01:00
CFG: Don't inject anything when guidance scale doesn't exist
If the guidance scale is 1, completely disable sending CFG and creating a negative prompt. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
2c2a68ef76
commit
0460375647
@ -2741,6 +2741,12 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
// Fetches the combined prompt for both negative and positive prompts
|
// Fetches the combined prompt for both negative and positive prompts
|
||||||
const cfgGuidanceScale = getGuidanceScale();
|
const cfgGuidanceScale = getGuidanceScale();
|
||||||
function getCombinedPrompt(isNegative) {
|
function getCombinedPrompt(isNegative) {
|
||||||
|
// Only return if the guidance scale doesn't exist or the value is 1
|
||||||
|
// Also don't return if constructing the neutral prompt
|
||||||
|
if (isNegative && (!cfgGuidanceScale || cfgGuidanceScale?.value === 1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let finalMesSend = [...mesSend];
|
let finalMesSend = [...mesSend];
|
||||||
let cfgPrompt = {};
|
let cfgPrompt = {};
|
||||||
if (cfgGuidanceScale && cfgGuidanceScale?.value !== 1) {
|
if (cfgGuidanceScale && cfgGuidanceScale?.value !== 1) {
|
||||||
@ -2754,7 +2760,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
? cfgPrompt.value
|
? cfgPrompt.value
|
||||||
: ` ${cfgPrompt.value}`;
|
: ` ${cfgPrompt.value}`;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Switch from splice method to insertion depth method
|
// TODO: Make all extension prompts use an array/splice method
|
||||||
finalMesSend.splice(mesSend.length - cfgPrompt.depth, 0, `${cfgPrompt.value}\n`);
|
finalMesSend.splice(mesSend.length - cfgPrompt.depth, 0, `${cfgPrompt.value}\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ jQuery(async () => {
|
|||||||
.filter(":checked")
|
.filter(":checked")
|
||||||
.map(function() { return parseInt($(this).val()) })
|
.map(function() { return parseInt($(this).val()) })
|
||||||
.get()
|
.get()
|
||||||
.filter((e) => e !== NaN) || [];
|
.filter((e) => !Number.isNaN(e)) || [];
|
||||||
|
|
||||||
chat_metadata[metadataKeys.prompt_combine] = values;
|
chat_metadata[metadataKeys.prompt_combine] = values;
|
||||||
saveMetadataDebounced();
|
saveMetadataDebounced();
|
||||||
|
@ -39,10 +39,12 @@ export function getGuidanceScale() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
if (extension_settings.cfg.global && extension_settings.cfg.global?.guidance_scale !== 1) {
|
||||||
type: cfgType.global,
|
return {
|
||||||
value: extension_settings.cfg.global.guidance_scale
|
type: cfgType.global,
|
||||||
};
|
value: extension_settings.cfg.global.guidance_scale
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the CFG prompt
|
// Gets the CFG prompt
|
||||||
|
@ -234,10 +234,6 @@ async function generateTextGenWithStreaming(generate_data, signal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTextGenGenerationData(finalPrompt, this_amount_gen, isImpersonate, cfgValues) {
|
export function getTextGenGenerationData(finalPrompt, this_amount_gen, isImpersonate, cfgValues) {
|
||||||
if (cfgValues?.guidanceScale?.value === 1) {
|
|
||||||
cfgValues = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'prompt': finalPrompt,
|
'prompt': finalPrompt,
|
||||||
'max_new_tokens': this_amount_gen,
|
'max_new_tokens': this_amount_gen,
|
||||||
|
Loading…
Reference in New Issue
Block a user