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