mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-04 09:38:50 +01:00
refactor: consolidate agent marketplace endpoints into main agents API and improve data management consistency
- Remove dedicated marketplace controller and routes, merging functionality into main agents v1 API - Add countPromotedAgents function to Agent model for promoted agents count - Enhance getListAgents handler with marketplace filtering (category, search, promoted status) - Move getAgentCategories from marketplace to v1 controller with same functionality - Update agent mutations to invalidate marketplace queries and handle multiple permission levels - Improve cache management by updating all agent query variants (VIEW/EDIT permissions) - Consolidate agent data access patterns for better maintainability and consistency - Remove duplicate marketplace route definitions and middleware
This commit is contained in:
parent
3f6d7ab7c7
commit
6a28d01b20
14 changed files with 291 additions and 412 deletions
|
|
@ -14,7 +14,12 @@ import type {
|
|||
AgentCreateParams,
|
||||
AgentListResponse,
|
||||
} from 'librechat-data-provider';
|
||||
import { useUploadAgentAvatarMutation, useGetFileConfig } from '~/data-provider';
|
||||
import {
|
||||
useUploadAgentAvatarMutation,
|
||||
useGetFileConfig,
|
||||
allAgentViewAndEditQueryKeys,
|
||||
invalidateAgentMarketplaceQueries,
|
||||
} from '~/data-provider';
|
||||
import { AgentAvatarRender, NoImage, AvatarMenu } from './Images';
|
||||
import { useToastContext } from '~/Providers';
|
||||
import { useLocalize } from '~/hooks';
|
||||
|
|
@ -57,30 +62,31 @@ function Avatar({
|
|||
const newUrl = data.avatar?.filepath ?? '';
|
||||
setPreviewUrl(newUrl);
|
||||
|
||||
const res = queryClient.getQueryData<AgentListResponse>([
|
||||
QueryKeys.agents,
|
||||
defaultOrderQuery,
|
||||
]);
|
||||
((keys) => {
|
||||
keys.forEach((key) => {
|
||||
const res = queryClient.getQueryData<AgentListResponse>([QueryKeys.agents, key]);
|
||||
|
||||
if (!res?.data) {
|
||||
return;
|
||||
}
|
||||
if (!res?.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
const agents = res.data.map((agent) => {
|
||||
if (agent.id === agent_id) {
|
||||
return {
|
||||
...agent,
|
||||
...data,
|
||||
};
|
||||
}
|
||||
return agent;
|
||||
});
|
||||
|
||||
queryClient.setQueryData<AgentListResponse>([QueryKeys.agents, defaultOrderQuery], {
|
||||
...res,
|
||||
data: agents,
|
||||
});
|
||||
const agents = res.data.map((agent) => {
|
||||
if (agent.id === agent_id) {
|
||||
return {
|
||||
...agent,
|
||||
...data,
|
||||
};
|
||||
}
|
||||
return agent;
|
||||
});
|
||||
|
||||
queryClient.setQueryData<AgentListResponse>([QueryKeys.agents, key], {
|
||||
...res,
|
||||
data: agents,
|
||||
});
|
||||
});
|
||||
})(allAgentViewAndEditQueryKeys);
|
||||
invalidateAgentMarketplaceQueries(queryClient);
|
||||
setProgress(1);
|
||||
},
|
||||
onError: (error) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue