Add Character note to char.card embeds

This commit is contained in:
Cohee 2023-10-04 22:13:56 +03:00
parent 368cba1149
commit f8b5fe8b1e
4 changed files with 75 additions and 18 deletions

View File

@ -6,6 +6,10 @@
color: var(--fullred); color: var(--fullred);
} }
.m-t-0 {
margin-top: 0;
}
.m-t-1 { .m-t-1 {
margin-top: 1em; margin-top: 1em;
} }

View File

@ -3744,6 +3744,28 @@
</div> </div>
</div> </div>
<div id="depth_prompt_div" class="flex-container">
<div class="flex1">
<h4>
<span data-i18n="Character's Note">
Character's Note
</span>
</h4>
<textarea id="depth_prompt_prompt" name="depth_prompt_prompt" class="text_pole" rows="2" maxlength="20000" autocomplete="off" form="form_create" placeholder="(Text to be inserted in-chat @ designated depth)"></textarea>
</div>
<div>
<h4>
<span data-i18n="@ Depth">
@ Depth
</span>
</h4>
<input id="depth_prompt_depth" name="depth_prompt_depth" class="text_pole widthUnset m-t-0" type="number" min="0" max="999" value="4" form="form_create" />
<div class="extension_token_counter">
Tokens: <span data-token-counter="depth_prompt_prompt" data-token-permanent="true">counting...</span>
</div>
</div>
</div>
<div id="talkativeness_div"> <div id="talkativeness_div">
<h4><span data-i18n="Talkativeness">Talkativeness</span></h4> <h4><span data-i18n="Talkativeness">Talkativeness</span></h4>
<h5 data-i18n="How often the character speaks in group chats!">How often the character speaks in &nbsp;<span class="warning">group chats!</span> <h5 data-i18n="How often the character speaks in group chats!">How often the character speaks in &nbsp;<span class="warning">group chats!</span>
@ -4423,7 +4445,14 @@
<hr class="sysHR"> <hr class="sysHR">
<div class="inline-drawer"> <div class="inline-drawer">
<div id="charaANBlockToggle" class="inline-drawer-toggle inline-drawer-header"> <div id="charaANBlockToggle" class="inline-drawer-toggle inline-drawer-header">
<b>Character Author's Note</b> <div class="flex-container flexFlowColumn">
<b data-i18n="Character Author's Note (Private)">
Character Author's Note (Private)
</b>
<small data-i18n="Won't be shared with the character card on export.">
Won't be shared with the character card on export.
</small>
</div>
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div> <div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div> </div>
<div class="inline-drawer-content"> <div class="inline-drawer-content">

View File

