Compare commits

..

2 Commits

Author SHA1 Message Date
Cohee 9cf53c6a55 Handle null values for missing persona descriptor fields 2024-07-26 19:45:45 +03:00
Wolfsblvt 63512c208f Fix popup not respecting <null> for text 2024-07-26 18:17:32 +02:00
2 changed files with 16 additions and 11 deletions

View File

@ -646,7 +646,12 @@ async function lockPersona() {
);
}
power_user.personas[user_avatar] = name1;
power_user.persona_descriptions[user_avatar] = { description: '', position: persona_description_positions.IN_PROMPT };
power_user.persona_descriptions[user_avatar] = {
description: '',
position: persona_description_positions.IN_PROMPT,
depth: DEFAULT_DEPTH,
role: DEFAULT_ROLE,
};
}
chat_metadata['persona'] = user_avatar;
@ -1012,7 +1017,7 @@ async function duplicatePersona(avatarId) {
const personaName = power_user.personas[avatarId];
if (!personaName) {
toastr.warning('Current avatar is not a persona');
toastr.warning('Chosen avatar is not a persona');
return;
}
@ -1028,10 +1033,10 @@ async function duplicatePersona(avatarId) {
power_user.personas[newAvatarId] = personaName;
power_user.persona_descriptions[newAvatarId] = {
description: descriptor?.description || '',
position: descriptor?.position || persona_description_positions.IN_PROMPT,
depth: descriptor?.depth || DEFAULT_DEPTH,
role: descriptor?.role || DEFAULT_ROLE,
description: descriptor?.description ?? '',
position: descriptor?.position ?? persona_description_positions.IN_PROMPT,
depth: descriptor?.depth ?? DEFAULT_DEPTH,
role: descriptor?.role ?? DEFAULT_ROLE,
};
await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId);

View File

@ -73,8 +73,8 @@ const showPopupHelper = {
/**
* Asynchronously displays an input popup with the given header and text, and returns the user's input.
*
* @param {string} header - The header text for the popup.
* @param {string} text - The main text for the popup.
* @param {string?} header - The header text for the popup.
* @param {string?} text - The main text for the popup.
* @param {string} [defaultValue=''] - The default value for the input field.
* @param {PopupOptions} [popupOptions={}] - Options for the popup.
* @return {Promise<string?>} A Promise that resolves with the user's input.
@ -591,15 +591,15 @@ class PopupUtils {
/**
* Builds popup content with header and text below
*
* @param {string} header - The header to be added to the text
* @param {string} text - The main text content
* @param {string?} header - The header to be added to the text
* @param {string?} text - The main text content
*/
static BuildTextWithHeader(header, text) {
if (!header) {
return text;
}
return `<h3>${header}</h3>
${text}`;
${text ?? ''}`; // Convert no text to empty string
}
}