Merge branch 'SillyTavern:staging' into staging

This commit is contained in:
Tony Ribeiro 2023-08-12 14:36:23 +02:00 committed by GitHub
commit 1eb4dd9a4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 188 additions and 46 deletions

View File

@ -1,19 +1,20 @@
{ {
"order": [5, 0, 1, 3], "order": [5, 0, 1, 3, 7],
"temperature": 1.23, "temperature": 1.35,
"max_length": 300, "max_length": 300,
"min_length": 1, "min_length": 1,
"top_k": 200, "top_k": 225,
"typical_p": 0.966, "top_g": 8,
"tail_free_sampling": 0.982, "typical_p": 0.975,
"repetition_penalty": 1.74, "tail_free_sampling": 0.984,
"repetition_penalty_range": 4000, "repetition_penalty": 1.7,
"repetition_penalty_range": 3200,
"repetition_penalty_frequency": 0, "repetition_penalty_frequency": 0,
"repetition_penalty_presence": 0.02, "repetition_penalty_presence": 0.02,
"use_cache": false, "use_cache": false,
"return_full_text": false, "return_full_text": false,
"prefix": "vanilla", "prefix": "vanilla",
"cfg_scale": 1, "cfg_scale": 1,
"phrase_rep_pen": "aggressive", "phrase_rep_pen": "medium",
"max_context": 7800 "max_context": 7800
} }

View File

@ -3,7 +3,7 @@
"temperature": 1.35, "temperature": 1.35,
"max_length": 300, "max_length": 300,
"min_length": 1, "min_length": 1,
"top_k": 12, "top_k": 15,
"top_p": 0.85, "top_p": 0.85,
"top_a": 0.1, "top_a": 0.1,
"tail_free_sampling": 0.915, "tail_free_sampling": 0.915,

View File

@ -1,19 +1,20 @@
{ {
"order": [6, 1, 0, 5, 3], "order": [6, 0, 8, 5, 3],
"temperature": 1.25, "temperature": 1.5,
"max_length": 300, "max_length": 300,
"min_length": 1, "min_length": 1,
"top_k": 70, "typical_p": 0.95,
"typical_p": 0.9, "tail_free_sampling": 0.95,
"tail_free_sampling": 0.925, "mirostat_lr": 0.2,
"repetition_penalty": 2, "mirostat_tau": 5.5,
"repetition_penalty": 1,
"repetition_penalty_range": 1632, "repetition_penalty_range": 1632,
"repetition_penalty_frequency": 0, "repetition_penalty_frequency": 0,
"repetition_penalty_presence": 0, "repetition_penalty_presence": 0,
"use_cache": false, "use_cache": false,
"return_full_text": false, "return_full_text": false,
"prefix": "vanilla", "prefix": "vanilla",
"phrase_rep_pen": "aggressive", "phrase_rep_pen": "very_aggressive",
"cfg_scale": 1.825, "cfg_scale": 1.4,
"max_context": 7800 "max_context": 7800
} }

View File

@ -1,12 +1,13 @@
{ {
"order": [3, 4, 0], "order": [3, 4, 5, 0],
"temperature": 1.19, "temperature": 1.06,
"max_length": 300, "max_length": 300,
"min_length": 1, "min_length": 1,
"top_a": 0.116, "top_a": 0.146,
"tail_free_sampling": 0.958, "typical_p": 0.976,
"repetition_penalty": 1.64, "tail_free_sampling": 0.969,
"repetition_penalty_slope": 2.12, "repetition_penalty": 1.86,
"repetition_penalty_slope": 2.33,
"repetition_penalty_frequency": 0, "repetition_penalty_frequency": 0,
"repetition_penalty_presence": 0, "repetition_penalty_presence": 0,
"repetition_penalty_range": 2048, "repetition_penalty_range": 2048,

View File

@ -1,12 +1,14 @@
{ {
"order": [6, 1, 0, 5, 3, 2], "order": [8, 0, 5, 3, 2, 4],
"temperature": 1.5, "temperature": 1.5,
"max_length": 300, "max_length": 300,
"min_length": 1, "min_length": 1,
"top_k": 70, "top_a": 0.02,
"top_p": 0.95, "top_p": 0.95,
"typical_p": 0.95, "typical_p": 0.95,
"tail_free_sampling": 0.95, "tail_free_sampling": 0.95,
"mirostat_lr": 0.2,
"mirostat_tau": 5,
"repetition_penalty": 1.6, "repetition_penalty": 1.6,
"repetition_penalty_range": 2016, "repetition_penalty_range": 2016,
"repetition_penalty_frequency": 0, "repetition_penalty_frequency": 0,

View File

@ -555,7 +555,7 @@
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<input id="openai_proxy_password" type="text" class="text_pole" placeholder="" maxlength="200" /> <input id="openai_proxy_password" type="password" class="text_pole" placeholder="" maxlength="200" />
</div> </div>
</div> </div>
<div class="range-block" data-source="openai,claude"> <div class="range-block" data-source="openai,claude">
@ -838,8 +838,7 @@
<div class="range-block"> <div class="range-block">
<div class="range-block-title openai_restorable"> <div class="range-block-title openai_restorable">
<span data-i18n="Preamble">Preamble</span> <span data-i18n="Preamble">Preamble</span>
<div id="nai_preamble_restore" title="Restore default prompt" data-i18n="[title]Restore default prompt" <div id="nai_preamble_restore" title="Restore default prompt" data-i18n="[title]Restore default prompt" class="right_menu_button">
class="right_menu_button">
<div class="fa-solid fa-clock-rotate-left "></div> <div class="fa-solid fa-clock-rotate-left "></div>
</div> </div>
</div> </div>
@ -847,8 +846,7 @@
Use style tags to modify the writing style of the output Use style tags to modify the writing style of the output
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="nai_preamble_textarea" class="text_pole textarea_compact" name="nai_preamble" rows="2" <textarea id="nai_preamble_textarea" class="text_pole textarea_compact" name="nai_preamble" rows="2" placeholder=""></textarea>
placeholder=""></textarea>
</div> </div>
</div> </div>
<div class="range-block"> <div class="range-block">
@ -896,6 +894,51 @@
</div> </div>
</div> </div>
</div> </div>
<div class="range-block">
<div class="range-block-title" data-i18n="Top G">
Top G
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="top_g_novel" name="volume" min="0" max="20" step="1">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="top_g_novel" id="top_g_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Mirostat Tau">
Mirostat Tau
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="mirostat_tau_novel" name="volume" min="0" max="6" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="mirostat_tau_novel" id="mirostat_tau_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block">
<div class="range-block-title" data-i18n="Mirostat LR">
Mirostat LR
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="mirostat_lr_novel" name="volume" min="0" max="1" step="0.01">
</div>
<div class="range-block-counter">
<div contenteditable="true" data-for="mirostat_lr_novel" id="mirostat_lr_counter_novel">
select
</div>
</div>
</div>
</div>
<div class="range-block"> <div class="range-block">
<div class="range-block-title" data-i18n="Typical P"> <div class="range-block-title" data-i18n="Typical P">
Typical P Typical P
@ -2429,6 +2472,22 @@
</div> </div>
</div> </div>
</div> </div>
<div class="range-block">
<div class="range-block-title">
<span data-i18n="Lazy Chat Loading">Lazy Chat Loading</span><br>
<small># of messages (0 = disabled)</small>
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input id="lazy_load" class="wide100p" type="range" min="0" max="100" step="10" value="0">
<div class="slider_hint">
<span>0</span>
<span>50</span>
<span>100</span>
</div>
</div>
</div>
</div>
<div> <div>
<span data-i18n="Avatar Style">Avatar Style:</span><br> <span data-i18n="Avatar Style">Avatar Style:</span><br>
<label> <label>
@ -3860,7 +3919,8 @@
<div class="inline-drawer-content"> <div class="inline-drawer-content">
<small>Will be automatically added as the Author's Note for all new chats.</small> <small>Will be automatically added as the Author's Note for all new chats.</small>
<textarea id="extension_floating_default" class="text_pole" rows="8" maxlength="10000" placeholder="Example:&#10;[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea> <div class="extension_token_counter"> <textarea id="extension_floating_default" class="text_pole" rows="8" maxlength="10000" placeholder="Example:&#10;[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
<div class="extension_token_counter">
Tokens: <span id="extension_floating_default_token_counter">0</span> Tokens: <span id="extension_floating_default_token_counter">0</span>
</div> </div>
<div class="floating_prompt_radio_group"> <div class="floating_prompt_radio_group">
@ -4018,4 +4078,4 @@
</script> </script>
</body> </body>
</html> </html>

View File

@ -96,7 +96,7 @@ import {
import { import {
generateNovelWithStreaming, generateNovelWithStreaming,
getNovelGenerationData, getNovelGenerationData,
getNovelMaxContextTokens, getKayraMaxContextTokens,
getNovelTier, getNovelTier,
loadNovelPreset, loadNovelPreset,
loadNovelSettings, loadNovelSettings,
@ -1193,6 +1193,16 @@ function printMessages() {
chat.forEach(function (item, i, arr) { chat.forEach(function (item, i, arr) {
addOneMessage(item, { scroll: i === arr.length - 1 }); addOneMessage(item, { scroll: i === arr.length - 1 });
}); });
if (power_user.lazy_load > 0) {
const height = $('#chat').height();
const scrollHeight = $('#chat').prop('scrollHeight');
// Only hide if oveflowing the scroll
if (scrollHeight > height) {
$('#chat').children('.mes').slice(0, -power_user.lazy_load).hide();
}
}
} }
function clearChat() { function clearChat() {
@ -3170,20 +3180,19 @@ function getMaxContextSize() {
if (main_api == 'novel') { if (main_api == 'novel') {
this_max_context = Number(max_context); this_max_context = Number(max_context);
if (nai_settings.model_novel == 'krake-v2' || nai_settings.model_novel == 'euterpe-v2') { if (nai_settings.model_novel == 'krake-v2' || nai_settings.model_novel == 'euterpe-v2') {
// Krake and Euterpe have a max context of 2048
// Should be used with classic gpt tokenizer for best results
this_max_context = Math.min(max_context, 2048); this_max_context = Math.min(max_context, 2048);
} }
if (nai_settings.model_novel == 'clio-v1' || nai_settings.model_novel == 'kayra-v1') { if (nai_settings.model_novel == 'clio-v1') {
// Clio and Kayra have a max context of 8192
// Should be used with nerdstash / nerdstash_v2 tokenizer for best results
this_max_context = Math.min(max_context, 8192); this_max_context = Math.min(max_context, 8192);
} }
if (nai_settings.model_novel == 'kayra-v1') {
this_max_context = Math.min(max_context, 8192);
const subscriptionLimit = getNovelMaxContextTokens(); const subscriptionLimit = getKayraMaxContextTokens();
if (typeof subscriptionLimit === "number" && this_max_context > subscriptionLimit) { if (typeof subscriptionLimit === "number" && this_max_context > subscriptionLimit) {
this_max_context = subscriptionLimit; this_max_context = subscriptionLimit;
console.log(`NovelAI subscription limit reached. Max context size is now ${this_max_context}`); console.log(`NovelAI subscription limit reached. Max context size is now ${this_max_context}`);
}
} }
this_max_context = this_max_context - amount_gen; this_max_context = this_max_context - amount_gen;
@ -5473,7 +5482,7 @@ async function getStatusNovel() {
success: function (data) { success: function (data) {
if (data.error != true) { if (data.error != true) {
setNovelData(data); setNovelData(data);
online_status = `${getNovelTier(data.tier)} (${getNovelMaxContextTokens()} context tokens)`; online_status = `${getNovelTier(data.tier)}`;
} }
resultCheckStatusNovel(); resultCheckStatusNovel();
}, },
@ -7144,6 +7153,17 @@ $(document).ready(function () {
updateVisibleDivs('#rm_print_characters_block', true); updateVisibleDivs('#rm_print_characters_block', true);
}, 5)); }, 5));
$('#chat').on('scroll', async () => {
// if on the start of the chat and has hidden messages
if ($('#chat').scrollTop() === 0 && $('#chat').children('.mes').not(':visible').length > 0) {
// show next hidden messages
const prevHeight = $('#chat').prop('scrollHeight');
$('#chat').children('.mes').not(':visible').slice(-power_user.lazy_load).show();
const newHeight = $('#chat').prop('scrollHeight');
$('#chat').scrollTop(newHeight - prevHeight);
}
});
$("#chat").on('mousewheel touchstart', () => { $("#chat").on('mousewheel touchstart', () => {
scrollLock = true; scrollLock = true;
}); });

View File

@ -125,7 +125,7 @@ async function loadSettings() {
$('#chromadb_auto_adjust').prop('checked', extension_settings.chromadb.auto_adjust); $('#chromadb_auto_adjust').prop('checked', extension_settings.chromadb.auto_adjust);
$('#chromadb_freeze').prop('checked', extension_settings.chromadb.freeze); $('#chromadb_freeze').prop('checked', extension_settings.chromadb.freeze);
$('#chromadb_query_last_only').val(extension_settings.chromadb.query_last_only).trigger('input'); $('#chromadb_query_last_only').prop('checked', extension_settings.chromadb.query_last_only);
enableDisableSliders(); enableDisableSliders();
onStrategyChange(); onStrategyChange();
} }
@ -573,6 +573,11 @@ function getCharacterDataLength() {
* on the chat history and a specified maximum context length. * on the chat history and a specified maximum context length.
*/ */
function doAutoAdjust(chat, maxContext) { function doAutoAdjust(chat, maxContext) {
// Only valid for chat injections strategy
if (extension_settings.chromadb.recall_strategy !== 0) {
return;
}
console.debug('CHROMADB: Auto-adjusting sliders (messages: %o, maxContext: %o)', chat.length, maxContext); console.debug('CHROMADB: Auto-adjusting sliders (messages: %o, maxContext: %o)', chat.length, maxContext);
// Get mean message length // Get mean message length
const meanMessageLength = chat.reduce((acc, cur) => acc + (cur?.mes?.length ?? 0), 0) / chat.length; const meanMessageLength = chat.reduce((acc, cur) => acc + (cur?.mes?.length ?? 0), 0) / chat.length;

View File

@ -47,8 +47,17 @@ export function setNovelData(data) {
novel_data = data; novel_data = data;
} }
export function getNovelMaxContextTokens() { export function getKayraMaxContextTokens() {
return novel_data?.perks?.contextTokens; switch (novel_data?.tier) {
case 1:
return 3072;
case 2:
return 6144;
case 3:
return 8192;
}
return null;
} }
function getNovelTier(tier) { function getNovelTier(tier) {
@ -80,6 +89,9 @@ function loadNovelPreset(preset) {
nai_settings.min_length = preset.min_length; nai_settings.min_length = preset.min_length;
nai_settings.cfg_scale = preset.cfg_scale; nai_settings.cfg_scale = preset.cfg_scale;
nai_settings.phrase_rep_pen = preset.phrase_rep_pen; nai_settings.phrase_rep_pen = preset.phrase_rep_pen;
nai_settings.top_g = preset.top_g;
nai_settings.mirostat_lr = preset.mirostat_lr;
nai_settings.mirostat_tau = preset.mirostat_tau;
loadNovelSettingsUi(nai_settings); loadNovelSettingsUi(nai_settings);
} }
@ -105,6 +117,9 @@ function loadNovelSettings(settings) {
nai_settings.min_length = settings.min_length; nai_settings.min_length = settings.min_length;
nai_settings.phrase_rep_pen = settings.phrase_rep_pen; nai_settings.phrase_rep_pen = settings.phrase_rep_pen;
nai_settings.cfg_scale = settings.cfg_scale; nai_settings.cfg_scale = settings.cfg_scale;
nai_settings.top_g = settings.top_g;
nai_settings.mirostat_lr = settings.mirostat_lr;
nai_settings.mirostat_tau = settings.mirostat_tau;
nai_settings.streaming_novel = !!settings.streaming_novel; nai_settings.streaming_novel = !!settings.streaming_novel;
loadNovelSettingsUi(nai_settings); loadNovelSettingsUi(nai_settings);
} }
@ -169,6 +184,12 @@ function loadNovelSettingsUi(ui_settings) {
$("#cfg_scale_counter_novel").text(Number(ui_settings.cfg_scale).toFixed(2)); $("#cfg_scale_counter_novel").text(Number(ui_settings.cfg_scale).toFixed(2));
$("#phrase_rep_pen_novel").val(getPhraseRepPenCounter(ui_settings.phrase_rep_pen)); $("#phrase_rep_pen_novel").val(getPhraseRepPenCounter(ui_settings.phrase_rep_pen));
$("#phrase_rep_pen_counter_novel").text(getPhraseRepPenCounter(ui_settings.phrase_rep_pen)); $("#phrase_rep_pen_counter_novel").text(getPhraseRepPenCounter(ui_settings.phrase_rep_pen));
$("#top_g_novel").val(ui_settings.top_g);
$("#top_g_counter_novel").text(Number(ui_settings.top_g).toFixed(0));
$("#mirostat_lr_novel").val(ui_settings.mirostat_lr);
$("#mirostat_lr_counter_novel").text(Number(ui_settings.mirostat_lr).toFixed(2));
$("#mirostat_tau_novel").val(ui_settings.mirostat_tau);
$("#mirostat_tau_counter_novel").text(Number(ui_settings.mirostat_tau).toFixed(2));
$("#min_length_novel").val(ui_settings.min_length); $("#min_length_novel").val(ui_settings.min_length);
$("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0)); $("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0));
$('#nai_preamble_textarea').val(ui_settings.nai_preamble); $('#nai_preamble_textarea').val(ui_settings.nai_preamble);
@ -243,6 +264,24 @@ const sliders = [
format: (val) => Number(val).toFixed(2), format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.typical_p = Number(val).toFixed(2); }, setValue: (val) => { nai_settings.typical_p = Number(val).toFixed(2); },
}, },
{
sliderId: "#top_g_novel",
counterId: "#top_g_counter_novel",
format: (val) => Number(val).toFixed(0),
setValue: (val) => { nai_settings.top_g = Number(val).toFixed(0); },
},
{
sliderId: "#mirostat_tau_novel",
counterId: "#mirostat_tau_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.mirostat_tau = Number(val).toFixed(2); },
},
{
sliderId: "#mirostat_lr_novel",
counterId: "#mirostat_lr_counter_novel",
format: (val) => Number(val).toFixed(2),
setValue: (val) => { nai_settings.mirostat_lr = Number(val).toFixed(2); },
},
{ {
sliderId: "#cfg_scale_novel", sliderId: "#cfg_scale_novel",
counterId: "#cfg_scale_counter_novel", counterId: "#cfg_scale_counter_novel",
@ -298,6 +337,9 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge
"top_p": parseFloat(nai_settings.top_p), "top_p": parseFloat(nai_settings.top_p),
"top_k": parseInt(nai_settings.top_k), "top_k": parseInt(nai_settings.top_k),
"typical_p": parseFloat(nai_settings.typical_p), "typical_p": parseFloat(nai_settings.typical_p),
"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_scale": parseFloat(nai_settings.cfg_scale),
"cfg_uc": "", "cfg_uc": "",
"phrase_rep_pen": nai_settings.phrase_rep_pen, "phrase_rep_pen": nai_settings.phrase_rep_pen,

View File

@ -193,6 +193,7 @@ let power_user = {
custom_stopping_strings_macro: true, custom_stopping_strings_macro: true,
fuzzy_search: false, fuzzy_search: false,
encode_tags: false, encode_tags: false,
lazy_load: 0,
}; };
let themes = []; let themes = [];
@ -688,6 +689,7 @@ function loadPowerUserSettings(settings, data) {
$('#fuzzy_search_checkbox').prop("checked", power_user.fuzzy_search); $('#fuzzy_search_checkbox').prop("checked", power_user.fuzzy_search);
$('#persona_show_notifications').prop("checked", power_user.persona_show_notifications); $('#persona_show_notifications').prop("checked", power_user.persona_show_notifications);
$('#encode_tags').prop("checked", power_user.encode_tags); $('#encode_tags').prop("checked", power_user.encode_tags);
$('#lazy_load').val(Number(power_user.lazy_load));
$("#console_log_prompts").prop("checked", power_user.console_log_prompts); $("#console_log_prompts").prop("checked", power_user.console_log_prompts);
$('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown); $('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown);
@ -2040,6 +2042,11 @@ $(document).ready(() => {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#lazy_load').on('input', function () {
power_user.lazy_load = Number($(this).val());
saveSettingsDebounced();
});
$(window).on('focus', function () { $(window).on('focus', function () {
browser_has_focus = true; browser_has_focus = true;
}); });

View File

@ -1872,6 +1872,9 @@ app.post("/generate_novelai", jsonParser, async function (request, response_gene
"top_p": request.body.top_p, "top_p": request.body.top_p,
"top_k": request.body.top_k, "top_k": request.body.top_k,
"typical_p": request.body.typical_p, "typical_p": request.body.typical_p,
"top_g": request.body.top_g,
"mirostat_lr": request.body.mirostat_lr,
"mirostat_tau": request.body.mirostat_tau,
"cfg_scale": request.body.cfg_scale, "cfg_scale": request.body.cfg_scale,
"cfg_uc": request.body.cfg_uc, "cfg_uc": request.body.cfg_uc,
"phrase_rep_pen": request.body.phrase_rep_pen, "phrase_rep_pen": request.body.phrase_rep_pen,