mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🖼️ fix: Avatar Handling for Agents and Assistants (#4507)
The changes include: - In the agent controller: - Removed the parsing of the avatar metadata from the request body. - Fetched the avatar data from the agent object using the agent ID. - Updated the error logging when fetching the agent. - Updated the deleteFileByFilter function to include the user ID when deleting the old avatar file. - In the assistant controller: - Removed the parsing of the metadata from the request body. - Fetched the metadata from the assistant object using the assistant ID. - Updated the error logging when fetching the assistant. - Updated the deleteFileByFilter function to include the user ID when deleting the old avatar file.
This commit is contained in:
parent
ec922986a9
commit
ebe3e7f796
5 changed files with 37 additions and 35 deletions
|
|
@ -226,8 +226,6 @@ const uploadAgentAvatarHandler = async (req, res) => {
|
|||
return res.status(400).json({ message: 'Agent ID is required' });
|
||||
}
|
||||
|
||||
let { avatar: _avatar = '{}' } = req.body;
|
||||
|
||||
const image = await uploadImageBuffer({
|
||||
req,
|
||||
context: FileContext.avatar,
|
||||
|
|
@ -236,10 +234,12 @@ const uploadAgentAvatarHandler = async (req, res) => {
|
|||
},
|
||||
});
|
||||
|
||||
let _avatar;
|
||||
try {
|
||||
_avatar = JSON.parse(_avatar);
|
||||
const agent = await getAgent({ id: agent_id });
|
||||
_avatar = agent.avatar;
|
||||
} catch (error) {
|
||||
logger.error('[/avatar/:agent_id] Error parsing avatar', error);
|
||||
logger.error('[/avatar/:agent_id] Error fetching agent', error);
|
||||
_avatar = {};
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ const uploadAgentAvatarHandler = async (req, res) => {
|
|||
const { deleteFile } = getStrategyFunctions(_avatar.source);
|
||||
try {
|
||||
await deleteFile(req, { filepath: _avatar.filepath });
|
||||
await deleteFileByFilter({ filepath: _avatar.filepath });
|
||||
await deleteFileByFilter({ user: req.user.id, filepath: _avatar.filepath });
|
||||
} catch (error) {
|
||||
logger.error('[/avatar/:agent_id] Error deleting old avatar', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue