mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-25 00:10:11 +01:00
Add NAI preamble to start of chat buffer
This commit is contained in:
parent
14ef5d9a6b
commit
1d0f67c144
@ -807,6 +807,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="novel_api-settings">
|
||||
<div class="range-block">
|
||||
<div class="range-block-title openai_restorable">
|
||||
<span data-i18n="Preamble">Preamble</span>
|
||||
<div id="nai_preamble_restore" title="Restore default prompt" data-i18n="[title]Restore default prompt"
|
||||
class="right_menu_button">
|
||||
<div class="fa-solid fa-clock-rotate-left "></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toggle-description justifyLeft" data-i18n="Use style tags to improve the quality of the output">
|
||||
Use style tags to improve the quality of the output
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<textarea id="nai_preamble_textarea" class="text_pole textarea_compact" name="nai_preamble" rows="2"
|
||||
placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title" data-i18n="Top P">
|
||||
Top P
|
||||
|
@ -3142,7 +3142,15 @@ function parseTokenCounts(counts, thisPromptBits) {
|
||||
}
|
||||
|
||||
function adjustChatsSeparator(mesSendString) {
|
||||
if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) {
|
||||
if (main_api === 'novel') {
|
||||
let preamble = "\n***\n" + nai_settings.nai_preamble;
|
||||
if (!preamble.endsWith('\n')) {
|
||||
preamble += '\n';
|
||||
}
|
||||
mesSendString = preamble + mesSendString;
|
||||
}
|
||||
|
||||
else if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) {
|
||||
mesSendString = power_user.custom_chat_separator + '\n' + mesSendString;
|
||||
}
|
||||
|
||||
|
@ -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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user