Apply CFG extension for Novel
This commit is contained in:
parent
bd3933bcbf
commit
9b8d069e3b
|
@ -864,6 +864,34 @@
|
|||
<textarea id="nai_preamble_textarea" class="text_pole textarea_compact" name="nai_preamble" rows="2" placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title justifyLeft" data-i18n="CFG Scale">
|
||||
CFG Scale
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="cfg_scale_novel" name="volume" min="1" max="3" step="0.05">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="cfg_scale_novel" id="cfg_scale_counter_novel">
|
||||
select
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title justifyLeft">
|
||||
<span data-i18n="Negative Prompt">Negative Prompt</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<textarea id="nai_cfg_uc" class="text_pole textarea_compact" name="cfg_uc" rows="2" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<small class="margin-bot-10px" data-i18n="Used if CFG Scale is unset globally, per chat or character">
|
||||
Used if CFG Scale is unset globally, per chat or character
|
||||
</small>
|
||||
<hr>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title" data-i18n="Top P">
|
||||
Top P
|
||||
|
@ -969,21 +997,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title" data-i18n="CFG Scale">
|
||||
CFG Scale
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="cfg_scale_novel" name="volume" min="1" max="3" step="0.05">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="cfg_scale_novel" id="cfg_scale_counter_novel">
|
||||
select
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title" data-i18n="Phrase Repetition Penalty">
|
||||
Phrase Repetition Penalty
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
getStoppingStrings,
|
||||
getTextTokens
|
||||
} from "../script.js";
|
||||
import { getCfg } from "./extensions/cfg/util.js";
|
||||
import { tokenizers } from "./power-user.js";
|
||||
|
||||
export {
|
||||
|
@ -34,6 +35,7 @@ const nai_settings = {
|
|||
streaming_novel: false,
|
||||
nai_preamble: default_preamble,
|
||||
prefix: '',
|
||||
cfg_uc: '',
|
||||
};
|
||||
|
||||
const nai_tiers = {
|
||||
|
@ -95,6 +97,7 @@ function loadNovelPreset(preset) {
|
|||
nai_settings.mirostat_lr = preset.mirostat_lr;
|
||||
nai_settings.mirostat_tau = preset.mirostat_tau;
|
||||
nai_settings.prefix = preset.prefix;
|
||||
nai_settings.cfg_uc = preset.cfg_uc || '';
|
||||
loadNovelSettingsUi(nai_settings);
|
||||
}
|
||||
|
||||
|
@ -125,6 +128,7 @@ function loadNovelSettings(settings) {
|
|||
nai_settings.mirostat_tau = settings.mirostat_tau;
|
||||
nai_settings.streaming_novel = !!settings.streaming_novel;
|
||||
nai_settings.prefix = settings.prefix;
|
||||
nai_settings.cfg_uc = settings.cfg_uc || '';
|
||||
loadNovelSettingsUi(nai_settings);
|
||||
}
|
||||
|
||||
|
@ -198,6 +202,7 @@ function loadNovelSettingsUi(ui_settings) {
|
|||
$("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0));
|
||||
$('#nai_preamble_textarea').val(ui_settings.nai_preamble);
|
||||
$('#nai_prefix').val(ui_settings.prefix || "");
|
||||
$('#nai_cfg_uc').val(ui_settings.cfg_uc || "");
|
||||
|
||||
$("#streaming_novel").prop('checked', ui_settings.streaming_novel);
|
||||
}
|
||||
|
@ -305,6 +310,12 @@ const sliders = [
|
|||
format: (val) => `${val}`,
|
||||
setValue: (val) => { nai_settings.min_length = Number(val).toFixed(0); },
|
||||
},
|
||||
{
|
||||
sliderId: "#nai_cfg_uc",
|
||||
counterId: "#nai_cfg_uc_counter",
|
||||
format: (val) => val,
|
||||
setValue: (val) => { nai_settings.cfg_uc = val; },
|
||||
},
|
||||
];
|
||||
|
||||
export function getNovelGenerationData(finalPrompt, this_settings, this_amount_gen, isImpersonate) {
|
||||
|
@ -318,6 +329,7 @@ export function getNovelGenerationData(finalPrompt, this_settings, this_amount_g
|
|||
: undefined;
|
||||
|
||||
const prefix = nai_settings.prefix || autoSelectPrefix(finalPrompt);
|
||||
const cfgSettings = getCfg();
|
||||
|
||||
return {
|
||||
"input": finalPrompt,
|
||||
|
@ -339,8 +351,8 @@ export function getNovelGenerationData(finalPrompt, this_settings, this_amount_g
|
|||
"top_g": parseFloat(nai_settings.top_g),
|
||||
"mirostat_lr": parseFloat(nai_settings.mirostat_lr),
|
||||
"mirostat_tau": parseFloat(nai_settings.mirostat_tau),
|
||||
"cfg_scale": parseFloat(nai_settings.cfg_scale),
|
||||
"cfg_uc": "",
|
||||
"cfg_scale": cfgSettings?.guidanceScale ?? parseFloat(nai_settings.cfg_scale),
|
||||
"cfg_uc": cfgSettings?.negativePrompt ?? nai_settings.cfg_uc ?? "",
|
||||
"phrase_rep_pen": nai_settings.phrase_rep_pen,
|
||||
//"stop_sequences": {{187}},
|
||||
"stop_sequences": stopSequences,
|
||||
|
|
Loading…
Reference in New Issue