mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Code clean-up
This commit is contained in:
@@ -2304,6 +2304,8 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
|
|||||||
environment.scenario = fields.scenario || '';
|
environment.scenario = fields.scenario || '';
|
||||||
environment.persona = fields.persona || '';
|
environment.persona = fields.persona || '';
|
||||||
environment.mesExamples = fields.mesExamples || '';
|
environment.mesExamples = fields.mesExamples || '';
|
||||||
|
environment.charVersion = fields.version || '';
|
||||||
|
environment.char_version = fields.version || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be substituted last so that they're replaced inside {{description}}
|
// Must be substituted last so that they're replaced inside {{description}}
|
||||||
@@ -2311,7 +2313,6 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
|
|||||||
environment.char = _name2 ?? name2;
|
environment.char = _name2 ?? name2;
|
||||||
environment.group = environment.charIfNotGroup = getGroupValue();
|
environment.group = environment.charIfNotGroup = getGroupValue();
|
||||||
environment.model = getGeneratingModel();
|
environment.model = getGeneratingModel();
|
||||||
environment.char_version = characters.filter(x => x.name === environment.char).map(x => x.data.character_version)[0];
|
|
||||||
|
|
||||||
return evaluateMacros(content, environment);
|
return evaluateMacros(content, environment);
|
||||||
}
|
}
|
||||||
@@ -2602,10 +2603,10 @@ export function baseChatReplace(value, name1, name2) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character card fields for the current character.
|
* Returns the character card fields for the current character.
|
||||||
* @returns {{system: string, mesExamples: string, description: string, personality: string, persona: string, scenario: string, jailbreak: string}}
|
* @returns {{system: string, mesExamples: string, description: string, personality: string, persona: string, scenario: string, jailbreak: string, version: string}}
|
||||||
*/
|
*/
|
||||||
export function getCharacterCardFields() {
|
export function getCharacterCardFields() {
|
||||||
const result = { system: '', mesExamples: '', description: '', personality: '', persona: '', scenario: '', jailbreak: '' };
|
const result = { system: '', mesExamples: '', description: '', personality: '', persona: '', scenario: '', jailbreak: '', version: '' };
|
||||||
const character = characters[this_chid];
|
const character = characters[this_chid];
|
||||||
|
|
||||||
if (!character) {
|
if (!character) {
|
||||||
@@ -2620,6 +2621,7 @@ export function getCharacterCardFields() {
|
|||||||
result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
|
result.persona = baseChatReplace(power_user.persona_description?.trim(), name1, name2);
|
||||||
result.system = power_user.prefer_character_prompt ? baseChatReplace(characters[this_chid].data?.system_prompt?.trim(), name1, name2) : '';
|
result.system = power_user.prefer_character_prompt ? baseChatReplace(characters[this_chid].data?.system_prompt?.trim(), name1, name2) : '';
|
||||||
result.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';
|
result.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';
|
||||||
|
result.version = characters[this_chid].data?.character_version ?? '';
|
||||||
|
|
||||||
if (selected_group) {
|
if (selected_group) {
|
||||||
const groupCards = getGroupCharacterCards(selected_group, Number(this_chid));
|
const groupCards = getGroupCharacterCards(selected_group, Number(this_chid));
|
||||||
|
@@ -337,8 +337,6 @@ export function evaluateMacros(content, env) {
|
|||||||
content = content.replace(/{{isotime}}/gi, () => moment().format('HH:mm'));
|
content = content.replace(/{{isotime}}/gi, () => moment().format('HH:mm'));
|
||||||
content = content.replace(/{{isodate}}/gi, () => moment().format('YYYY-MM-DD'));
|
content = content.replace(/{{isodate}}/gi, () => moment().format('YYYY-MM-DD'));
|
||||||
|
|
||||||
content = content.replace(/{{char_version}}/gi, env.char_version);
|
|
||||||
|
|
||||||
content = content.replace(/{{datetimeformat +([^}]*)}}/gi, (_, format) => {
|
content = content.replace(/{{datetimeformat +([^}]*)}}/gi, (_, format) => {
|
||||||
const formattedTime = moment().format(format);
|
const formattedTime = moment().format(format);
|
||||||
return formattedTime;
|
return formattedTime;
|
||||||
|
Reference in New Issue
Block a user