@ -594,6 +594,7 @@ function getCurrentChatId() {
} }
const talkativeness_default = 0.5; const talkativeness_default = 0.5;
const depth_prompt_depth_default = 4;
var is_advanced_char_open = false; var is_advanced_char_open = false;
@ -616,7 +617,9 @@ let create_save = {
mes_example: "", mes_example: "",
world: "", world: "",
talkativeness: talkativeness_default, talkativeness: talkativeness_default,
alternate_greetings: [] alternate_greetings: [],
depth_prompt_prompt: '',
depth_prompt_depth: depth_prompt_depth_default,
}; };
//animation right menu //animation right menu
@ -2475,6 +2478,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
systemPrompt = formatInstructModeSystemPrompt(substituteParams(systemPrompt, name1, name2, power_user.instruct.system_prompt)); systemPrompt = formatInstructModeSystemPrompt(substituteParams(systemPrompt, name1, name2, power_user.instruct.system_prompt));
} }
// Depth prompt (character-specific A/N)
const depthPromptText = baseChatReplace(characters[this_chid].data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2) || '';
const depthPromptDepth = characters[this_chid].data?.extensions?.depth_prompt?.depth ?? depth_prompt_depth_default;
setExtensionPrompt('DEPTH_PROMPT', depthPromptText, extension_prompt_types.IN_CHAT, depthPromptDepth);
// Parse example messages // Parse example messages
if (!mesExamples.startsWith('<START>')) { if (!mesExamples.startsWith('<START>')) {
mesExamples = '<START>\n' + mesExamples.trim(); mesExamples = '<START>\n' + mesExamples.trim();
@ -5554,6 +5562,8 @@ export function select_selected_character(chid) {
$("#personality_textarea").val(characters[chid].personality); $("#personality_textarea").val(characters[chid].personality);
$("#firstmessage_textarea").val(characters[chid].first_mes); $("#firstmessage_textarea").val(characters[chid].first_mes);
$("#scenario_pole").val(characters[chid].scenario); $("#scenario_pole").val(characters[chid].scenario);
$("#depth_prompt_prompt").val(characters[chid].data?.extensions?.depth_prompt?.prompt ?? '');
$("#depth_prompt_depth").val(characters[chid].data?.extensions?.depth_prompt?.depth ?? depth_prompt_depth_default);
$("#talkativeness_slider").val(characters[chid].talkativeness || talkativeness_default); $("#talkativeness_slider").val(characters[chid].talkativeness || talkativeness_default);
$("#mes_example_textarea").val(characters[chid].mes_example); $("#mes_example_textarea").val(characters[chid].mes_example);
$("#selected_chat_pole").val(characters[chid].chat); $("#selected_chat_pole").val(characters[chid].chat);
@ -5621,6 +5631,8 @@ function select_rm_create() {
$("#firstmessage_textarea").val(create_save.first_message); $("#firstmessage_textarea").val(create_save.first_message);
$("#talkativeness_slider").val(create_save.talkativeness); $("#talkativeness_slider").val(create_save.talkativeness);
$("#scenario_pole").val(create_save.scenario); $("#scenario_pole").val(create_save.scenario);
$("#depth_prompt_prompt").val(create_save.depth_prompt_prompt);
$("#depth_prompt_depth").val(create_save.depth_prompt_depth);
$("#mes_example_textarea").val(create_save.mes_example.trim().length === 0 ? '<START>' : create_save.mes_example); $("#mes_example_textarea").val(create_save.mes_example.trim().length === 0 ? '<START>' : create_save.mes_example);
$('#character_json_data').val(''); $('#character_json_data').val('');
$("#avatar_div").css("display", "flex"); $("#avatar_div").css("display", "flex");
@ -6273,6 +6285,8 @@ async function createOrEditCharacter(e) {
{ id: '#firstmessage_textarea', callback: value => create_save.first_message = value }, { id: '#firstmessage_textarea', callback: value => create_save.first_message = value },
{ id: '#talkativeness_slider', callback: value => create_save.talkativeness = value, defaultValue: talkativeness_default }, { id: '#talkativeness_slider', callback: value => create_save.talkativeness = value, defaultValue: talkativeness_default },
{ id: '#scenario_pole', callback: value => create_save.scenario = value }, { id: '#scenario_pole', callback: value => create_save.scenario = value },
{ id: '#depth_prompt_prompt', callback: value => create_save.depth_prompt_prompt = value },
{ id: '#depth_prompt_depth', callback: value => create_save.depth_prompt_depth = value, defaultValue: depth_prompt_depth_default },
{ id: '#mes_example_textarea', callback: value => create_save.mes_example = value }, { id: '#mes_example_textarea', callback: value => create_save.mes_example = value },
{ id: '#character_json_data', callback: () => { } }, { id: '#character_json_data', callback: () => { } },
{ id: '#alternate_greetings_template', callback: value => create_save.alternate_greetings = value, defaultValue: [] }, { id: '#alternate_greetings_template', callback: value => create_save.alternate_greetings = value, defaultValue: [] },
@ -7444,23 +7458,25 @@ jQuery(async function () {
$("#character_name_pole").on("input", function () { $("#character_name_pole").on("input", function () {
if (menu_type == "create") { if (menu_type == "create") {
create_save.name = $("#character_name_pole").val(); create_save.name = String($("#character_name_pole").val());
} }
}); });
const elementsToUpdate = { const elementsToUpdate = {
'#description_textarea': function () { create_save.description = $("#description_textarea").val(); }, '#description_textarea': function () { create_save.description = String($("#description_textarea").val()); },
'#creator_notes_textarea': function () { create_save.creator_notes = $("#creator_notes_textarea").val(); }, '#creator_notes_textarea': function () { create_save.creator_notes = String($("#creator_notes_textarea").val()); },
'#character_version_textarea': function () { create_save.character_version = $("#character_version_textarea").val(); }, '#character_version_textarea': function () { create_save.character_version = String($("#character_version_textarea").val()); },
'#system_prompt_textarea': function () { create_save.system_prompt = $("#system_prompt_textarea").val(); }, '#system_prompt_textarea': function () { create_save.system_prompt = String($("#system_prompt_textarea").val()); },
'#post_history_instructions_textarea': function () { create_save.post_history_instructions = $("#post_history_instructions_textarea").val(); }, '#post_history_instructions_textarea': function () { create_save.post_history_instructions = String($("#post_history_instructions_textarea").val()); },
'#creator_textarea': function () { create_save.creator = $("#creator_textarea").val(); }, '#creator_textarea': function () { create_save.creator = String($("#creator_textarea").val()); },
'#tags_textarea': function () { create_save.tags = $("#tags_textarea").val(); }, '#tags_textarea': function () { create_save.tags = String($("#tags_textarea").val()); },
'#personality_textarea': function () { create_save.personality = $("#personality_textarea").val(); }, '#personality_textarea': function () { create_save.personality = String($("#personality_textarea").val()); },
'#scenario_pole': function () { create_save.scenario = $("#scenario_pole").val(); }, '#scenario_pole': function () { create_save.scenario = String($("#scenario_pole").val()); },
'#mes_example_textarea': function () { create_save.mes_example = $("#mes_example_textarea").val(); }, '#mes_example_textarea': function () { create_save.mes_example = String($("#mes_example_textarea").val()); },
'#firstmessage_textarea': function () { create_save.first_message = $("#firstmessage_textarea").val(); }, '#firstmessage_textarea': function () { create_save.first_message = String($("#firstmessage_textarea").val()); },
'#talkativeness_slider': function () { create_save.talkativeness = $("#talkativeness_slider").val(); }, '#talkativeness_slider': function () { create_save.talkativeness = Number($("#talkativeness_slider").val()); },
'#depth_prompt_prompt': function () { create_save.depth_prompt_prompt = String($("#depth_prompt_prompt").val()); },
'#depth_prompt_depth': function () { create_save.depth_prompt_depth = Number($("#depth_prompt_depth").val()); },
}; };
Object.keys(elementsToUpdate).forEach(function (id) { Object.keys(elementsToUpdate).forEach(function (id) {

View File

@ -828,6 +828,8 @@ function convertToV2(char) {
fav: char.fav, fav: char.fav,
creator: char.creator, creator: char.creator,
tags: char.tags, tags: char.tags,
depth_prompt_prompt: char.depth_prompt_prompt,
depth_prompt_response: char.depth_prompt_response,
}); });
result.chat = char.chat ?? humanizedISO8601DateTime(); result.chat = char.chat ?? humanizedISO8601DateTime();
@ -943,6 +945,12 @@ function charaFormatData(data) {
_.set(char, 'data.extensions.talkativeness', data.talkativeness); _.set(char, 'data.extensions.talkativeness', data.talkativeness);
_.set(char, 'data.extensions.fav', data.fav == 'true'); _.set(char, 'data.extensions.fav', data.fav == 'true');
_.set(char, 'data.extensions.world', data.world || ''); _.set(char, 'data.extensions.world', data.world || '');
// Spec extension: depth prompt
const depth_default = 4;
const depth_value = !isNaN(Number(data.depth_prompt_depth)) ? Number(data.depth_prompt_depth) : depth_default;
_.set(char, 'data.extensions.depth_prompt.prompt', data.depth_prompt_prompt ?? '');
_.set(char, 'data.extensions.depth_prompt.depth', depth_value);
//_.set(char, 'data.extensions.create_date', humanizedISO8601DateTime()); //_.set(char, 'data.extensions.create_date', humanizedISO8601DateTime());
//_.set(char, 'data.extensions.avatar', 'none'); //_.set(char, 'data.extensions.avatar', 'none');
//_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime()); //_.set(char, 'data.extensions.chat', data.ch_name + ' - ' + humanizedISO8601DateTime());