Merge pull request #913 from SillyTavern/staging

Staging
This commit is contained in:
Cohee 2023-08-10 12:50:02 +03:00 committed by GitHub
commit e4d1463a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 151 additions and 69 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "sillytavern", "name": "sillytavern",
"version": "1.9.6", "version": "1.9.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sillytavern", "name": "sillytavern",
"version": "1.9.6", "version": "1.9.7",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"@dqbd/tiktoken": "^1.0.2", "@dqbd/tiktoken": "^1.0.2",

View File

@ -50,7 +50,7 @@
"type": "git", "type": "git",
"url": "https://github.com/SillyTavern/SillyTavern.git" "url": "https://github.com/SillyTavern/SillyTavern.git"
}, },
"version": "1.9.6", "version": "1.9.7",
"scripts": { "scripts": {
"start": "node server.js", "start": "node server.js",
"start-multi": "node server.js --disableCsrf", "start-multi": "node server.js --disableCsrf",

View File

@ -787,21 +787,45 @@
</label> </label>
</div> </div>
<div class="range-block flexFlowColumn"> <div class="range-block flexFlowColumn">
<div class="range-block-title" data-i18n="Samplers Order"> <div class="range-block-title">
Samplers Order <span data-i18n="Samplers Order">Samplers Order</span>
</div> </div>
<div class="toggle-description" data-i18n="Samplers will be applied in a top-down order. Use with caution."> <div class="toggle-description" data-i18n="Samplers will be applied in a top-down order. Use with caution.">
Samplers will be applied in a top-down order. Samplers will be applied in a top-down order.
Use with caution. Use with caution.
</div> </div>
<div id="kobold_order"> <div id="kobold_order">
<div data-id="0" data-i18n="Top K">Top K</div> <div data-id="0">
<div data-id="1" data-i18n="Top A">Top A</div> <span data-i18n="Top K">Top K</span>
<div data-id="2" data-i18n="Top P">Top P</div> <small>0</small>
<div data-id="3" data-i18n="Tail Free Sampling">Tail Free Sampling</div> </div>
<div data-id="4" data-i18n="Typical Sampling">Typical Sampling</div> <div data-id="1">
<div data-id="5" data-i18n="Temperature">Temperature</div> <span data-i18n="Top A">Top A</span>
<div data-id="6" data-i18n="Repetition Penalty">Repetition Penalty</div> <small>1</small>
</div>
<div data-id="2">
<span data-i18n="Top P">Top P</span>
<small>2</small>
</div>
<div data-id="3">
<span data-i18n="Tail Free Sampling">Tail Free Sampling</span>
<small>3</small>
</div>
<div data-id="4">
<span data-i18n="Typical Sampling">Typical Sampling</span>
<small>4</small>
</div>
<div data-id="5">
<span data-i18n="Temperature">Temperature</span>
<small>5</small>
</div>
<div data-id="6">
<span data-i18n="Repetition Penalty">Repetition Penalty</span>
<small>6</small>
</div>
</div>
<div id="samplers_order_recommended" class="menu_button menu_button_icon">
<span data-i18n="Load koboldcpp order">Load koboldcpp order</span>
</div> </div>
</div> </div>
</div> </div>
@ -1750,6 +1774,9 @@
<select id="model_openrouter_select"> <select id="model_openrouter_select">
<option data-i18n="Connect to the API">-- Connect to the API --</option> <option data-i18n="Connect to the API">-- Connect to the API --</option>
</select> </select>
<small>
Max prompt cost: <span id="openrouter_max_prompt_cost">Unknown</span> <span id="openrouter_max_prompt_cost_currency">USD</span>
</small>
</div> </div>
<h4 data-i18n="OpenRouter API Key">OpenRouter API Key</h4> <h4 data-i18n="OpenRouter API Key">OpenRouter API Key</h4>
<div> <div>
@ -2479,11 +2506,11 @@
<div id="power-user-options-block" class="flex-container drawer33pWidth"> <div id="power-user-options-block" class="flex-container drawer33pWidth">
<div id="power-user-option-checkboxes"> <div id="power-user-option-checkboxes">
<h4 data-i18n="Power User Options">Power User Options</h4> <h4 data-i18n="Power User Options">Power User Options</h4>
<label for="swipes-checkbox"> <label class="checkbox_label" for="swipes-checkbox">
<input id="swipes-checkbox" type="checkbox" /> <input id="swipes-checkbox" type="checkbox" />
<span data-i18n="Swipes">Swipes</span> <span data-i18n="Swipes">Swipes</span>
</label> </label>
<label for="fuzzy_search_checkbox"> <label class="checkbox_label" for="fuzzy_search_checkbox">
<input id="fuzzy_search_checkbox" type="checkbox" /> <input id="fuzzy_search_checkbox" type="checkbox" />
<span data-i18n="Advanced Character Search">Advanced Character Search</span> <span data-i18n="Advanced Character Search">Advanced Character Search</span>
</label> </label>
@ -2501,13 +2528,15 @@
Press "Send" to continue Press "Send" to continue
</span> </span>
</label> </label>
<label for="auto-load-chat-checkbox"><input id="auto-load-chat-checkbox" type="checkbox" /> <label class="checkbox_label" for="auto-load-chat-checkbox">
<input id="auto-load-chat-checkbox" type="checkbox" />
<span data-i18n="Auto-load Last Chat">Auto-load Last Chat</span> <span data-i18n="Auto-load Last Chat">Auto-load Last Chat</span>
</label> </label>
<label for="auto_save_msg_edits"><input id="auto_save_msg_edits" type="checkbox" /> <label class="checkbox_label" for="auto_save_msg_edits">
<input id="auto_save_msg_edits" type="checkbox" />
<span data-i18n="Auto-save Message Edits">Auto-save Message Edits</span> <span data-i18n="Auto-save Message Edits">Auto-save Message Edits</span>
</label> </label>
<label for="auto_fix_generated_markdown"> <label class="checkbox_label" for="auto_fix_generated_markdown">
<input id="auto_fix_generated_markdown" type="checkbox" /> <input id="auto_fix_generated_markdown" type="checkbox" />
<span data-i18n="Auto-fix Markdown">Auto-fix Markdown</span> <span data-i18n="Auto-fix Markdown">Auto-fix Markdown</span>
</label> </label>
@ -2519,37 +2548,43 @@
<input id="allow_name1_display" type="checkbox" /> <input id="allow_name1_display" type="checkbox" />
<span data-i18n="Allow {{user}}: in bot messages">Show {{user}}: in responses</span> <span data-i18n="Allow {{user}}: in bot messages">Show {{user}}: in responses</span>
</label> </label>
<!-- <label class="checkbox_label" for="removeXML"> <label class="checkbox_label" for="encode_tags">
<input id="removeXML" type="checkbox" /> <input id="encode_tags" type="checkbox" />
<span data-i18n="Remove XML/HTML tags from responses">Remove &lt;tags&gt; from responses</span> <span data-i18n="Show tags in responses">Show &lt;tags&gt; in responses</span>
</label> --> </label>
<label for="console_log_prompts"> <label class="checkbox_label" for="console_log_prompts">
<input id="console_log_prompts" type="checkbox" /> <input id="console_log_prompts" type="checkbox" />
<span data-i18n="Log prompts to console">Log prompts to console</span> <span data-i18n="Log prompts to console">Log prompts to console</span>
</label> </label>
<label for="render_formulas"> <label class="checkbox_label" for="render_formulas">
<input id="render_formulas" type="checkbox" /> <input id="render_formulas" type="checkbox" />
<span data-i18n="Render Formulas">Render Formulas</span> <span data-i18n="Render Formulas">Render Formulas</span>
<a href="https://docs.sillytavern.app/usage/core-concepts/uicustomization/#formulas-rendering" class="notes-link" target="_blank"> <a href="https://docs.sillytavern.app/usage/core-concepts/uicustomization/#formulas-rendering" class="notes-link" target="_blank">
<span class="note-link-span">?</span> <span class="note-link-span">?</span>
</a> </a>
</label> </label>
<label for="never_resize_avatars"><input id="never_resize_avatars" type="checkbox" /> <label class="checkbox_label" for="never_resize_avatars">
<input id="never_resize_avatars" type="checkbox" />
<span data-i18n="Never resize avatars">Never resize avatars</span> <span data-i18n="Never resize avatars">Never resize avatars</span>
</label> </label>
<label for="show_card_avatar_urls"><input id="show_card_avatar_urls" type="checkbox" /> <label class="checkbox_label" for="show_card_avatar_urls">
<input id="show_card_avatar_urls" type="checkbox" />
<span data-i18n="Show avatar filenames">Show avatar filenames</span> <span data-i18n="Show avatar filenames">Show avatar filenames</span>
</label> </label>
<label for="import_card_tags"><input id="import_card_tags" type="checkbox" /> <label class="checkbox_label" for="import_card_tags">
<input id="import_card_tags" type="checkbox" />
<span data-i18n="Import Card Tags">Import Card Tags</span> <span data-i18n="Import Card Tags">Import Card Tags</span>
</label> </label>
<label for="confirm_message_delete"><input id="confirm_message_delete" type="checkbox" /> <label class="checkbox_label" for="confirm_message_delete">
<input id="confirm_message_delete" type="checkbox" />
<span data-i18n="Confirm message deletion">Confirm message deletion</span> <span data-i18n="Confirm message deletion">Confirm message deletion</span>
</label> </label>
<label for="spoiler_free_mode"><input id="spoiler_free_mode" type="checkbox" /> <label class="checkbox_label" for="spoiler_free_mode">
<input id="spoiler_free_mode" type="checkbox" />
<span data-i18n="Spoiler Free Mode">Spoiler Free Mode</span> <span data-i18n="Spoiler Free Mode">Spoiler Free Mode</span>
</label> </label>
<label for="relaxed_api_urls" title="Reduce the formatting requirements on API URLS"><input id="relaxed_api_urls" type="checkbox" /> <label class="checkbox_label" for="relaxed_api_urls" title="Reduce the formatting requirements on API URLS">
<input id="relaxed_api_urls" type="checkbox" />
<span data-i18n="Relaxed API URLS">Relaxed API URLS</span> <span data-i18n="Relaxed API URLS">Relaxed API URLS</span>
</label> </label>

View File

@ -1269,8 +1269,10 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
mes = fixMarkdown(mes); mes = fixMarkdown(mes);
} }
//if (this_chid != undefined && !isSystem) if (!isSystem && power_user.encode_tags) {
// mes = mes.replaceAll("<", "&lt;").replaceAll(">", "&gt;"); //for welcome message mes = mes.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}
if ((this_chid === undefined || this_chid === "invalid-safety-id") && !selected_group) { if ((this_chid === undefined || this_chid === "invalid-safety-id") && !selected_group) {
mes = mes mes = mes
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>") .replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
@ -2958,7 +2960,8 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
} }
//Formating //Formating
getMessage = cleanUpMessage(getMessage, isImpersonate, isContinue); const displayIncomplete = type == 'quiet';
getMessage = cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete);
let this_mes_is_name; let this_mes_is_name;
({ this_mes_is_name, getMessage } = extractNameFromMessage(getMessage, force_name2, isImpersonate)); ({ this_mes_is_name, getMessage } = extractNameFromMessage(getMessage, force_name2, isImpersonate));

