Merge pull request #2042 from Wolfsblvt/macro-main-system-prompt
Add a main {{systemPrompt}} macro
This commit is contained in:
commit
7311997e7a
|
@ -518,13 +518,16 @@ function selectMatchingContextTemplate(name) {
|
||||||
/**
|
/**
|
||||||
* Replaces instruct mode macros in the given input string.
|
* Replaces instruct mode macros in the given input string.
|
||||||
* @param {string} input Input string.
|
* @param {string} input Input string.
|
||||||
|
* @param {Object<string, *>} env - Map of macro names to the values they'll be substituted with. If the param
|
||||||
|
* values are functions, those functions will be called and their return values are used.
|
||||||
* @returns {string} String with macros replaced.
|
* @returns {string} String with macros replaced.
|
||||||
*/
|
*/
|
||||||
export function replaceInstructMacros(input) {
|
export function replaceInstructMacros(input, env) {
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const instructMacros = {
|
const instructMacros = {
|
||||||
|
'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.instruct.system_prompt),
|
||||||
'instructSystem|instructSystemPrompt': power_user.instruct.system_prompt,
|
'instructSystem|instructSystemPrompt': power_user.instruct.system_prompt,
|
||||||
'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix,
|
'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix,
|
||||||
'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix,
|
'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix,
|
||||||
|
|
|
@ -279,7 +279,7 @@ export function evaluateMacros(content, env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
content = diceRollReplace(content);
|
content = diceRollReplace(content);
|
||||||
content = replaceInstructMacros(content);
|
content = replaceInstructMacros(content, env);
|
||||||
content = replaceVariableMacros(content);
|
content = replaceVariableMacros(content);
|
||||||
content = content.replace(/{{newline}}/gi, '\n');
|
content = content.replace(/{{newline}}/gi, '\n');
|
||||||
content = content.replace(/\n*{{trim}}\n*/gi, '');
|
content = content.replace(/\n*{{trim}}\n*/gi, '');
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
<li><tt>{{maxPrompt}}</tt> – max allowed prompt length in tokens = (context size - response length)</li>
|
<li><tt>{{maxPrompt}}</tt> – max allowed prompt length in tokens = (context size - response length)</li>
|
||||||
<li><tt>{{exampleSeparator}}</tt> – context template example dialogues separator</li>
|
<li><tt>{{exampleSeparator}}</tt> – context template example dialogues separator</li>
|
||||||
<li><tt>{{chatStart}}</tt> – context template chat start line</li>
|
<li><tt>{{chatStart}}</tt> – context template chat start line</li>
|
||||||
|
<li><tt>{{systemPrompt}}</tt> – main system prompt (either character prompt override if chosen, or instructSystemPrompt)</li>
|
||||||
<li><tt>{{instructSystemPrompt}}</tt> – instruct system prompt</li>
|
<li><tt>{{instructSystemPrompt}}</tt> – instruct system prompt</li>
|
||||||
<li><tt>{{instructSystemPromptPrefix}}</tt> – instruct system prompt prefix sequence</li>
|
<li><tt>{{instructSystemPromptPrefix}}</tt> – instruct system prompt prefix sequence</li>
|
||||||
<li><tt>{{instructSystemPromptSuffix}}</tt> – instruct system prompt suffix sequence</li>
|
<li><tt>{{instructSystemPromptSuffix}}</tt> – instruct system prompt suffix sequence</li>
|
||||||
|
|
Loading…
Reference in New Issue