Add native presetable CFG scale for ooba

This commit is contained in:
Cohee 2023-08-14 13:06:20 +03:00
parent a0bfc67632
commit 32eb877fdb
2 changed files with 35 additions and 4 deletions

View File

@ -1229,6 +1229,33 @@
</div>
</div>
<hr>
<div class="range-block">
<h4 class="range-block-title justifyLeft" data-i18n="CFG Scale">
CFG Scale
</h4>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="guidance_scale_textgenerationwebui" name="volume" min="0.1" max="4" step="0.05">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="guidance_scale_textgenerationwebui" id="guidance_scale_counter_textgenerationwebui">
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="negative_prompt_textgenerationwebui" class="text_pole textarea_compact" name="negative_prompt" 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>
<h4 data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat (mode=1 is only for llama.cpp)</h4>
<div class="range-block">
<div class="range-block-title" data-i18n="Mirostat Mode">

View File

@ -50,6 +50,8 @@ const textgenerationwebui_settings = {
mirostat_mode: 0,
mirostat_tau: 5,
mirostat_eta: 0.1,
guidance_scale: 1,
negative_prompt: '',
};
export let textgenerationwebui_presets = [];
@ -83,6 +85,8 @@ const setting_names = [
"mirostat_mode",
"mirostat_tau",
"mirostat_eta",
"guidance_scale",
"negative_prompt",
];
function selectPreset(name) {
@ -154,7 +158,7 @@ $(document).ready(function () {
$(`#${i}_textgenerationwebui`).attr("x-setting-id", i);
$(document).on("input", `#${i}_textgenerationwebui`, function () {
const isCheckbox = $(this).attr('type') == 'checkbox';
const isText = $(this).attr('type') == 'text';
const isText = $(this).attr('type') == 'text' || $(this).is('textarea');
const id = $(this).attr("x-setting-id");
if (isCheckbox) {
@ -182,7 +186,7 @@ function setSettingByName(i, value, trigger) {
}
const isCheckbox = $(`#${i}_textgenerationwebui`).attr('type') == 'checkbox';
const isText = $(`#${i}_textgenerationwebui`).attr('type') == 'text';
const isText = $(`#${i}_textgenerationwebui`).attr('type') == 'text' || $(`#${i}_textgenerationwebui`).is('textarea');
if (isCheckbox) {
const val = Boolean(value);
$(`#${i}_textgenerationwebui`).prop('checked', val);
@ -251,8 +255,8 @@ export function getTextGenGenerationData(finalPromt, this_amount_gen, isImperson
'penalty_alpha': textgenerationwebui_settings.penalty_alpha,
'length_penalty': textgenerationwebui_settings.length_penalty,
'early_stopping': textgenerationwebui_settings.early_stopping,
'guidance_scale': cfgValues?.guidanceScale ?? 1,
'negative_prompt': cfgValues?.negativePrompt ?? '',
'guidance_scale': cfgValues?.guidanceScale ?? textgenerationwebui_settings.guidance_scale ?? 1,
'negative_prompt': cfgValues?.negativePrompt ?? textgenerationwebui_settings.negative_prompt ?? '',
'seed': textgenerationwebui_settings.seed,
'add_bos_token': textgenerationwebui_settings.add_bos_token,
'stopping_strings': getStoppingStrings(isImpersonate, false),