Add macro for charDepthPrompt
| @@ -2746,6 +2746,7 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re | |||
| 2746 | environment.mesExamplesRaw = fields.mesExamples || ''; | 2746 | environment.mesExamplesRaw = fields.mesExamples || ''; |
| 2747 | environment.charVersion = fields.version || ''; | 2747 | environment.charVersion = fields.version || ''; |
| 2748 | environment.char_version = fields.version || ''; | 2748 | environment.char_version = fields.version || ''; |
| 2749 | environment.charDepthPrompt = fields.charDepthPrompt || ''; | ||
| 2749 | } | 2750 | } |
| 2750 | 2751 | ||
| 2751 | // Must be substituted last so that they're replaced inside {{description}} | 2752 | // Must be substituted last so that they're replaced inside {{description}} |
| @@ -3097,10 +3098,30 @@ export function baseChatReplace(value, name1, name2) { | |||
| 3097 | 3098 | ||
| 3098 | /** | 3099 | /** |
| 3099 | * Returns the character card fields for the current character. | 3100 | * 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 | ||
| 3101 | */ | 3112 | */ |
| 3102 | export function getCharacterCardFields() { | 3113 | export 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 | }; | ||
| 3104 | result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2); | 3125 | result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2); |
| 3105 | 3126 | ||
| 3106 | const character = characters[this_chid]; | 3127 | const character = characters[this_chid]; |
| @@ -3117,6 +3138,7 @@ export function getCharacterCardFields() { | |||
| 3117 | result.system = power_user.prefer_character_prompt ? baseChatReplace(character.data?.system_prompt?.trim(), name1, name2) : ''; | 3138 | result.system = power_user.prefer_character_prompt ? baseChatReplace(character.data?.system_prompt?.trim(), name1, name2) : ''; |
| 3118 | result.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(character.data?.post_history_instructions?.trim(), name1, name2) : ''; | 3139 | result.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(character.data?.post_history_instructions?.trim(), name1, name2) : ''; |
| 3119 | result.version = character.data?.character_version ?? ''; | 3140 | result.version = character.data?.character_version ?? ''; |
| 3141 | result.charDepthPrompt = baseChatReplace(character.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2); | ||
| 3120 | 3142 | ||
| 3121 | if (selected_group) { | 3143 | if (selected_group) { |
| 3122 | const groupCards = getGroupCharacterCards(selected_group, Number(this_chid)); | 3144 | const groupCards = getGroupCharacterCards(selected_group, Number(this_chid)); |
| @@ -3612,7 +3634,8 @@ export async function generateRaw(prompt, api, instructOverride, quietToLoud, sy | |||
| 3612 | throw new Error(data.response); | 3634 | throw new Error(data.response); |
| 3613 | } | 3635 | } |
| 3614 | 3636 | ||
| 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); | ||
| 3616 | 3639 | ||
| 3617 | if (!message) { | 3640 | if (!message) { |
| 3618 | throw new Error('No message generated'); | 3641 | throw new Error('No message generated'); |
| @@ -3921,6 +3944,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3921 | mesExamples, | 3944 | mesExamples, |
| 3922 | system, | 3945 | system, |
| 3923 | jailbreak, | 3946 | jailbreak, |
| 3947 | charDepthPrompt, | ||
| 3924 | } = getCharacterCardFields(); | 3948 | } = getCharacterCardFields(); |
| 3925 | 3949 | ||
| 3926 | if (main_api !== 'openai') { | 3950 | if (main_api !== 'openai') { |
| @@ -3943,7 +3967,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3943 | setExtensionPrompt('DEPTH_PROMPT_' + index, value.text, extension_prompt_types.IN_CHAT, value.depth, extension_settings.note.allowWIScan, role); | 3967 | setExtensionPrompt('DEPTH_PROMPT_' + index, value.text, extension_prompt_types.IN_CHAT, value.depth, extension_settings.note.allowWIScan, role); |
| 3944 | }); | 3968 | }); |
| 3945 | } else { | 3969 | } else { |
| 3946 | const depthPromptText = baseChatReplace(characters[this_chid]?.data?.extensions?.depth_prompt?.prompt?.trim(), name1, name2) || ''; | 3970 | const depthPromptText = charDepthPrompt || ''; |
| 3947 | const depthPromptDepth = characters[this_chid]?.data?.extensions?.depth_prompt?.depth ?? depth_prompt_depth_default; | 3971 | const depthPromptDepth = characters[this_chid]?.data?.extensions?.depth_prompt?.depth ?? depth_prompt_depth_default; |
| 3948 | const depthPromptRole = getExtensionPromptRoleByName(characters[this_chid]?.data?.extensions?.depth_prompt?.role ?? depth_prompt_role_default); | 3972 | const depthPromptRole = getExtensionPromptRoleByName(characters[this_chid]?.data?.extensions?.depth_prompt?.role ?? depth_prompt_role_default); |
| 3949 | setExtensionPrompt('DEPTH_PROMPT', depthPromptText, extension_prompt_types.IN_CHAT, depthPromptDepth, extension_settings.note.allowWIScan, depthPromptRole); | 3973 | setExtensionPrompt('DEPTH_PROMPT', depthPromptText, extension_prompt_types.IN_CHAT, depthPromptDepth, extension_settings.note.allowWIScan, depthPromptRole); |
| @@ -5884,13 +5908,14 @@ function extractMultiSwipes(data, type) { | |||
| 5884 | return swipes; | 5908 | return swipes; |
| 5885 | } | 5909 | } |
| 5886 | 5910 | ||
| 5887 | export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncompleteSentences = false, stoppingStrings = null) { | 5911 | export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncompleteSentences = false, stoppingStrings = null, includeUserPromptBias = true) { |
| 5888 | if (!getMessage) { | 5912 | if (!getMessage) { |
| 5889 | return ''; | 5913 | return ''; |
| 5890 | } | 5914 | } |
| 5891 | 5915 | ||
| 5892 | // Add the prompt bias before anything else | 5916 | // Add the prompt bias before anything else |
| 5893 | if ( | 5917 | if ( |
| 5918 | includeUserPromptBias && | ||
| 5894 | power_user.user_prompt_bias && | 5919 | power_user.user_prompt_bias && |
| 5895 | !isImpersonate && | 5920 | !isImpersonate && |
| 5896 | !isContinue && | 5921 | !isContinue && |
| @@ -20,7 +20,8 @@ | |||
| 20 | <li><tt>{{summary}}</tt> – <span data-i18n="help_macros_summary">the latest chat summary generated by the "Summarize" extension (if available).</span></li> | 20 | <li><tt>{{summary}}</tt> – <span data-i18n="help_macros_summary">the latest chat summary generated by the "Summarize" extension (if available).</span></li> |
| 21 | <li><tt>{{user}}</tt> – <span data-i18n="help_macros_15">your current Persona username</span></li> | 21 | <li><tt>{{user}}</tt> – <span data-i18n="help_macros_15">your current Persona username</span></li> |
| 22 | <li><tt>{{char}}</tt> – <span data-i18n="help_macros_16">the Character's name</span></li> | 22 | <li><tt>{{char}}</tt> – <span data-i18n="help_macros_16">the Character's name</span></li> |
| 23 | <li><tt>{{char_version}}</tt> – <span data-i18n="help_macros_17">the Character's version number</span></li> | 23 | <li><tt>{{version}}</tt> – <span data-i18n="help_macros_17">the Character's version number</span></li> |
| 24 | <li><tt>{{charDepthPrompt}}</tt> – <span data-i18n="help_macros_charDepthPrompt">the Character's @ Depth Note</span></li> | ||
| 24 | <li><tt>{{group}}</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: {{charIfNotGroup}}</span></li> | 25 | <li><tt>{{group}}</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: {{charIfNotGroup}}</span></li> |
| 25 | <li><tt>{{groupNotMuted}}</tt> – <span data-i18n="help_groupNotMuted">the same as {{group}}, but excludes muted members</span></li> | 26 | <li><tt>{{groupNotMuted}}</tt> – <span data-i18n="help_groupNotMuted">the same as {{group}}, but excludes muted members</span></li> |
| 26 | <li><tt>{{model}}</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> | 27 | <li><tt>{{model}}</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> |