Add NAI preamble to start of chat buffer

This commit is contained in:
Mike Weldon
2023-08-02 18:22:06 -07:00
parent 14ef5d9a6b
commit 1d0f67c144
3 changed files with 41 additions and 1 deletions

View File

@ -13,6 +13,8 @@ export {
getNovelTier,
};
const default_preamble = "[ Style: chat, complex, sensory, visceral ]";
const nai_settings = {
temperature: 0.5,
repetition_penalty: 1,
@ -29,6 +31,7 @@ const nai_settings = {
model_novel: "euterpe-v2",
preset_settings_novel: "Classic-Euterpe",
streaming_novel: false,
nai_preamble: default_preamble,
};
const nai_tiers = {
@ -76,6 +79,7 @@ function loadNovelSettings(settings) {
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
$('#model_novel_select').val(nai_settings.model_novel);
if (settings.nai_preamble !== undefined) nai_settings.nai_preamble = settings.nai_preamble;
nai_settings.preset_settings_novel = settings.preset_settings_novel;
nai_settings.temperature = settings.temperature;
nai_settings.repetition_penalty = settings.repetition_penalty;
@ -157,6 +161,7 @@ function loadNovelSettingsUi(ui_settings) {
$("#phrase_rep_pen_counter_novel").text(getPhraseRepPenCounter(ui_settings.phrase_rep_pen));
$("#min_length_novel").val(ui_settings.min_length);
$("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0));
$('#nai_preamble_textarea').val(ui_settings.nai_preamble);
$("#streaming_novel").prop('checked', ui_settings.streaming_novel);
}
@ -334,6 +339,17 @@ export async function generateNovelWithStreaming(generate_data, signal) {
}
}
$("#nai_preamble_textarea").on('input', function () {
nai_settings.nai_preamble = $('#nai_preamble_textarea').val();
saveSettingsDebounced();
});
$("#nai_preamble_restore").on('click', function () {
nai_settings.nai_preamble = default_preamble;
$('#nai_preamble_textarea').val(nai_settings.nai_preamble);
saveSettingsDebounced();
});
$(document).ready(function () {
sliders.forEach(slider => {
$(document).on("input", slider.sliderId, function () {