RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
feat: Fixed the issue where the page reports an error when the graph returned by the interface is empty #162 (#1795)
balibabu216f6495c467
diff --git a/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/force-graph.tsx b/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/force-graph.tsxindex 45bfb82ce0..4c6c427583 100644--- a/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/force-graph.tsx+++ b/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/force-graph.tsx@@ -1,4 +1,5 @@import { ElementDatum, Graph, IElementEvent } from '@antv/g6';+import isEmpty from 'lodash/isEmpty';import { useCallback, useEffect, useMemo, useRef } from 'react';import { buildNodesAndCombos } from './util';@@ -20,7 +21,7 @@ const ForceGraph = ({ data, show }: IProps) => {const graphRef = useRef<Graph | null>(null);const nextData = useMemo(() => {- if (data) {+ if (!isEmpty(data)) {const graphData = data;const mi = buildNodesAndCombos(graphData.nodes);return { edges: graphData.links, ...mi };@@ -116,7 +117,7 @@ const ForceGraph = ({ data, show }: IProps) => {}, [nextData]);useEffect(() => {- if (data) {+ if (!isEmpty(data)) {render();}}, [data, render]);diff --git a/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/util.ts b/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/util.tsindex 7aa41f2626..eff77479e5 100644--- a/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/util.ts+++ b/web/src/pages/add-knowledge/components/knowledge-chunk/components/knowledge-graph/util.ts@@ -1,3 +1,5 @@+import { isEmpty } from 'lodash';+class KeyGenerator {idx = 0;chars: string[] = [];@@ -55,7 +57,9 @@ export class Converter {}export const isDataExist = (data: any) => {- return data?.data && typeof data?.data !== 'boolean';+ return (+ data?.data && typeof data?.data !== 'boolean' && !isEmpty(data?.data?.graph)+ );};export const buildNodesAndCombos = (nodes: any[]) => {