feat: update RAG recommended plugins hook to accept type parameter for better categorization

This commit is contained in:
WTW0313 2025-12-16 15:46:42 +08:00
parent fdd21ac815
commit 03cc3868ef
2 changed files with 14 additions and 5 deletions

View File

@ -37,7 +37,7 @@ const useRefreshPluginList = () => {
if ((manifest && PluginCategoryEnum.tool.includes(manifest.category)) || refreshAllType) {
invalidateAllToolProviders()
invalidateAllBuiltInTools()
invalidateRAGRecommendedPlugins()
invalidateRAGRecommendedPlugins('tool')
// TODO: update suggested tools. It's a function in hook useMarketplacePlugins,handleUpdatePlugins
}

View File

@ -330,15 +330,24 @@ export const useRemoveProviderCredentials = ({
const useRAGRecommendedPluginListKey = [NAME_SPACE, 'rag-recommended-plugins']
export const useRAGRecommendedPlugins = () => {
export const useRAGRecommendedPlugins = (type: 'tool' | 'datasource' | 'all' = 'all') => {
return useQuery<RAGRecommendedPlugins>({
queryKey: useRAGRecommendedPluginListKey,
queryFn: () => get<RAGRecommendedPlugins>('/rag/pipelines/recommended-plugins'),
queryKey: [...useRAGRecommendedPluginListKey, type],
queryFn: () => get<RAGRecommendedPlugins>('/rag/pipelines/recommended-plugins', {
params: {
type,
},
}),
})
}
export const useInvalidateRAGRecommendedPlugins = () => {
return useInvalid(useRAGRecommendedPluginListKey)
const queryClient = useQueryClient()
return (type: 'tool' | 'datasource' | 'all' = 'all') => {
queryClient.invalidateQueries({
queryKey: [...useRAGRecommendedPluginListKey, type],
})
}
}
// App Triggers API hooks