diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index f053b25e..49f3d955 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -186,7 +186,9 @@ class LightRAG: embedding_batch_num: int = field(default=int(os.getenv("EMBEDDING_BATCH_NUM", 32))) """Batch size for embedding computations.""" - embedding_func_max_async: int = field(default=int(os.getenv("EMBEDDING_FUNC_MAX_ASYNC", 16))) + embedding_func_max_async: int = field( + default=int(os.getenv("EMBEDDING_FUNC_MAX_ASYNC", 16)) + ) """Maximum number of concurrent embedding function calls.""" embedding_cache_config: dict[str, Any] = field( diff --git a/lightrag_webui/src/components/graph/GraphLabels.tsx b/lightrag_webui/src/components/graph/GraphLabels.tsx index d554fa5b..b89c2e74 100644 --- a/lightrag_webui/src/components/graph/GraphLabels.tsx +++ b/lightrag_webui/src/components/graph/GraphLabels.tsx @@ -60,13 +60,13 @@ const GraphLabels = () => { // Reset fetch status flags useGraphStore.getState().setLabelsFetchAttempted(false) useGraphStore.getState().setGraphDataFetchAttempted(false) - + // Clear last successful query label to ensure labels are fetched useGraphStore.getState().setLastSuccessfulQueryLabel('') - + // Get current label const currentLabel = useSettingsStore.getState().queryLabel - + // If current label is empty, use default label '*' if (!currentLabel) { useSettingsStore.getState().setQueryLabel('*') @@ -119,7 +119,7 @@ const GraphLabels = () => { // Reset graphDataFetchAttempted flag to ensure data fetch is triggered useGraphStore.getState().setGraphDataFetchAttempted(false); - + // Update the label to trigger data loading useSettingsStore.getState().setQueryLabel(newLabel); }} diff --git a/lightrag_webui/src/hooks/useLightragGraph.tsx b/lightrag_webui/src/hooks/useLightragGraph.tsx index 74a3d87d..dbc26745 100644 --- a/lightrag_webui/src/hooks/useLightragGraph.tsx +++ b/lightrag_webui/src/hooks/useLightragGraph.tsx @@ -72,7 +72,7 @@ export type EdgeType = { label: string } const fetchGraph = async (label: string, maxDepth: number, minDegree: number) => { let rawData: any = null; - + // Check if we need to fetch all database labels first const lastSuccessfulQueryLabel = useGraphStore.getState().lastSuccessfulQueryLabel; if (!lastSuccessfulQueryLabel) { @@ -87,7 +87,7 @@ const fetchGraph = async (label: string, maxDepth: number, minDegree: number) => // If label is empty, use default label '*' const queryLabel = label || '*'; - + try { console.log(`Fetching graph data with label: ${queryLabel}, maxDepth: ${maxDepth}, minDegree: ${minDegree}`); rawData = await queryGraphs(queryLabel, maxDepth, minDegree); @@ -317,33 +317,33 @@ const useLightrangeGraph = () => { if (!data || !data.nodes || data.nodes.length === 0) { // Create a graph with a single "Graph Is Empty" node const emptyGraph = new DirectedGraph(); - + // Add a single node with "Graph Is Empty" label emptyGraph.addNode('empty-graph-node', { label: t('graphPanel.emptyGraph'), color: '#cccccc', // gray color x: 0.5, y: 0.5, - size: 15, + size: 15, borderColor: Constants.nodeBorderColor, borderSize: 0.2 }); - + // Set graph to store state.setSigmaGraph(emptyGraph); state.setRawGraph(null); - + // Still mark graph as empty for other logic state.setGraphIsEmpty(true); - + // Only clear current label if it's not already empty if (currentQueryLabel) { useSettingsStore.getState().setQueryLabel(''); } - + // Clear last successful query label to ensure labels are fetched next time state.setLastSuccessfulQueryLabel(''); - + console.log('Graph data is empty, created graph with empty graph node'); } else { // Create and set new graph @@ -354,13 +354,13 @@ const useLightrangeGraph = () => { state.setSigmaGraph(newSigmaGraph); state.setRawGraph(data); state.setGraphIsEmpty(false); - + // Update last successful query label state.setLastSuccessfulQueryLabel(currentQueryLabel); // Reset camera view state.setMoveToSelectedNode(true); - + console.log('Graph data loaded successfully'); } @@ -369,7 +369,7 @@ const useLightrangeGraph = () => { initialLoadRef.current = true fetchInProgressRef.current = false state.setIsFetching(false) - + // Mark empty data as handled if data is empty and query label is empty if ((!data || !data.nodes || data.nodes.length === 0) && !currentQueryLabel) { emptyDataHandledRef.current = true; @@ -386,7 +386,7 @@ const useLightrangeGraph = () => { state.setLastSuccessfulQueryLabel('') // Clear last successful query label on error }) } - }, [queryLabel, maxQueryDepth, minDegree, isFetching]) + }, [queryLabel, maxQueryDepth, minDegree, isFetching, t]) // Handle node expansion useEffect(() => {