feat: update RAG recommended plugins hook to accept type parameter (#29735)

This commit is contained in:
Wu Tianwei
2025-12-17 13:48:23 +08:00
committed by GitHub
parent 44f8915e30
commit 1d1351393a
3 changed files with 15 additions and 6 deletions

View File

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

View File

@ -52,7 +52,7 @@ const RAGToolRecommendations = ({
data: ragRecommendedPlugins, data: ragRecommendedPlugins,
isLoading: isLoadingRAGRecommendedPlugins, isLoading: isLoadingRAGRecommendedPlugins,
isFetching: isFetchingRAGRecommendedPlugins, isFetching: isFetchingRAGRecommendedPlugins,
} = useRAGRecommendedPlugins() } = useRAGRecommendedPlugins('tool')
const recommendedPlugins = useMemo(() => { const recommendedPlugins = useMemo(() => {
if (ragRecommendedPlugins) if (ragRecommendedPlugins)

View File

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