From 23c2a0d8f5512d7081254365ec22763d865c25e2 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 3 Mar 2024 18:56:05 +0200 Subject: [PATCH] Fix card fields replace if missing --- public/script.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/script.js b/public/script.js index cfb453486..961ce65c1 100644 --- a/public/script.js +++ b/public/script.js @@ -2491,12 +2491,12 @@ export function getCharacterCardFields() { return result; } - const scenarioText = chat_metadata['scenario'] || characters[this_chid].scenario; - result.description = baseChatReplace(characters[this_chid].description.trim(), name1, name2); - result.personality = baseChatReplace(characters[this_chid].personality.trim(), name1, name2); + const scenarioText = chat_metadata['scenario'] || characters[this_chid]?.scenario; + result.description = baseChatReplace(characters[this_chid].description?.trim(), name1, name2); + result.personality = baseChatReplace(characters[this_chid].personality?.trim(), name1, name2); result.scenario = baseChatReplace(scenarioText.trim(), name1, name2); - result.mesExamples = baseChatReplace(characters[this_chid].mes_example.trim(), name1, name2); - result.persona = baseChatReplace(power_user.persona_description.trim(), name1, name2); + result.mesExamples = baseChatReplace(characters[this_chid].mes_example?.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.jailbreak = power_user.prefer_character_jailbreak ? baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2) : '';