Handle null values for missing persona descriptor fields

9cf53c6a557962d1b352e45220c9c508566401c9

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

1 files changed, +11 -6Ignore whitespace
public/scripts/personas.js+11 -6
@@ -646,7 +646,12 @@ async function lockPersona() {
646646 );
647647 }
648648 power_user.personas[user_avatar] = name1;
649649 power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.IN_PROMPT };
650+ description: '',
651+ position: persona_description_positions.IN_PROMPT,
652+ depth: DEFAULT_DEPTH,
653+ role: DEFAULT_ROLE,
654+ };
650655 }
651656
652657 chat_metadata['persona'] = user_avatar;
@@ -1012,7 +1017,7 @@ async function duplicatePersona(avatarId) {
10121017 const personaName = power_user.personas[avatarId];
10131018
10141019 if (!personaName) {
10151020 toastr.warning('CurrentChosen avatar is not a persona');
10161021 return;
10171022 }
10181023
@@ -1028,10 +1033,10 @@ async function duplicatePersona(avatarId) {
10281033
10291034 power_user.personas[newAvatarId] = personaName;
10301035 power_user.persona_descriptions[newAvatarId] = {
10311036 description: descriptor?.description ||?? '',
10321037 position: descriptor?.position ||?? persona_description_positions.IN_PROMPT,
10331038 depth: descriptor?.depth ||?? DEFAULT_DEPTH,
10341039 role: descriptor?.role ||?? DEFAULT_ROLE,
10351040 };
10361041
10371042 await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId);