Handle null values for missing persona descriptor fields
| @@ -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 | } |
| 651 | 656 | ||
| 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]; |
| 1013 | 1018 | ||
| 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 | } |
| 1018 | 1023 | ||
| @@ -1028,10 +1033,10 @@ async function duplicatePersona(avatarId) { | |||
| 1028 | 1033 | ||
| 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 | }; |
| 1036 | 1041 | ||
| 1037 | await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId); | 1042 | await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId); |