Add macro for charDepthPrompt

4df98b034185de05b15bfd6ae33a604c8f887549

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +32 -6Ignore whitespace
public/script.js+30 -5
@@ -2746,6 +2746,7 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
27462746 environment.mesExamplesRaw = fields.mesExamples || '';
27472747 environment.charVersion = fields.version || '';
27482748 environment.char_version = fields.version || '';
2749+ environment.charDepthPrompt = fields.charDepthPrompt || '';
27492750 }
27502751
27512752 // Must be substituted last so that they're replaced inside {{description}}
@@ -3097,10 +3098,30 @@ export function baseChatReplace(value, name1, name2) {
30973098
30983099/**
30993100 * Returns the character card fields for the current character.
3100- * @returns {{system: string, mesExamples: string, description: string, personality: string, persona: string, scenario: string, jailbreak: string, version: string}}
3101+ * @typedef {object} CharacterCardFields
3102+ * @property {string} system System prompt
3103+ * @property {string} mesExamples Message examples
3104+ * @property {string} description Description
3105+ * @property {string} personality Personality
3106+ * @property {string} persona Persona
3107+ * @property {string} scenario Scenario
3108+ * @property {string} jailbreak Jailbreak instructions
3109+ * @property {string} version Character version
3110+ * @property {string} charDepthPrompt Character depth note
3111+ * @returns {CharacterCardFields} Character card fields
31013112 */
31023113export function getCharacterCardFields() {
3103- const result = { system: '', mesExamples: '', description: '', personality: '', persona: '', scenario: '', jailbreak: '', version: '' };
3114+ const result = {
3115+ system: '',
3116+ mesExamples: '',
3117+ description: '',
3118+ personality: '',
3119+ persona: '',
3120+ scenario: '',
3121+ jailbreak: '',
3122+ version: '',
3123+ charDepthPrompt: '',
3124+ };
31043125 result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
31053126
31063127 const character = characters[this_chid];
@@ -3117,6 +3138,7 @@ export function getCharacterCardFields() {
31173138 result.system = power_user.prefer_character_prompt ? baseChatReplace(character.data?.system_prompt?.trim(), name1, name2) : '';
31183139 result.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(character.data?.post_history_instructions?.trim(), name1, name2) : '';
31193140 result.version = character.data?.character_version ?? '';
3141+ result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2);
31203142
31213143 if (selected_group) {
31223144 const groupCards = getGroupCharacterCards(selected_group, Number(this_chid));
@@ -3612,7 +3634,8 @@ export async function generateRaw(prompt, api, instructOverride, quietToLoud, sy
36123634 throw new Error(data.response);
36133635 }
36143636
3615- const message = cleanUpMessage(extractMessageFromData(data), false, false, true);
3637+ // format result, exclude user prompt bias
3638+ const message = cleanUpMessage(extractMessageFromData(data), false, false, true, null, false);
36163639
36173640 if (!message) {
36183641 throw new Error('No message generated');
@@ -3921,6 +3944,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
39213944 mesExamples,
39223945 system,
39233946 jailbreak,
3947+ charDepthPrompt,
39243948 } = getCharacterCardFields();
39253949
39263950 if (main_api !== 'openai') {
@@ -3943,7 +3967,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
39433967 setExtensionPrompt('DEPTH_PROMPT_' + index, value.text, extension_prompt_types.IN_CHAT, value.depth, extension_settings.note.allowWIScan, role);
39443968 });
39453969 } else {
3946- const depthPromptText = baseChatReplace(characters[this_chid]?.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2) || '';
3970+ const depthPromptText = charDepthPrompt || '';
39473971 const depthPromptDepth = characters[this_chid]?.data?.extensions?.depth_prompt?.depth ?? depth_prompt_depth_default;
39483972 const depthPromptRole = getExtensionPromptRoleByName(characters[this_chid]?.data?.extensions?.depth_prompt?.role ?? depth_prompt_role_default);
39493973 setExtensionPrompt('DEPTH_PROMPT', depthPromptText, extension_prompt_types.IN_CHAT, depthPromptDepth, extension_settings.note.allowWIScan, depthPromptRole);
@@ -5884,13 +5908,14 @@ function extractMultiSwipes(data, type) {
58845908 return swipes;
58855909}
58865910
58875911export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncompleteSentences = false, stoppingStrings = null, includeUserPromptBias = true) {
58885912 if (!getMessage) {
58895913 return '';
58905914 }
58915915
58925916 // Add the prompt bias before anything else
58935917 if (
5918+ includeUserPromptBias &&
58945919 power_user.user_prompt_bias &&
58955920 !isImpersonate &&
58965921 !isContinue &&
public/scripts/templates/macros.html+2 -1
@@ -20,7 +20,8 @@
2020 <li><tt>&lcub;&lcub;summary&rcub;&rcub;</tt> – <span data-i18n="help_macros_summary">the latest chat summary generated by the "Summarize" extension (if available).</span></li>
2121 <li><tt>&lcub;&lcub;user&rcub;&rcub;</tt> – <span data-i18n="help_macros_15">your current Persona username</span></li>
2222 <li><tt>&lcub;&lcub;char&rcub;&rcub;</tt> – <span data-i18n="help_macros_16">the Character's name</span></li>
2323 <li><tt>&lcub;&lcub;char_versionversion&rcub;&rcub;</tt> – <span data-i18n="help_macros_17">the Character's version number</span></li>
24+ <li><tt>&lcub;&lcub;charDepthPrompt&rcub;&rcub;</tt> – <span data-i18n="help_macros_charDepthPrompt">the Character's @ Depth Note</span></li>
2425 <li><tt>&lcub;&lcub;group&rcub;&rcub;</tt> – <span data-i18n="help_macros_18">a comma-separated list of group member names (including muted) or the character name in solo chats. Alias: &lcub;&lcub;charIfNotGroup&rcub;&rcub;</span></li>
2526 <li><tt>&lcub;&lcub;groupNotMuted&rcub;&rcub;</tt> – <span data-i18n="help_groupNotMuted">the same as &lcub;&lcub;group&rcub;&rcub;, but excludes muted members</span></li>
2627 <li><tt>&lcub;&lcub;model&rcub;&rcub;</tt> – <span data-i18n="help_macros_19">a text generation model name for the currently selected API. </span><b data-i18n="Can be inaccurate!">Can be inaccurate!</b></li>