Handle null values for missing persona descriptor fields

9cf53c6a557962d1b352e45220c9c508566401c9

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

1 files changed, +11 -6Showing whitespace changes
public/scripts/personas.js+11 -6
@@ -646,7 +646,12 @@ async function lockPersona() {
646 );646 );
647 }647 }
648 power_user.personas[user_avatar] = name1;648 power_user.personas[user_avatar] = name1;
649 power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.IN_PROMPT };649 power_user.persona_descriptions[user_avatar] = {
650 description: '',
651 position: persona_description_positions.IN_PROMPT,
652 depth: DEFAULT_DEPTH,
653 role: DEFAULT_ROLE,
654 };
650 }655 }
651656
652 chat_metadata['persona'] = user_avatar;657 chat_metadata['persona'] = user_avatar;
@@ -1012,7 +1017,7 @@ async function duplicatePersona(avatarId) {
1012 const personaName = power_user.personas[avatarId];1017 const personaName = power_user.personas[avatarId];
10131018
1014 if (!personaName) {1019 if (!personaName) {
1015 toastr.warning('Current avatar is not a persona');1020 toastr.warning('Chosen avatar is not a persona');
1016 return;1021 return;
1017 }1022 }
10181023
@@ -1028,10 +1033,10 @@ async function duplicatePersona(avatarId) {
10281033
1029 power_user.personas[newAvatarId] = personaName;1034 power_user.personas[newAvatarId] = personaName;
1030 power_user.persona_descriptions[newAvatarId] = {1035 power_user.persona_descriptions[newAvatarId] = {
1031 description: descriptor?.description || '',1036 description: descriptor?.description ?? '',
1032 position: descriptor?.position || persona_description_positions.IN_PROMPT,1037 position: descriptor?.position ?? persona_description_positions.IN_PROMPT,
1033 depth: descriptor?.depth || DEFAULT_DEPTH,1038 depth: descriptor?.depth ?? DEFAULT_DEPTH,
1034 role: descriptor?.role || DEFAULT_ROLE,1039 role: descriptor?.role ?? DEFAULT_ROLE,
1035 };1040 };
10361041
1037 await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId);1042 await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId);