mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
CFG: Pass entire guidance object
If an API doesn't use the negative prompt from generate, allow the negative prompt to be refetched in the specific API. This requires the full guidance scale object instead of just the number. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@@ -2975,8 +2975,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
// Get the negative prompt first since it has the unmodified mesSend array
|
// Get the negative prompt first since it has the unmodified mesSend array
|
||||||
let negativePrompt = main_api == 'textgenerationwebui' ? getCombinedPrompt(true) : undefined;
|
let negativePrompt = main_api == 'textgenerationwebui' ? getCombinedPrompt(true) : undefined;
|
||||||
let finalPromt = getCombinedPrompt(false);
|
let finalPromt = getCombinedPrompt(false);
|
||||||
|
|
||||||
|
// Include the entire guidance scale object
|
||||||
const cfgValues = {
|
const cfgValues = {
|
||||||
guidanceScale: cfgGuidanceScale?.value,
|
guidanceScale: cfgGuidanceScale,
|
||||||
negativePrompt: negativePrompt
|
negativePrompt: negativePrompt
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -396,7 +396,7 @@ function getBadWordPermutations(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getNovelGenerationData(finalPrompt, this_settings, this_amount_gen, isImpersonate, cfgValues) {
|
export function getNovelGenerationData(finalPrompt, this_settings, this_amount_gen, isImpersonate, cfgValues) {
|
||||||
if (cfgValues.guidanceScale && cfgValues.guidanceScale !== 1) {
|
if (cfgValues.guidanceScale && cfgValues.guidanceScale?.value !== 1) {
|
||||||
cfgValues.negativePrompt = (getCfgPrompt(cfgValues.guidanceScale, true))?.value;
|
cfgValues.negativePrompt = (getCfgPrompt(cfgValues.guidanceScale, true))?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ export function getNovelGenerationData(finalPrompt, this_settings, this_amount_g
|
|||||||
"typical_p": parseFloat(nai_settings.typical_p),
|
"typical_p": parseFloat(nai_settings.typical_p),
|
||||||
"mirostat_lr": parseFloat(nai_settings.mirostat_lr),
|
"mirostat_lr": parseFloat(nai_settings.mirostat_lr),
|
||||||
"mirostat_tau": parseFloat(nai_settings.mirostat_tau),
|
"mirostat_tau": parseFloat(nai_settings.mirostat_tau),
|
||||||
"cfg_scale": cfgValues?.guidanceScale ?? parseFloat(nai_settings.cfg_scale),
|
"cfg_scale": cfgValues?.guidanceScale?.value ?? parseFloat(nai_settings.cfg_scale),
|
||||||
"cfg_uc": cfgValues?.negativePrompt ?? nai_settings.cfg_uc ?? "",
|
"cfg_uc": cfgValues?.negativePrompt ?? nai_settings.cfg_uc ?? "",
|
||||||
"phrase_rep_pen": nai_settings.phrase_rep_pen,
|
"phrase_rep_pen": nai_settings.phrase_rep_pen,
|
||||||
"stop_sequences": stopSequences,
|
"stop_sequences": stopSequences,
|
||||||
|
@@ -251,7 +251,7 @@ export function getTextGenGenerationData(finalPromt, this_amount_gen, isImperson
|
|||||||
'penalty_alpha': textgenerationwebui_settings.penalty_alpha,
|
'penalty_alpha': textgenerationwebui_settings.penalty_alpha,
|
||||||
'length_penalty': textgenerationwebui_settings.length_penalty,
|
'length_penalty': textgenerationwebui_settings.length_penalty,
|
||||||
'early_stopping': textgenerationwebui_settings.early_stopping,
|
'early_stopping': textgenerationwebui_settings.early_stopping,
|
||||||
'guidance_scale': isImpersonate ? 1 : cfgValues?.guidanceScale ?? textgenerationwebui_settings.guidance_scale ?? 1,
|
'guidance_scale': isImpersonate ? 1 : cfgValues?.guidanceScale?.value ?? textgenerationwebui_settings.guidance_scale ?? 1,
|
||||||
'negative_prompt': isImpersonate ? '' : cfgValues?.negativePrompt ?? textgenerationwebui_settings.negative_prompt ?? '',
|
'negative_prompt': isImpersonate ? '' : cfgValues?.negativePrompt ?? textgenerationwebui_settings.negative_prompt ?? '',
|
||||||
'seed': textgenerationwebui_settings.seed,
|
'seed': textgenerationwebui_settings.seed,
|
||||||
'add_bos_token': textgenerationwebui_settings.add_bos_token,
|
'add_bos_token': textgenerationwebui_settings.add_bos_token,
|
||||||
|
Reference in New Issue
Block a user