Merge branch 'SillyTavern:staging' into staging

This commit is contained in:
pyrater 2023-08-03 19:06:04 +09:00 committed by GitHub
commit 0ad3c86e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 157 additions and 26 deletions

View File

@ -0,0 +1,19 @@
{
"order": [3, 4, 0],
"temperature": 1.19,
"max_length": 300,
"min_length": 1,
"top_a": 0.116,
"tail_free_sampling": 0.958,
"repetition_penalty": 1.64,
"repetition_penalty_slope": 2.12,
"repetition_penalty_frequency": 0,
"repetition_penalty_presence": 0,
"repetition_penalty_range": 2048,
"use_cache": false,
"return_full_text": false,
"prefix": "vanilla",
"phrase_rep_pen": "medium",
"cfg_scale": 1.0,
"max_context": 7800
}

View File

@ -0,0 +1,19 @@
{
"order": [5, 0, 4],
"temperature": 1,
"max_length": 300,
"min_length": 1,
"top_a": 0.017,
"typical_p": 0.975,
"repetition_penalty": 3,
"repetition_penalty_slope": 0.09,
"repetition_penalty_frequency": 0,
"repetition_penalty_presence": 0,
"repetition_penalty_range": 7680,
"use_cache": false,
"return_full_text": false,
"prefix": "vanilla",
"phrase_rep_pen": "aggressive",
"cfg_scale": 1.0,
"max_context": 7800
}

View File

@ -1523,7 +1523,7 @@
"Continue": "이어서 계속",
"Editing:": "편집:",
"AI reply prefix": "AI 답변 접두사",
"Custom Stopping Strings": "문장출력 중단 문자열 (KoboldAI/TextGen)",
"Custom Stopping Strings": "문장출력 중단 문자열 (KoboldAI/TextGen/NovelAI)",
"JSON serialized array of strings": "JSON 연속 문자배열",
"words you dont want generated separated by comma ','": "답변에 포함을 막으려는 단어 (쉼표','로 구분)",
"Extensions URL": "확장기능 URL",

View File

@ -147,7 +147,7 @@
<i data-preset-manager-update="kobold" class="menu_button fa-solid fa-save" title="Update current preset" data-i18n="[title]Update current preset"></i>
<i data-preset-manager-new="kobold" class="menu_button fa-solid fa-plus" title="Create new preset" data-i18n="[title]Create new preset"></i>
<i data-preset-manager-import="kobold" class="menu_button fa-solid fa-upload" title="Import preset" data-i18n="[title]Import preset"></i>
<i data-preset-manager-export="kobold" class="menu_button fa-solid fa-download"title="Export preset" data-i18n="[title]Export preset"></i>
<i data-preset-manager-export="kobold" class="menu_button fa-solid fa-download" title="Export preset" data-i18n="[title]Export preset"></i>
<i data-preset-manager-delete="kobold" class="menu_button fa-solid fa-trash-can" title="Delete the preset" data-i18n="[title]Delete the preset"></i>
</div>
</div>
@ -187,7 +187,7 @@
<i data-preset-manager-update="textgenerationwebui" class="menu_button fa-solid fa-save" title="Update current preset" data-i18n="[title]Update current preset"></i>
<i data-preset-manager-new="textgenerationwebui" class="menu_button fa-solid fa-plus" title="Create new preset" data-i18n="[title]Create new preset"></i>
<i data-preset-manager-import="textgenerationwebui" class="menu_button fa-solid fa-upload" title="Import preset" data-i18n="[title]Import preset"></i>
<i data-preset-manager-export="textgenerationwebui" class="menu_button fa-solid fa-download"title="Export preset" data-i18n="[title]Export preset"></i>
<i data-preset-manager-export="textgenerationwebui" class="menu_button fa-solid fa-download" title="Export preset" data-i18n="[title]Export preset"></i>
<i data-preset-manager-delete="textgenerationwebui" class="menu_button fa-solid fa-trash-can" title="Delete the preset" data-i18n="[title]Delete the preset"></i>
</div>
</div>
@ -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
@ -1984,7 +2000,7 @@
</label>
<h4>
<span data-i18n="Custom Stopping Strings">
Custom Stopping Strings (KoboldAI/TextGen)
Custom Stopping Strings (KoboldAI/TextGen/NovelAI)
</span>
<div>
<small>
@ -2145,9 +2161,7 @@
Match whole words
</small>
</label>
<label title="Alert if your world info is greater than the allocated budget."
data-i18n="[title]Alert if your world info is greater than the allocated budget."
class="checkbox_label">
<label title="Alert if your world info is greater than the allocated budget." data-i18n="[title]Alert if your world info is greater than the allocated budget." class="checkbox_label">
<input id="world_info_overflow_alert" type="checkbox" />
<small data-i18n="Alert On Overflow">
Alert On Overflow
@ -3782,11 +3796,11 @@
<!-- popups live outside sheld to avoid blur conflicts -->
<div id="options" class="font-family-reset" style="display: none;">
<div class="options-content">
<a id="option_close_chat">
<a id="option_close_chat" class="displayNone">
<i class="fa-lg fa-solid fa-times"></i>
<span data-i18n="Close chat">Close chat</span>
</a>
<a id="option_settings">
<a id="option_settings" class="displayNone">
<i class="fa-lg fa-solid fa-cog"></i>
<span data-i18n="Toggle Panels">Toggle Panels</span>
</a>

