mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 03:10: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
|
|
@ -135,10 +135,6 @@ function Avatar({
|
|||
formData.append('file', input, input.name);
|
||||
formData.append('agent_id', createMutation.data.id);
|
||||
|
||||
if (typeof createMutation.data.avatar === 'object') {
|
||||
formData.append('avatar', JSON.stringify(createMutation.data.avatar));
|
||||
}
|
||||
|
||||
uploadAvatar({
|
||||
agent_id: createMutation.data.id,
|
||||
postCreation: true,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ function Avatar({
|
|||
setInput(null);
|
||||
setPreviewUrl(data.metadata?.avatar as string | null);
|
||||
|
||||
const res = queryClient.getQueryData<AssistantListResponse>([
|
||||
const res = queryClient.getQueryData<AssistantListResponse | undefined>([
|
||||
QueryKeys.assistants,
|
||||
endpoint,
|
||||
defaultOrderQuery,
|
||||
|
|
@ -78,16 +78,15 @@ function Avatar({
|
|||
return;
|
||||
}
|
||||
|
||||
const assistants =
|
||||
res.data.map((assistant) => {
|
||||
if (assistant.id === assistant_id) {
|
||||
return {
|
||||
...assistant,
|
||||
...data,
|
||||
};
|
||||
}
|
||||
return assistant;
|
||||
}) ?? [];
|
||||
const assistants = res.data.map((assistant) => {
|
||||
if (assistant.id === assistant_id) {
|
||||
return {
|
||||
...assistant,
|
||||
...data,
|
||||
};
|
||||
}
|
||||
return assistant;
|
||||
});
|
||||
|
||||
queryClient.setQueryData<AssistantListResponse>(
|
||||
[QueryKeys.assistants, endpoint, defaultOrderQuery],
|
||||
|
|
@ -149,10 +148,6 @@ function Avatar({
|
|||
formData.append('file', input, input.name);
|
||||
formData.append('assistant_id', createMutation.data.id);
|
||||
|
||||
if (typeof createMutation.data.metadata === 'object') {
|
||||
formData.append('metadata', JSON.stringify(createMutation.data.metadata));
|
||||
}
|
||||
|
||||
uploadAvatar({
|
||||
assistant_id: createMutation.data.id,
|
||||
model: activeModel,
|
||||
|
|
@ -195,10 +190,6 @@ function Avatar({
|
|||
formData.append('file', file, file.name);
|
||||
formData.append('assistant_id', assistant_id);
|
||||
|
||||
if (typeof metadata === 'object') {
|
||||
formData.append('metadata', JSON.stringify(metadata));
|
||||
}
|
||||
|
||||
uploadAvatar({
|
||||
assistant_id,
|
||||
model: activeModel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue