Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Feat: Displays the total number of nodes and the current number of nodes in ArtifactForceGraph. (#19142)

balibabu31b37aaa604b
diff --git a/web/src/components/artifact-force-graph/index.tsx b/web/src/components/artifact-force-graph/index.tsx
index df58384561..ceac72af28 100644
--- a/web/src/components/artifact-force-graph/index.tsx
+++ b/web/src/components/artifact-force-graph/index.tsx
@@ -17,6 +17,7 @@
import { type IArtifactGraphEntity } from '@/interfaces/database/dataset';
import { cn } from '@/lib/utils';
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
import ForceGraph2D, { type ForceGraphMethods } from 'react-force-graph-2d';
import {
getNodeColor as defaultGetNodeColor,
@@ -49,7 +50,10 @@ function ArtifactForceGraph<TNodeValue = IArtifactGraphEntity>({
getNodeColor = defaultGetNodeColor,
getNodeRadius = defaultGetNodeRadius,
highlightNodeId,
+ totalEntities,
+ returnedEntities,
}: ArtifactForceGraphProps<TNodeValue>) {
+ const { t } = useTranslation();
const containerRef = useRef<HTMLDivElement>(null);
const fgRef = useRef<ForceGraphMethods<ArtifactGraphNode> | undefined>(
undefined,
@@ -123,7 +127,7 @@ function ArtifactForceGraph<TNodeValue = IArtifactGraphEntity>({
return (
<div
ref={containerRef}
- className={cn('flex-1 min-h-0 h-full', !show && 'hidden')}
+ className={cn('relative flex-1 min-h-0 h-full', !show && 'hidden')}
>
{hasDimensions && (
<ForceGraph2D
@@ -147,6 +151,14 @@ function ArtifactForceGraph<TNodeValue = IArtifactGraphEntity>({
linkLabel={getLinkLabel}
/>
)}
+ {totalEntities !== undefined && returnedEntities !== undefined && (
+ <div className="absolute top-2 right-2 z-10 rounded-md border border-border-button bg-bg-card px-2 py-1 text-xs text-text-secondary">
+ {t('knowledgeCompilation.graphEntityCount', {
+ returned: returnedEntities,
+ total: totalEntities,
+ })}
+ </div>
+ )}
</div>
);
}
diff --git a/web/src/components/artifact-force-graph/types.ts b/web/src/components/artifact-force-graph/types.ts
index a8e8eb7415..ede2787444 100644
--- a/web/src/components/artifact-force-graph/types.ts
+++ b/web/src/components/artifact-force-graph/types.ts
@@ -47,4 +47,8 @@ export interface ArtifactForceGraphProps<TNodeValue = IArtifactGraphEntity> {
) => number;
/** Controlled highlighted node id (same id space as getNodeId output, slug by default); real hover takes precedence over this value */
highlightNodeId?: string | null;
+ /** Total entity count in the dataset; rendered together with returnedEntities as an overlay badge */
+ totalEntities?: number;
+ /** Entity count present in the current graph data (may be a sampled subset of totalEntities) */
+ returnedEntities?: number;
}
diff --git a/web/src/components/structure-graph/representation-renderer.tsx b/web/src/components/structure-graph/representation-renderer.tsx
index 8bcc1c38d3..5db35963c7 100644
--- a/web/src/components/structure-graph/representation-renderer.tsx
+++ b/web/src/components/structure-graph/representation-renderer.tsx
@@ -48,6 +48,8 @@ interface RepresentationRendererProps {
template?: IStructureGraphTemplate;
onNodeClick?: (node: ClickableNode) => void;
highlightNodeId?: string | null;
+ totalEntities?: number;
+ returnedEntities?: number;
}
function UnsupportedPlaceholder({ kind }: { kind: StructureTemplateKind }) {
@@ -67,6 +69,8 @@ export function RepresentationRenderer({
template,
onNodeClick,
highlightNodeId,
+ totalEntities,
+ returnedEntities,
}: RepresentationRendererProps) {
const handleTreeItemClick = useCallback(
(item: TreeDataItem | undefined) => {
@@ -172,6 +176,8 @@ export function RepresentationRenderer({
getNodeId={getArtifactNodeName}
onNodeClick={handleArtifactNodeClick}
highlightNodeId={highlightNodeId}
+ totalEntities={totalEntities}
+ returnedEntities={returnedEntities}
/>
</div>
);
@@ -203,6 +209,8 @@ export function RepresentationRenderer({
show
getNodeId={getArtifactNodeName}
onNodeClick={handleArtifactNodeClick}
+ totalEntities={totalEntities}
+ returnedEntities={returnedEntities}
/>
</div>
);
@@ -224,6 +232,8 @@ export function RepresentationRenderer({
show
getNodeId={getArtifactNodeName}
onNodeClick={handleArtifactNodeClick}
+ totalEntities={totalEntities}
+ returnedEntities={returnedEntities}
/>
</div>
);
diff --git a/web/src/interfaces/database/dataset.ts b/web/src/interfaces/database/dataset.ts
index 1b5ef2dffd..a05afa4d44 100644
--- a/web/src/interfaces/database/dataset.ts
+++ b/web/src/interfaces/database/dataset.ts
@@ -297,4 +297,6 @@ export interface IArtifactGraphRelation {
export interface IArtifactGraph {
entities: IArtifactGraphEntity[];
relations: IArtifactGraphRelation[];
+ total_entities?: number;
+ returned_entities?: number;
}
diff --git a/web/src/interfaces/database/document-structure.ts b/web/src/interfaces/database/document-structure.ts
index 6ba6e70363..4cfa9d20a4 100644
--- a/web/src/interfaces/database/document-structure.ts
+++ b/web/src/interfaces/database/document-structure.ts
@@ -29,4 +29,6 @@ export interface IStructureGraphTemplate {
export interface IStructureGraphResponse {
templates: IStructureGraphTemplate[];
+ total_entities?: number;
+ returned_entities?: number;
}
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index bf4a7585f4..1e9aee0264 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -2379,6 +2379,7 @@ Example: Virtual Hosted Style`,
topics: 'Topics',
selectArtifact: 'Select an item from the contents to view details',
searchEntity: 'Search entity',
+ graphEntityCount: '{{returned}} / {{total}} entities',
sourceDocuments: 'Source documents',
clearWikiTitle: 'Clear wiki',
clearWikiDescription:
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 7069e2e95d..ed985c42df 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -2004,6 +2004,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
topics: 'Topic',
selectArtifact: '从目录中选择一个条目以查看详情',
searchEntity: '搜索 Entity',
+ graphEntityCount: '实体 {{returned}} / {{total}}',
sourceDocuments: '来源文档',
clearWikiTitle: '清空 Wiki',
clearWikiDescription:
diff --git a/web/src/pages/chunk/representation/index.tsx b/web/src/pages/chunk/representation/index.tsx
index 3830fdf7cc..2e60e2816b 100644
--- a/web/src/pages/chunk/representation/index.tsx
+++ b/web/src/pages/chunk/representation/index.tsx
@@ -99,6 +99,8 @@ function Representation({ onNodeClick }: RepresentationProps) {
template={selectedTemplate}
onNodeClick={handleNodeClick}
highlightNodeId={highlightNodeId}
+ totalEntities={data?.total_entities}
+ returnedEntities={data?.returned_entities}
/>
)}
</section>
diff --git a/web/src/pages/dataset/compilation/dataset-structure-view.tsx b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
index f9a67d3985..2167f75c90 100644
--- a/web/src/pages/dataset/compilation/dataset-structure-view.tsx
+++ b/web/src/pages/dataset/compilation/dataset-structure-view.tsx
@@ -76,7 +76,7 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
queryKey: ArtifactAlterationKeys.detail(knowledgeBaseId, kind),
});
}, [queryClient, knowledgeBaseId, kind]);
-
+
useRunEndEffect(structureStatus, handleRunEnd);
const entityOptions = useMemo<SelectWithSearchFlagOptionType[]>(
@@ -193,6 +193,8 @@ export function DatasetStructureView({ kind }: DatasetStructureViewProps) {
<RepresentationRenderer
template={template}
highlightNodeId={selectedEntityName || null}
+ totalEntities={data?.total_entities}
+ returnedEntities={data?.returned_entities}
/>
<UpdateLogSheet
open={updateSheetOpen}
diff --git a/web/src/pages/dataset/compilation/wiki-left-panel/wiki-graph-panel.tsx b/web/src/pages/dataset/compilation/wiki-left-panel/wiki-graph-panel.tsx
index 839c660257..a34c30fc61 100644
--- a/web/src/pages/dataset/compilation/wiki-left-panel/wiki-graph-panel.tsx
+++ b/web/src/pages/dataset/compilation/wiki-left-panel/wiki-graph-panel.tsx
@@ -94,6 +94,8 @@ export function WikiGraphPanel({
mapNodeToValue={mapNodeToValue}
onNodeClick={onSelectArtifact}
highlightNodeId={selectedArtifact?.slug}
+ totalEntities={data.total_entities}
+ returnedEntities={data.returned_entities}
/>
</div>
);