View File

@ -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;
}
@ -6954,6 +6962,10 @@ function doCharListDisplaySwitch() {
updateVisibleDivs('#rm_print_characters_block', true);
}
function doCloseChat() {
$("#option_close_chat").trigger('click')
}
/**
* Function to handle the deletion of a character, given a specific popup type and character ID.
* If popup type equals "del_ch", it will proceed with deletion otherwise it will exit the function.
@ -7020,6 +7032,10 @@ export async function deleteCharacter(name, avatar) {
saveSettingsDebounced();
}
function doTogglePanels() {
$("#option_settings").trigger('click')
}
$(document).ready(function () {
@ -7034,6 +7050,9 @@ $(document).ready(function () {
registerSlashCommand('api', connectAPISlash, [], "(kobold, horde, novel, ooba, oai, claude, windowai) connect to an API", true, true);
registerSlashCommand('impersonate', doImpersonate, ['imp'], "- calls an impersonation response", true, true);
registerSlashCommand('delchat', doDeleteChat, [], "- deletes the current chat", true, true);
registerSlashCommand('closechat', doCloseChat, [], "- closes the current chat", true, true);
registerSlashCommand('panels', doTogglePanels, ['togglepanels'], "- toggle UI panels on/off", true, true);
setTimeout(function () {

View File

@ -987,6 +987,12 @@ $("document").ready(function () {
Generate();
}
}
if ($(':focus').attr('id') === 'dialogue_popup_input' && !isMobile()) {
if (!event.shiftKey && !event.ctrlKey && event.key == "Enter") {
event.preventDefault();
$('#dialogue_popup_ok').trigger('click');
}
}
//ctrl+shift+up to scroll to context line
if (event.shiftKey && event.ctrlKey && event.key == "ArrowUp") {
event.preventDefault();
@ -1134,5 +1140,11 @@ $("document").ready(function () {
return
}
}
if (event.ctrlKey && /^[1-9]$/.test(event.key)) {
// Your code here
event.preventDefault();
console.log("Ctrl +" + event.key + " pressed!");
}
}
});

View File

@ -1,6 +1,7 @@
import { saveSettingsDebounced, callPopup, getRequestHeaders } from "../../../script.js";
import { getContext, extension_settings } from "../../extensions.js";
import { initScrollHeight, resetScrollHeight } from "../../utils.js";
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "../../slash-commands.js";
export { MODULE_NAME };
@ -256,7 +257,7 @@ async function applyQuickReplyPreset(name) {
const quickReplyPreset = presets.find(x => x.name == name);
if (!quickReplyPreset) {
console.log(`error, QR preset '${name}' not found`)
toastr.warning(`error, QR preset '${name}' not found. Confirm you are using proper case sensitivity!`)
return;
}
@ -268,9 +269,27 @@ async function applyQuickReplyPreset(name) {
moduleWorker();
$(`#quickReplyPresets option[value="${name}"]`).attr('selected', true);
console.debug('QR Preset applied: ' + name);
//loadMovingUIState()
}
async function doQRPresetSwitch(_, text) {
text = String(text)
applyQuickReplyPreset(text)
}
async function doQR(_, text) {
if (!text) {
toastr.warning('must specify which QR # to use')
return
}
text = Number(text)
//use scale starting with 0
//ex: user inputs "/qr 2" >> qr with data-index 1 (but 2nd item displayed) gets triggered
let QRnum = Number(text - 1)
if (QRnum <= 0) { QRnum = 0 }
const whichQR = $("#quickReplies").find(`[data-index='${QRnum}']`);
whichQR.trigger('click')
}
jQuery(async () => {
@ -326,5 +345,11 @@ jQuery(async () => {
await loadSettings('init');
addQuickReplyBar();
});
$(document).ready(() => {
registerSlashCommand('qr', doQR, [], "- requires number argument, activates the specified QuickReply", true, true);
registerSlashCommand('qrset', doQRPresetSwitch, [], "- arg: QuickReply Preset Name, swaps to that QR preset", true, true);
})

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);
}
@ -259,6 +264,13 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge
.map(t => getTextTokens(tokenizerType, t))
: undefined;
let useInstruct = false;
if (isNewModel) {
// NovelAI claims they scan backwards 1000 characters (not tokens!) to look for instruct brackets. That's really short.
const tail = finalPromt.slice(-1500);
useInstruct = tail.includes("}");
}
return {
"input": finalPromt,
"model": nai_settings.model_novel,
@ -286,7 +298,7 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge
"use_cache": false,
"use_string": true,
"return_full_text": false,
"prefix": isNewModel ? "special_instruct" : "vanilla",
"prefix": useInstruct ? "special_instruct" : (isNewModel ? "special_proseaugmenter" : "vanilla"),
"order": this_settings.order,
"streaming": nai_settings.streaming_novel,
};
@ -334,6 +346,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 () {