yangdx
commited on
Commit
·
e70144e
1
Parent(s):
ebd81d2
Fix linting
Browse files
lightrag/lightrag.py
CHANGED
@@ -186,7 +186,9 @@ class LightRAG:
|
|
186 |
embedding_batch_num: int = field(default=int(os.getenv("EMBEDDING_BATCH_NUM", 32)))
|
187 |
"""Batch size for embedding computations."""
|
188 |
|
189 |
-
embedding_func_max_async: int = field(
|
|
|
|
|
190 |
"""Maximum number of concurrent embedding function calls."""
|
191 |
|
192 |
embedding_cache_config: dict[str, Any] = field(
|
|
|
186 |
embedding_batch_num: int = field(default=int(os.getenv("EMBEDDING_BATCH_NUM", 32)))
|
187 |
"""Batch size for embedding computations."""
|
188 |
|
189 |
+
embedding_func_max_async: int = field(
|
190 |
+
default=int(os.getenv("EMBEDDING_FUNC_MAX_ASYNC", 16))
|
191 |
+
)
|
192 |
"""Maximum number of concurrent embedding function calls."""
|
193 |
|
194 |
embedding_cache_config: dict[str, Any] = field(
|
lightrag_webui/src/components/graph/GraphLabels.tsx
CHANGED
@@ -60,13 +60,13 @@ const GraphLabels = () => {
|
|
60 |
// Reset fetch status flags
|
61 |
useGraphStore.getState().setLabelsFetchAttempted(false)
|
62 |
useGraphStore.getState().setGraphDataFetchAttempted(false)
|
63 |
-
|
64 |
// Clear last successful query label to ensure labels are fetched
|
65 |
useGraphStore.getState().setLastSuccessfulQueryLabel('')
|
66 |
-
|
67 |
// Get current label
|
68 |
const currentLabel = useSettingsStore.getState().queryLabel
|
69 |
-
|
70 |
// If current label is empty, use default label '*'
|
71 |
if (!currentLabel) {
|
72 |
useSettingsStore.getState().setQueryLabel('*')
|
@@ -119,7 +119,7 @@ const GraphLabels = () => {
|
|
119 |
|
120 |
// Reset graphDataFetchAttempted flag to ensure data fetch is triggered
|
121 |
useGraphStore.getState().setGraphDataFetchAttempted(false);
|
122 |
-
|
123 |
// Update the label to trigger data loading
|
124 |
useSettingsStore.getState().setQueryLabel(newLabel);
|
125 |
}}
|
|
|
60 |
// Reset fetch status flags
|
61 |
useGraphStore.getState().setLabelsFetchAttempted(false)
|
62 |
useGraphStore.getState().setGraphDataFetchAttempted(false)
|
63 |
+
|
64 |
// Clear last successful query label to ensure labels are fetched
|
65 |
useGraphStore.getState().setLastSuccessfulQueryLabel('')
|
66 |
+
|
67 |
// Get current label
|
68 |
const currentLabel = useSettingsStore.getState().queryLabel
|
69 |
+
|
70 |
// If current label is empty, use default label '*'
|
71 |
if (!currentLabel) {
|
72 |
useSettingsStore.getState().setQueryLabel('*')
|
|
|
119 |
|
120 |
// Reset graphDataFetchAttempted flag to ensure data fetch is triggered
|
121 |
useGraphStore.getState().setGraphDataFetchAttempted(false);
|
122 |
+
|
123 |
// Update the label to trigger data loading
|
124 |
useSettingsStore.getState().setQueryLabel(newLabel);
|
125 |
}}
|
lightrag_webui/src/hooks/useLightragGraph.tsx
CHANGED
@@ -72,7 +72,7 @@ export type EdgeType = { label: string }
|
|
72 |
|
73 |
const fetchGraph = async (label: string, maxDepth: number, minDegree: number) => {
|
74 |
let rawData: any = null;
|
75 |
-
|
76 |
// Check if we need to fetch all database labels first
|
77 |
const lastSuccessfulQueryLabel = useGraphStore.getState().lastSuccessfulQueryLabel;
|
78 |
if (!lastSuccessfulQueryLabel) {
|
@@ -87,7 +87,7 @@ const fetchGraph = async (label: string, maxDepth: number, minDegree: number) =>
|
|
87 |
|
88 |
// If label is empty, use default label '*'
|
89 |
const queryLabel = label || '*';
|
90 |
-
|
91 |
try {
|
92 |
console.log(`Fetching graph data with label: ${queryLabel}, maxDepth: ${maxDepth}, minDegree: ${minDegree}`);
|
93 |
rawData = await queryGraphs(queryLabel, maxDepth, minDegree);
|
@@ -317,33 +317,33 @@ const useLightrangeGraph = () => {
|
|
317 |
if (!data || !data.nodes || data.nodes.length === 0) {
|
318 |
// Create a graph with a single "Graph Is Empty" node
|
319 |
const emptyGraph = new DirectedGraph();
|
320 |
-
|
321 |
// Add a single node with "Graph Is Empty" label
|
322 |
emptyGraph.addNode('empty-graph-node', {
|
323 |
label: t('graphPanel.emptyGraph'),
|
324 |
color: '#cccccc', // gray color
|
325 |
x: 0.5,
|
326 |
y: 0.5,
|
327 |
-
size: 15,
|
328 |
borderColor: Constants.nodeBorderColor,
|
329 |
borderSize: 0.2
|
330 |
});
|
331 |
-
|
332 |
// Set graph to store
|
333 |
state.setSigmaGraph(emptyGraph);
|
334 |
state.setRawGraph(null);
|
335 |
-
|
336 |
// Still mark graph as empty for other logic
|
337 |
state.setGraphIsEmpty(true);
|
338 |
-
|
339 |
// Only clear current label if it's not already empty
|
340 |
if (currentQueryLabel) {
|
341 |
useSettingsStore.getState().setQueryLabel('');
|
342 |
}
|
343 |
-
|
344 |
// Clear last successful query label to ensure labels are fetched next time
|
345 |
state.setLastSuccessfulQueryLabel('');
|
346 |
-
|
347 |
console.log('Graph data is empty, created graph with empty graph node');
|
348 |
} else {
|
349 |
// Create and set new graph
|
@@ -354,13 +354,13 @@ const useLightrangeGraph = () => {
|
|
354 |
state.setSigmaGraph(newSigmaGraph);
|
355 |
state.setRawGraph(data);
|
356 |
state.setGraphIsEmpty(false);
|
357 |
-
|
358 |
// Update last successful query label
|
359 |
state.setLastSuccessfulQueryLabel(currentQueryLabel);
|
360 |
|
361 |
// Reset camera view
|
362 |
state.setMoveToSelectedNode(true);
|
363 |
-
|
364 |
console.log('Graph data loaded successfully');
|
365 |
}
|
366 |
|
@@ -369,7 +369,7 @@ const useLightrangeGraph = () => {
|
|
369 |
initialLoadRef.current = true
|
370 |
fetchInProgressRef.current = false
|
371 |
state.setIsFetching(false)
|
372 |
-
|
373 |
// Mark empty data as handled if data is empty and query label is empty
|
374 |
if ((!data || !data.nodes || data.nodes.length === 0) && !currentQueryLabel) {
|
375 |
emptyDataHandledRef.current = true;
|
@@ -386,7 +386,7 @@ const useLightrangeGraph = () => {
|
|
386 |
state.setLastSuccessfulQueryLabel('') // Clear last successful query label on error
|
387 |
})
|
388 |
}
|
389 |
-
}, [queryLabel, maxQueryDepth, minDegree, isFetching])
|
390 |
|
391 |
// Handle node expansion
|
392 |
useEffect(() => {
|
|
|
72 |
|
73 |
const fetchGraph = async (label: string, maxDepth: number, minDegree: number) => {
|
74 |
let rawData: any = null;
|
75 |
+
|
76 |
// Check if we need to fetch all database labels first
|
77 |
const lastSuccessfulQueryLabel = useGraphStore.getState().lastSuccessfulQueryLabel;
|
78 |
if (!lastSuccessfulQueryLabel) {
|
|
|
87 |
|
88 |
// If label is empty, use default label '*'
|
89 |
const queryLabel = label || '*';
|
90 |
+
|
91 |
try {
|
92 |
console.log(`Fetching graph data with label: ${queryLabel}, maxDepth: ${maxDepth}, minDegree: ${minDegree}`);
|
93 |
rawData = await queryGraphs(queryLabel, maxDepth, minDegree);
|
|
|
317 |
if (!data || !data.nodes || data.nodes.length === 0) {
|
318 |
// Create a graph with a single "Graph Is Empty" node
|
319 |
const emptyGraph = new DirectedGraph();
|
320 |
+
|
321 |
// Add a single node with "Graph Is Empty" label
|
322 |
emptyGraph.addNode('empty-graph-node', {
|
323 |
label: t('graphPanel.emptyGraph'),
|
324 |
color: '#cccccc', // gray color
|
325 |
x: 0.5,
|
326 |
y: 0.5,
|
327 |
+
size: 15,
|
328 |
borderColor: Constants.nodeBorderColor,
|
329 |
borderSize: 0.2
|
330 |
});
|
331 |
+
|
332 |
// Set graph to store
|
333 |
state.setSigmaGraph(emptyGraph);
|
334 |
state.setRawGraph(null);
|
335 |
+
|
336 |
// Still mark graph as empty for other logic
|
337 |
state.setGraphIsEmpty(true);
|
338 |
+
|
339 |
// Only clear current label if it's not already empty
|
340 |
if (currentQueryLabel) {
|
341 |
useSettingsStore.getState().setQueryLabel('');
|
342 |
}
|
343 |
+
|
344 |
// Clear last successful query label to ensure labels are fetched next time
|
345 |
state.setLastSuccessfulQueryLabel('');
|
346 |
+
|
347 |
console.log('Graph data is empty, created graph with empty graph node');
|
348 |
} else {
|
349 |
// Create and set new graph
|
|
|
354 |
state.setSigmaGraph(newSigmaGraph);
|
355 |
state.setRawGraph(data);
|
356 |
state.setGraphIsEmpty(false);
|
357 |
+
|
358 |
// Update last successful query label
|
359 |
state.setLastSuccessfulQueryLabel(currentQueryLabel);
|
360 |
|
361 |
// Reset camera view
|
362 |
state.setMoveToSelectedNode(true);
|
363 |
+
|
364 |
console.log('Graph data loaded successfully');
|
365 |
}
|
366 |
|
|
|
369 |
initialLoadRef.current = true
|
370 |
fetchInProgressRef.current = false
|
371 |
state.setIsFetching(false)
|
372 |
+
|
373 |
// Mark empty data as handled if data is empty and query label is empty
|
374 |
if ((!data || !data.nodes || data.nodes.length === 0) && !currentQueryLabel) {
|
375 |
emptyDataHandledRef.current = true;
|
|
|
386 |
state.setLastSuccessfulQueryLabel('') // Clear last successful query label on error
|
387 |
})
|
388 |
}
|
389 |
+
}, [queryLabel, maxQueryDepth, minDegree, isFetching, t])
|
390 |
|
391 |
// Handle node expansion
|
392 |
useEffect(() => {
|