Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

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

Wu Tianwei1d1351393abb
diff --git a/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx b/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx
index 264c4782cdf..b9413afcdd1 100644
--- a/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx
+++ b/web/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list.tsx
@@ -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
}
diff --git a/web/app/components/workflow/block-selector/rag-tool-recommendations/index.tsx b/web/app/components/workflow/block-selector/rag-tool-recommendations/index.tsx
index 240c0814a1c..47b158b9b2a 100644
--- a/web/app/components/workflow/block-selector/rag-tool-recommendations/index.tsx
+++ b/web/app/components/workflow/block-selector/rag-tool-recommendations/index.tsx
@@ -52,7 +52,7 @@ const RAGToolRecommendations = ({
data: ragRecommendedPlugins,
isLoading: isLoadingRAGRecommendedPlugins,
isFetching: isFetchingRAGRecommendedPlugins,
- } = useRAGRecommendedPlugins()
+ } = useRAGRecommendedPlugins('tool')
const recommendedPlugins = useMemo(() => {
if (ragRecommendedPlugins)
diff --git a/web/service/use-tools.ts b/web/service/use-tools.ts
index ad483bea110..6ac57e84d31 100644
--- a/web/service/use-tools.ts
+++ b/web/service/use-tools.ts
@@ -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