View File

@ -515,7 +515,7 @@ async function moduleWorker() {
//set checkbox to global var //set checkbox to global var
$('#image_type_toggle').prop('checked', extension_settings.expressions.live2d); $('#image_type_toggle').prop('checked', extension_settings.expressions.live2d);
if(extension_settings.expressions.live2d == true){ if (extension_settings.expressions.live2d) {
setLive2dState(extension_settings.expressions.live2d); setLive2dState(extension_settings.expressions.live2d);
} }
} }
@ -641,11 +641,11 @@ async function live2dcheck() {
let live2dObj = spriteCache[spriteFolderName].find(obj => obj.label === 'live2d'); let live2dObj = spriteCache[spriteFolderName].find(obj => obj.label === 'live2d');
let live2dPath_f = live2dObj ? live2dObj.path : null; let live2dPath_f = live2dObj ? live2dObj.path : null;
if(live2dPath_f != null){ if (live2dPath_f != null) {
//console.log("live2dPath_f " + live2dPath_f); //console.log("live2dPath_f " + live2dPath_f);
return true; return true;
} else { } else {
//console.log("live2dPath_f is null"); //console.log("live2dPath_f is null");
unloadLiveChar(); unloadLiveChar();
return false; return false;
} }
@ -654,7 +654,7 @@ async function live2dcheck() {
} }
} }
function setLive2dState(switch_var){ function setLive2dState(switch_var) {
extension_settings.expressions.live2d = switch_var; // Store setting extension_settings.expressions.live2d = switch_var; // Store setting
saveSettingsDebounced(); saveSettingsDebounced();
@ -662,22 +662,18 @@ function setLive2dState(switch_var){
if (result) { if (result) {
//console.log("Live2d exists!"); //console.log("Live2d exists!");
if (extension_settings.expressions.live2d) { if (extension_settings.expressions.live2d) {
loadLiveChar(); loadLiveChar();
} else { } else {
unloadLiveChar(); unloadLiveChar();
} }
handleImageChange(switch_var); // Change image as needed handleImageChange(switch_var); // Change image as needed
} else { } else {
//console.log("Live2d does not exist."); //console.log("Live2d does not exist.");
} }
}); });
} }
function getSpriteFolderName(message) { function getSpriteFolderName(message) {
@ -867,8 +863,7 @@ async function getExpressionsList() {
} }
async function setExpression(character, expression, force) { async function setExpression(character, expression, force) {
if (extension_settings.expressions.live2d == false) { if (!extension_settings.expressions.live2d) {
console.debug('entered setExpressions'); console.debug('entered setExpressions');
await validateImages(character); await validateImages(character);
const img = $('img.expression'); const img = $('img.expression');
@ -961,10 +956,11 @@ async function setExpression(character, expression, force) {
setDefault(); setDefault();
} }
}); });
} else { }
if (extension_settings.expressions.showDefault) { }
setDefault(); else {
} if (extension_settings.expressions.showDefault) {
setDefault();
} }
} }
@ -982,14 +978,14 @@ async function setExpression(character, expression, force) {
live2dcheck().then(result => { live2dcheck().then(result => {
if (result) { if (result) {
// Find the <img> element with id="expression-image" and class="expression" // Find the <img> element with id="expression-image" and class="expression"
const imgElement = document.querySelector('img#expression-image.expression'); const imgElement = document.querySelector('img#expression-image.expression');
//console.log("searching"); //console.log("searching");
if (imgElement) { if (imgElement) {
//console.log("setting value"); //console.log("setting value");
imgElement.src = getApiUrl() + '/api/live2d/result_feed'; imgElement.src = getApiUrl() + '/api/live2d/result_feed';
} }
} else { } else {
//console.log("The fetch failed!"); //console.log("The fetch failed!");
} }
@ -1254,14 +1250,15 @@ function setExpressionOverrideHtml(forceClear = false) {
</div> </div>
<div class="inline-drawer-content"> <div class="inline-drawer-content">
<!-- Toggle button for aituber/static images --> <!-- Toggle button for aituber/static images -->
<div class="toggle_button"> <div class="toggle_button">
<label class="switch"> <label class="switch">
<input id="image_type_toggle" type="checkbox"> <input id="image_type_toggle" type="checkbox">
<span class="slider round"></span> <span class="slider round"></span>
<label for="image_type_toggle">Image Type - Live2d (extras)</label> <label for="image_type_toggle">Image Type - Live2d (extras)</label>
</div> </label>
<div class="offline_mode"> </div>
<div class="offline_mode">
<small>You are in offline mode. Click on the image below to set the expression.</small> <small>You are in offline mode. Click on the image below to set the expression.</small>
</div> </div>
<div class="flex-container flexnowrap"> <div class="flex-container flexnowrap">

View File

@ -35,6 +35,7 @@ const kai_settings = {
const MIN_STOP_SEQUENCE_VERSION = '1.2.2'; const MIN_STOP_SEQUENCE_VERSION = '1.2.2';
const MIN_STREAMING_KCPPVERSION = '1.30'; const MIN_STREAMING_KCPPVERSION = '1.30';
const KOBOLDCPP_ORDER = [6, 0, 1, 3, 4, 2, 5];
function formatKoboldUrl(value) { function formatKoboldUrl(value) {
try { try {
@ -143,7 +144,7 @@ export async function generateKoboldWithStreaming(generate_data, signal) {
if (done) { if (done) {
return; return;
} }
} }
} }
} }
@ -276,4 +277,10 @@ $(document).ready(function () {
saveSettingsDebounced(); saveSettingsDebounced();
}, },
}); });
$('#samplers_order_recommended').on('click', function () {
kai_settings.sampler_order = KOBOLDCPP_ORDER;
sortItemsByOrder(kai_settings.sampler_order);
saveSettingsDebounced();
});
}); });

