mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Set scenario override for characters
This commit is contained in:
@ -2364,7 +2364,7 @@
|
|||||||
<input id="character_name_pole" name="ch_name" class="text_pole" placeholder="Name this character" maxlength="50" value="" autocomplete="off">
|
<input id="character_name_pole" name="ch_name" class="text_pole" placeholder="Name this character" maxlength="50" value="" autocomplete="off">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="avatar_div" class="avatar_div alignitemsflexstart justifySpaceBetween">
|
<div id="avatar_div" class="avatar_div alignitemsflexstart justifySpaceBetween flexnowrap flexGap5">
|
||||||
<div id="avatar_div_div" class="avatar">
|
<div id="avatar_div_div" class="avatar">
|
||||||
<img id="avatar_load_preview" src="img/ai4.png" alt="avatar">
|
<img id="avatar_load_preview" src="img/ai4.png" alt="avatar">
|
||||||
</div>
|
</div>
|
||||||
@ -2379,6 +2379,7 @@
|
|||||||
<input type="hidden" id="fav_checkbox" name="fav" />
|
<input type="hidden" id="fav_checkbox" name="fav" />
|
||||||
<div id="advanced_div" class="menu_button fa-solid fa-book " title="Advanced Definitions"></div>
|
<div id="advanced_div" class="menu_button fa-solid fa-book " title="Advanced Definitions"></div>
|
||||||
<div id="export_button" class="menu_button fa-solid fa-file-export " title="Export and Download"></div>
|
<div id="export_button" class="menu_button fa-solid fa-file-export " title="Export and Download"></div>
|
||||||
|
<div id="set_chat_scenario" class="menu_button fa-solid fa-scroll" title="Set a chat scenario override"></div>
|
||||||
<div id="dupe_button" class="menu_button fa-solid fa-clone " title="Duplicate Character"></div>
|
<div id="dupe_button" class="menu_button fa-solid fa-clone " title="Duplicate Character"></div>
|
||||||
<label for="create_button" id="create_button_label" class="menu_button fa-solid fa-user-check" title="Create Character">
|
<label for="create_button" id="create_button_label" class="menu_button fa-solid fa-user-check" title="Create Character">
|
||||||
<input type="submit" id="create_button" name="create_button">
|
<input type="submit" id="create_button" name="create_button">
|
||||||
@ -2764,19 +2765,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="group_scenario_template" class="template_element">
|
<div id="scenario_override_template" class="template_element">
|
||||||
<div class="group_scenario range-block flexFlowColumn flex-container">
|
<div class="scenario_override range-block flexFlowColumn flex-container">
|
||||||
<div class="range-block-title title_restorable">
|
<div class="range-block-title title_restorable">
|
||||||
<h3><span data-i18n="Group Chat Scenario Override">Group Chat Scenario Override</span></h3>
|
<h3><span data-i18n="Chat Scenario Override">Chat Scenario Override</span></h3>
|
||||||
<div title="Remove" class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
|
<div title="Remove" class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-counter justifyLeft flex-container flexFlowColumn">
|
<div class="range-block-counter justifyLeft flex-container flexFlowColumn">
|
||||||
<strong>Unique to this chat.</strong> All group members will use the following scenario text instead of
|
<strong>Unique to this chat.</strong>
|
||||||
what is specified in their character cards.
|
<span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span>
|
||||||
Bookmarks inherit the scenario from their parent, and can be changed individually after that.
|
<span data-character="true">The following scenario text will be used instead of the value set in the character card.</span>
|
||||||
|
Bookmarks inherit the scenario override from their parent, and can be changed individually after that.
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-range wide100p">
|
<div class="range-block-range wide100p">
|
||||||
<textarea class="wide100p group_chat_scenario" class="text_pole" rows="15" placeholder="Type here..."></textarea>
|
<textarea class="wide100p chat_scenario" class="text_pole" rows="15" placeholder="Type here..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -130,7 +130,7 @@ import {
|
|||||||
isDataURL,
|
isDataURL,
|
||||||
} from "./scripts/utils.js";
|
} from "./scripts/utils.js";
|
||||||
|
|
||||||
import { extension_settings, loadExtensionSettings, runGenerationInterceptors } from "./scripts/extensions.js";
|
import { extension_settings, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from "./scripts/extensions.js";
|
||||||
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "./scripts/slash-commands.js";
|
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "./scripts/slash-commands.js";
|
||||||
import {
|
import {
|
||||||
tag_map,
|
tag_map,
|
||||||
@ -4871,6 +4871,33 @@ function updateFavButtonState(state) {
|
|||||||
$("#favorite_button").toggleClass('fav_off', !fav_ch_checked);
|
$("#favorite_button").toggleClass('fav_off', !fav_ch_checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setScenarioOverride() {
|
||||||
|
if (!selected_group && !this_chid) {
|
||||||
|
console.warn('setScenarioOverride() -- no selected group or character');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const template = $('#scenario_override_template .scenario_override').clone();
|
||||||
|
const metadataValue = chat_metadata['scenario'] || '';
|
||||||
|
const isGroup = !!selected_group;
|
||||||
|
template.find('[data-group="true"]').toggle(isGroup);
|
||||||
|
template.find('[data-character="true"]').toggle(!isGroup);
|
||||||
|
template.find('.chat_scenario').text(metadataValue).on('input', onScenarioOverrideInput);
|
||||||
|
template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick);
|
||||||
|
callPopup(template, 'text');
|
||||||
|
}
|
||||||
|
|
||||||
|
function onScenarioOverrideInput() {
|
||||||
|
const value = $(this).val();
|
||||||
|
const metadata = { scenario: value, };
|
||||||
|
updateChatMetadata(metadata, false);
|
||||||
|
saveMetadataDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onScenarioOverrideRemoveClick() {
|
||||||
|
$(this).closest('.scenario_override').find('.chat_scenario').val('').trigger('input');
|
||||||
|
}
|
||||||
|
|
||||||
function callPopup(text, type, inputValue = '') {
|
function callPopup(text, type, inputValue = '') {
|
||||||
if (type) {
|
if (type) {
|
||||||
popup_type = type;
|
popup_type = type;
|
||||||
@ -6554,6 +6581,8 @@ $(document).ready(function () {
|
|||||||
if (!isMouseOverButtonOrMenu() && menu.is(':visible')) { hideMenu(); }
|
if (!isMouseOverButtonOrMenu() && menu.is(':visible')) { hideMenu(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#set_chat_scenario').on('click', setScenarioOverride);
|
||||||
|
|
||||||
///////////// OPTIMIZED LISTENERS FOR LEFT SIDE OPTIONS POPUP MENU //////////////////////
|
///////////// OPTIMIZED LISTENERS FOR LEFT SIDE OPTIONS POPUP MENU //////////////////////
|
||||||
|
|
||||||
$("#options [id]").on("click", function () {
|
$("#options [id]").on("click", function () {
|
||||||
|
@ -56,6 +56,7 @@ import {
|
|||||||
eventSource,
|
eventSource,
|
||||||
event_types,
|
event_types,
|
||||||
getCurrentChatId,
|
getCurrentChatId,
|
||||||
|
setScenarioOverride,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect, tag_map } from './tags.js';
|
import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect, tag_map } from './tags.js';
|
||||||
|
|
||||||
@ -1397,27 +1398,6 @@ export async function saveGroupBookmarkChat(groupId, name, metadata) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setGroupScenario() {
|
|
||||||
if (!selected_group) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const template = $('#group_scenario_template .group_scenario').clone();
|
|
||||||
const metadataValue = chat_metadata['scenario'] || '';
|
|
||||||
template.find('.group_chat_scenario').text(metadataValue);
|
|
||||||
callPopup(template.get(0).outerHTML, 'text');
|
|
||||||
}
|
|
||||||
|
|
||||||
function onGroupScenarioInput() {
|
|
||||||
const value = $(this).val();
|
|
||||||
const metadata = { scenario: value, };
|
|
||||||
updateChatMetadata(metadata, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onGroupScenarioRemoveClick() {
|
|
||||||
$(this).closest('.group_scenario').find('.group_chat_scenario').val('').trigger('input');
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSendTextareaInput() {
|
function onSendTextareaInput() {
|
||||||
if (is_group_automode_enabled) {
|
if (is_group_automode_enabled) {
|
||||||
// Wait for current automode generation to finish
|
// Wait for current automode generation to finish
|
||||||
@ -1437,12 +1417,10 @@ function stopAutoModeGeneration() {
|
|||||||
|
|
||||||
jQuery(() => {
|
jQuery(() => {
|
||||||
$(document).on("click", ".group_select", selectGroup);
|
$(document).on("click", ".group_select", selectGroup);
|
||||||
$(document).on("input", ".group_chat_scenario", onGroupScenarioInput);
|
|
||||||
$(document).on("click", ".remove_scenario_override", onGroupScenarioRemoveClick);
|
|
||||||
$("#rm_group_filter").on("input", filterGroupMembers);
|
$("#rm_group_filter").on("input", filterGroupMembers);
|
||||||
$("#group_fav_filter").on("click", toggleFilterByFavorites);
|
$("#group_fav_filter").on("click", toggleFilterByFavorites);
|
||||||
$("#rm_group_submit").on("click", createGroup);
|
$("#rm_group_submit").on("click", createGroup);
|
||||||
$("#rm_group_scenario").on("click", setGroupScenario);
|
$("#rm_group_scenario").on("click", setScenarioOverride);
|
||||||
$("#rm_group_automode").on("input", function () {
|
$("#rm_group_automode").on("input", function () {
|
||||||
const value = $(this).prop("checked");
|
const value = $(this).prop("checked");
|
||||||
is_group_automode_enabled = value;
|
is_group_automode_enabled = value;
|
||||||
|
@ -1590,6 +1590,7 @@ grammarly-extension {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
align-self: center !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#first_message_div {
|
#first_message_div {
|
||||||
|
Reference in New Issue
Block a user