Add seed to Kobold APi

This commit is contained in:
Cohee 2023-10-26 21:22:00 +03:00
parent b29f63f89e
commit 24f406917d
4 changed files with 19 additions and 0 deletions

View File

@ -1091,6 +1091,14 @@
</div>
</div>
<hr>
<div class="range-block">
<div class="range-block-title" data-i18n="Seed">
Seed
</div>
<!-- Max value is 2**64 - 1 -->
<input type="number" id="seed_kobold" class="text_pole wide100p" min="-1" value="-1" max="18446744073709551615" />
</div>
<hr>
<div class="range-block flexFlowColumn">
<div class="range-block-title">
<span data-i18n="Samplers Order">Samplers Order</span>

View File

@ -28,6 +28,7 @@ export const kai_settings = {
mirostat_eta: 0.1,
use_default_badwordsids: false,
grammar: "",
seed: -1,
};
export const kai_flags = {
@ -136,6 +137,7 @@ export function getKoboldGenerationData(finalPrompt, settings, maxLength, maxCon
mirostat_eta: kai_flags.can_use_mirostat ? kai_settings.mirostat_eta : undefined,
use_default_badwordsids: kai_flags.can_use_default_badwordsids ? kai_settings.use_default_badwordsids : undefined,
grammar: kai_flags.can_use_grammar ? substituteParams(kai_settings.grammar) : undefined,
sampler_seed: kai_settings.seed >= 0 ? kai_settings.seed : undefined,
};
return generate_data;
}
@ -281,6 +283,13 @@ const sliders = [
format: (val) => val,
setValue: (val) => { kai_settings.grammar = val; },
},
{
name: "seed",
sliderId: "#seed_kobold",
counterId: "#seed_counter_kobold",
format: (val) => val,
setValue: (val) => { kai_settings.seed = Number(val); },
},
];
export function setKoboldFlags(version, koboldVersion) {

View File

@ -262,6 +262,7 @@ class PresetManager {
'model_novel',
'streaming_kobold',
"enabled",
'seed',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@ -401,6 +401,7 @@ app.post("/generate", jsonParser, async function (request, response_generate) {
mirostat_eta: request.body.mirostat_eta,
mirostat_tau: request.body.mirostat_tau,
grammar: request.body.grammar,
sampler_seed: request.body.sampler_seed,
};
if (!!request.body.stop_sequence) {
this_settings['stop_sequence'] = request.body.stop_sequence;