Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging

This commit is contained in:
RossAscends 2023-08-03 21:17:36 +09:00
commit f892931d44
8 changed files with 83 additions and 60 deletions

View File

@ -291,6 +291,7 @@ SillyTavern 会将 API 密钥保存在目录中的 `secrets.json` 文件内。
* RossAscends' additions: AGPL v3 * RossAscends' additions: AGPL v3
* Portions of CncAnon's TavernAITurbo mod: Unknown license * Portions of CncAnon's TavernAITurbo mod: Unknown license
* kingbri's various commits and suggestions (https://github.com/bdashore3) * kingbri's various commits and suggestions (https://github.com/bdashore3)
* StefanDanielSchwarz's various commits and bug reports (https://github.com/StefanDanielSchwarz)
* Waifu mode inspired by the work of PepperTaco (https://github.com/peppertaco/Tavern/) * Waifu mode inspired by the work of PepperTaco (https://github.com/peppertaco/Tavern/)
* Thanks Pygmalion University for being awesome testers and suggesting cool features! * Thanks Pygmalion University for being awesome testers and suggesting cool features!
* Thanks oobabooga for compiling presets for TextGen * Thanks oobabooga for compiling presets for TextGen

1
.github/readme.md vendored
View File

@ -293,6 +293,7 @@ GNU Affero General Public License for more details.**
* RossAscends' additions: AGPL v3 * RossAscends' additions: AGPL v3
* Portions of CncAnon's TavernAITurbo mod: Unknown license * Portions of CncAnon's TavernAITurbo mod: Unknown license
* kingbri's various commits and suggestions (<https://github.com/bdashore3>) * kingbri's various commits and suggestions (<https://github.com/bdashore3>)
* StefanDanielSchwarz's various commits and bug reports (<https://github.com/StefanDanielSchwarz>)
* Waifu mode inspired by the work of PepperTaco (<https://github.com/peppertaco/Tavern/>) * Waifu mode inspired by the work of PepperTaco (<https://github.com/peppertaco/Tavern/>)
* Thanks Pygmalion University for being awesome testers and suggesting cool features! * Thanks Pygmalion University for being awesome testers and suggesting cool features!
* Thanks oobabooga for compiling presets for TextGen * Thanks oobabooga for compiling presets for TextGen

View File

@ -1,9 +1,9 @@
{ {
"genamt": 300, "genamt": 300,
"max_length": 4096, "max_length": 2048,
"temp": 0, "temp": 0,
"rep_pen": 1.1, "rep_pen": 1.1,
"rep_pen_range": 4096, "rep_pen_range": 2048,
"streaming_kobold": true, "streaming_kobold": true,
"top_p": 0, "top_p": 0,
"top_a": 0, "top_a": 0,

View File

@ -1,9 +1,9 @@
{ {
"genamt": 250, "genamt": 250,
"max_length": 4096, "max_length": 2048,
"temp": 0.65, "temp": 0.65,
"rep_pen": 1.18, "rep_pen": 1.18,
"rep_pen_range": 4096, "rep_pen_range": 2048,
"streaming_kobold": true, "streaming_kobold": true,
"top_p": 0.47, "top_p": 0.47,
"top_a": 0, "top_a": 0,

View File

@ -2639,6 +2639,14 @@
<option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option> <option value="3" data-i18n="Bottom of Author's Note">Bottom of Author's Note</option>
</select> </select>
</div> </div>
<div class="range-block">
<label for="persona_show_notifications" class="checkbox_label">
<input id="persona_show_notifications" type="checkbox" />
<span data-i18n="Show Notifications Show notifications on switching personas">
Show notifications on switching personas
</span>
</label>
</div>
</div> </div>
<div class="flex1"> <div class="flex1">
<h4 class="title_restorable"> <h4 class="title_restorable">

View File

@ -4554,7 +4554,9 @@ export function setUserName(value) {
name1 = default_user_name; name1 = default_user_name;
console.log(`User name changed to ${name1}`); console.log(`User name changed to ${name1}`);
$("#your_name").val(name1); $("#your_name").val(name1);
toastr.success(`Your messages will now be sent as ${name1}`, 'Current persona updated'); if (power_user.persona_show_notifications) {
toastr.success(`Your messages will now be sent as ${name1}`, 'Current persona updated');
}
saveSettings("change_name"); saveSettings("change_name");
} }
@ -4653,7 +4655,7 @@ function setUserAvatar() {
const personaName = power_user.personas[user_avatar]; const personaName = power_user.personas[user_avatar];
if (personaName && name1 !== personaName) { if (personaName && name1 !== personaName) {
const lockedPersona = chat_metadata['persona']; const lockedPersona = chat_metadata['persona'];
if (lockedPersona && lockedPersona !== user_avatar) { if (lockedPersona && lockedPersona !== user_avatar && power_user.persona_show_notifications) {
toastr.info( toastr.info(
`To permanently set "${personaName}" as the selected persona, unlock and relock it using the "Lock" button. Otherwise, the selection resets upon reloading the chat.`, `To permanently set "${personaName}" as the selected persona, unlock and relock it using the "Lock" button. Otherwise, the selection resets upon reloading the chat.`,
`This chat is locked to a different persona (${power_user.personas[lockedPersona]}).`, `This chat is locked to a different persona (${power_user.personas[lockedPersona]}).`,
@ -4760,7 +4762,9 @@ async function setDefaultPersona() {
} }
console.log(`Removing default persona ${avatarId}`); console.log(`Removing default persona ${avatarId}`);
toastr.info('This persona will no longer be used by default when you open a new chat.', `Default persona removed`); if (power_user.persona_show_notifications) {
toastr.info('This persona will no longer be used by default when you open a new chat.', `Default persona removed`);
}
delete power_user.default_persona; delete power_user.default_persona;
} else { } else {
const confirm = await callPopup(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3> const confirm = await callPopup(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3>
@ -4772,7 +4776,9 @@ async function setDefaultPersona() {
} }
power_user.default_persona = avatarId; power_user.default_persona = avatarId;
toastr.success('This persona will be used by default when you open a new chat.', `Default persona set to ${personaName}`); if (power_user.persona_show_notifications) {
toastr.success('This persona will be used by default when you open a new chat.', `Default persona set to ${personaName}`);
}
} }
saveSettingsDebounced(); saveSettingsDebounced();
@ -4835,18 +4841,22 @@ function lockUserNameToChat() {
console.log(`Unlocking persona for this chat ${chat_metadata['persona']}`); console.log(`Unlocking persona for this chat ${chat_metadata['persona']}`);
delete chat_metadata['persona']; delete chat_metadata['persona'];
saveMetadata(); saveMetadata();
toastr.info('User persona is now unlocked for this chat. Click the "Lock" again to revert.', 'Persona unlocked'); if (power_user.persona_show_notifications) {
toastr.info('User persona is now unlocked for this chat. Click the "Lock" again to revert.', 'Persona unlocked');
}
updateUserLockIcon(); updateUserLockIcon();
return; return;
} }
if (!(user_avatar in power_user.personas)) { if (!(user_avatar in power_user.personas)) {
console.log(`Creating a new persona ${user_avatar}`); console.log(`Creating a new persona ${user_avatar}`);
toastr.info( if (power_user.persona_show_notifications) {
'Creating a new persona for currently selected user name and avatar...', toastr.info(
'Persona not set for this avatar', 'Creating a new persona for currently selected user name and avatar...',
{ timeOut: 10000, extendedTimeOut: 20000, }, 'Persona not set for this avatar',
); { timeOut: 10000, extendedTimeOut: 20000, },
);
}
power_user.personas[user_avatar] = name1; power_user.personas[user_avatar] = name1;
power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.BEFORE_CHAR }; power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.BEFORE_CHAR };
} }
@ -4855,7 +4865,9 @@ function lockUserNameToChat() {
saveMetadata(); saveMetadata();
saveSettingsDebounced(); saveSettingsDebounced();
console.log(`Locking persona for this chat ${user_avatar}`); console.log(`Locking persona for this chat ${user_avatar}`);
toastr.success(`User persona is locked to ${name1} in this chat`); if (power_user.persona_show_notifications) {
toastr.success(`User persona is locked to ${name1} in this chat`);
}
updateUserLockIcon(); updateUserLockIcon();
} }

View File

@ -45,7 +45,6 @@ let lastCharacter = undefined;
let lastMessage = null; let lastMessage = null;
let spriteCache = {}; let spriteCache = {};
let inApiCall = false; let inApiCall = false;
let live2d_var = false;
let previousSrc = null; let previousSrc = null;
@ -448,8 +447,7 @@ async function loadLiveChar() {
} }
} }
function handleImageChange() {
function handleImageChange(isChecked) {
const imgElement = document.querySelector('img#expression-image.expression'); const imgElement = document.querySelector('img#expression-image.expression');
if (!imgElement) { if (!imgElement) {
@ -457,31 +455,32 @@ function handleImageChange(isChecked) {
return; return;
} }
if (isChecked) { if (extension_settings.expressions.live2d) {
previousSrc = imgElement.src;
// Method get IP of endpoint // Method get IP of endpoint
if (imgElement.src !== getApiUrl() + '/api/live2d/result_feed') { const live2dResultFeedSrc = `${getApiUrl()}/api/live2d/result_feed`;
const expressionListItemElement = document.querySelector('#live2d'); $('#expression-holder').css({ display: '' });
const expressionImageElement = expressionListItemElement.querySelector('.expression_list_image'); if (imgElement.src !== live2dResultFeedSrc) {
const newSrc = expressionImageElement.src; const expressionImageElement = document.querySelector('.expression_list_image');
doExtrasFetch(newSrc, { if (expressionImageElement) {
method: 'HEAD', doExtrasFetch(expressionImageElement.src, {
}) method: 'HEAD',
.then(response => {
if (response.ok) {
imgElement.src = getApiUrl() + '/api/live2d/result_feed';
}
}) })
.catch(error => { .then(response => {
console.error(error); // Log the error if necessary if (response.ok) {
}); imgElement.src = live2dResultFeedSrc;
} else if (previousSrc) { }
imgElement.src = previousSrc; // Revert the src to its previous value })
.catch(error => {
console.error(error); // Log the error if necessary
});
}
} }
} else if (previousSrc !== null) { } else {
imgElement.src = previousSrc; // Revert the src to its previous value imgElement.src = ""; //remove incase char doesnt have expressions
setExpression(getContext().name2, FALLBACK_EXPRESSION, true);
} }
live2d_var = isChecked;
} }
async function moduleWorker() { async function moduleWorker() {
@ -497,22 +496,16 @@ async function moduleWorker() {
if (context.groupId !== lastCharacter && context.characterId !== lastCharacter) { if (context.groupId !== lastCharacter && context.characterId !== lastCharacter) {
removeExpression(); removeExpression();
spriteCache = {}; spriteCache = {};
previousSrc = null; previousSrc = null;
//uncheck live image
let checkbox = document.getElementById('image_type_toggle');
if (checkbox.checked) {
checkbox.click();
}
//clear expression //clear expression
let imgElement = document.getElementById('expression-image'); let imgElement = document.getElementById('expression-image');
imgElement.src = ""; imgElement.src = "";
//Load new char //set checkbox to global var
if (live2d_var) { $('#image_type_toggle').prop('checked', extension_settings.expressions.live2d);
loadLiveChar(); if(extension_settings.expressions.live2d == true){
setLive2dState(extension_settings.expressions.live2d);
} }
} }
@ -618,6 +611,14 @@ async function moduleWorker() {
} }
} }
function setLive2dState(switch_var){
extension_settings.expressions.live2d = switch_var; // Store setting
saveSettingsDebounced();
if (extension_settings.expressions.live2d) { loadLiveChar(); } // load char as needed
handleImageChange(switch_var); // Change image as needed
}
function getSpriteFolderName(message) { function getSpriteFolderName(message) {
const context = getContext(); const context = getContext();
let avatarPath = ''; let avatarPath = '';
@ -805,7 +806,7 @@ async function getExpressionsList() {
} }
async function setExpression(character, expression, force) { async function setExpression(character, expression, force) {
if (live2d_var == false) { if (extension_settings.expressions.live2d == false) {
console.debug('entered setExpressions'); console.debug('entered setExpressions');
await validateImages(character); await validateImages(character);
@ -915,7 +916,7 @@ async function setExpression(character, expression, force) {
} }
document.getElementById("expression-holder").style.display = ''; document.getElementById("expression-holder").style.display = '';
if (live2d_var == true) { } else {
// 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");
@ -923,7 +924,6 @@ async function setExpression(character, expression, force) {
console.log("setting value"); console.log("setting value");
imgElement.src = getApiUrl() + '/api/live2d/result_feed'; imgElement.src = getApiUrl() + '/api/live2d/result_feed';
} }
}
} }
} }
@ -1234,13 +1234,8 @@ function setExpressionOverrideHtml(forceClear = false) {
$(window).on("resize", updateVisualNovelModeDebounced); $(window).on("resize", updateVisualNovelModeDebounced);
$('.expression_settings').hide(); $('.expression_settings').hide();
$('#image_type_toggle').on('click', function () {
$('#image_type_toggle').on('change', function () { setLive2dState(this.checked);
const isChecked = this.checked;
if (isChecked) {
loadLiveChar();
}
handleImageChange(isChecked);
}); });
} }
@ -1253,7 +1248,6 @@ function setExpressionOverrideHtml(forceClear = false) {
moduleWorker(); moduleWorker();
dragElement($("#expression-holder")) dragElement($("#expression-holder"))
eventSource.on(event_types.CHAT_CHANGED, () => { eventSource.on(event_types.CHAT_CHANGED, () => {
//console.log("checked: " + live2d_var);
setExpressionOverrideHtml(); setExpressionOverrideHtml();
if (isVisualNovelMode()) { if (isVisualNovelMode()) {

View File

@ -27,7 +27,7 @@ import {
import { registerSlashCommand } from "./slash-commands.js"; import { registerSlashCommand } from "./slash-commands.js";
import { delay, debounce } from "./utils.js"; import { delay } from "./utils.js";
export { export {
loadPowerUserSettings, loadPowerUserSettings,
@ -184,6 +184,7 @@ let power_user = {
persona_description: '', persona_description: '',
persona_description_position: persona_description_positions.BEFORE_CHAR, persona_description_position: persona_description_positions.BEFORE_CHAR,
persona_show_notifications: true,
custom_stopping_strings: '', custom_stopping_strings: '',
fuzzy_search: false, fuzzy_search: false,
@ -678,6 +679,7 @@ function loadPowerUserSettings(settings, data) {
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold); $('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
$('#custom_stopping_strings').val(power_user.custom_stopping_strings); $('#custom_stopping_strings').val(power_user.custom_stopping_strings);
$('#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);
$("#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);
@ -1998,6 +2000,11 @@ $(document).ready(() => {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$('#persona_show_notifications').on('input', function () {
power_user.persona_show_notifications = !!$(this).prop('checked');
saveSettingsDebounced();
});
$(window).on('focus', function () { $(window).on('focus', function () {
browser_has_focus = true; browser_has_focus = true;
}); });