mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: update RAG recommended plugins hook to accept type parameter (#29735)
This commit is contained in:
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user