View File

@ -692,8 +692,30 @@ function getChatCompletionModel() {
} }
} }
function calculateOpenRouterCost() {
if (oai_settings.chat_completion_source !== chat_completion_sources.OPENROUTER) {
return;
}
let cost = 'Unknown';
const model = model_list.find(x => x.id === oai_settings.openrouter_model);
if (model?.pricing) {
const completionCost = Number(model.pricing.completion);
const promptCost = Number(model.pricing.prompt);
const completionTokens = oai_settings.openai_max_tokens;
const promptTokens = (oai_settings.openai_max_context - completionTokens);
const totalCost = (completionCost * completionTokens) + (promptCost * promptTokens);
if (!isNaN(totalCost)) {
cost = totalCost.toFixed(2);
}
}
$('#openrouter_max_prompt_cost').text(cost);
}
function saveModelList(data) { function saveModelList(data) {
model_list = data.map((model) => ({ id: model.id, context_length: model.context_length })); model_list = data.map((model) => ({ id: model.id, context_length: model.context_length, pricing: model.pricing }));
model_list.sort((a, b) => a?.id && b?.id && a.id.localeCompare(b.id)); model_list.sort((a, b) => a?.id && b?.id && a.id.localeCompare(b.id));
if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) { if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) {
@ -1801,6 +1823,8 @@ async function onModelChange() {
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
} }
calculateOpenRouterCost();
} }
if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) { if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) {
@ -2038,11 +2062,13 @@ $(document).ready(function () {
$(document).on('input', '#openai_max_context', function () { $(document).on('input', '#openai_max_context', function () {
oai_settings.openai_max_context = parseInt($(this).val()); oai_settings.openai_max_context = parseInt($(this).val());
$('#openai_max_context_counter').text(`${$(this).val()}`); $('#openai_max_context_counter').text(`${$(this).val()}`);
calculateOpenRouterCost();
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$(document).on('input', '#openai_max_tokens', function () { $(document).on('input', '#openai_max_tokens', function () {
oai_settings.openai_max_tokens = parseInt($(this).val()); oai_settings.openai_max_tokens = parseInt($(this).val());
calculateOpenRouterCost();
saveSettingsDebounced(); saveSettingsDebounced();
}); });

View File

@ -192,6 +192,7 @@ let power_user = {
custom_stopping_strings: '', custom_stopping_strings: '',
custom_stopping_strings_macro: true, custom_stopping_strings_macro: true,
fuzzy_search: false, fuzzy_search: false,
encode_tags: false,
}; };
let themes = []; let themes = [];
@ -686,6 +687,7 @@ function loadPowerUserSettings(settings, data) {
$("#custom_stopping_strings_macro").prop("checked", power_user.custom_stopping_strings_macro); $("#custom_stopping_strings_macro").prop("checked", power_user.custom_stopping_strings_macro);
$('#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);
$("#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);
@ -2032,6 +2034,12 @@ $(document).ready(() => {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#encode_tags').on('input', async function () {
power_user.encode_tags = !!$(this).prop('checked');
await reloadCurrentChat();
saveSettingsDebounced();
});
$(window).on('focus', function () { $(window).on('focus', function () {
browser_has_focus = true; browser_has_focus = true;
}); });

View File

@ -222,6 +222,10 @@ table.responsiveTable {
font-weight: 500; font-weight: 500;
} }
.mes_text rp {
display: block;
}
.mes_text blockquote { .mes_text blockquote {
border-left: 3px solid var(--SmartThemeQuoteColor); border-left: 3px solid var(--SmartThemeQuoteColor);
padding-left: 10px; padding-left: 10px;
@ -2160,6 +2164,9 @@ grammarly-extension {
transition: background-color 200ms ease-in-out; transition: background-color 200ms ease-in-out;
position: relative; position: relative;
user-select: none; user-select: none;
display: flex;
align-items: center;
justify-content: space-between;
} }
#kobold_order>div:hover { #kobold_order>div:hover {
@ -2772,7 +2779,6 @@ input[type="range"]::-webkit-slider-thumb {
#power-user-option-checkboxes { #power-user-option-checkboxes {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
row-gap: 5px;
flex-grow: 1; flex-grow: 1;
} }