zrguo commited on
Commit
e6454c7
·
unverified ·
2 Parent(s): 822a4ff decb232

Merge pull request #1050 from danielaskdd/fix-neo4j-duplicate-nodes

Browse files
.gitattributes CHANGED
@@ -1,3 +1,4 @@
 
1
  *.png filter=lfs diff=lfs merge=lfs -text
2
  *.ttf filter=lfs diff=lfs merge=lfs -text
3
  *.ico filter=lfs diff=lfs merge=lfs -text
 
1
+ lightrag/api/webui/** -diff
2
  *.png filter=lfs diff=lfs merge=lfs -text
3
  *.ttf filter=lfs diff=lfs merge=lfs -text
4
  *.ico filter=lfs diff=lfs merge=lfs -text
.pre-commit-config.yaml CHANGED
@@ -3,16 +3,21 @@ repos:
3
  rev: v5.0.0
4
  hooks:
5
  - id: trailing-whitespace
 
6
  - id: end-of-file-fixer
 
7
  - id: requirements-txt-fixer
 
8
 
9
 
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
  rev: v0.6.4
12
  hooks:
13
  - id: ruff-format
 
14
  - id: ruff
15
  args: [--fix, --ignore=E402]
 
16
 
17
 
18
  - repo: https://github.com/mgedmin/check-manifest
@@ -20,3 +25,4 @@ repos:
20
  hooks:
21
  - id: check-manifest
22
  stages: [manual]
 
 
3
  rev: v5.0.0
4
  hooks:
5
  - id: trailing-whitespace
6
+ exclude: ^lightrag/api/webui/
7
  - id: end-of-file-fixer
8
+ exclude: ^lightrag/api/webui/
9
  - id: requirements-txt-fixer
10
+ exclude: ^lightrag/api/webui/
11
 
12
 
13
  - repo: https://github.com/astral-sh/ruff-pre-commit
14
  rev: v0.6.4
15
  hooks:
16
  - id: ruff-format
17
+ exclude: ^lightrag/api/webui/
18
  - id: ruff
19
  args: [--fix, --ignore=E402]
20
+ exclude: ^lightrag/api/webui/
21
 
22
 
23
  - repo: https://github.com/mgedmin/check-manifest
 
25
  hooks:
26
  - id: check-manifest
27
  stages: [manual]
28
+ exclude: ^lightrag/api/webui/
lightrag/api/webui/assets/{index-CJz72b6Q.js → index-BlVvSIic.js} RENAMED
Binary files a/lightrag/api/webui/assets/index-CJz72b6Q.js and b/lightrag/api/webui/assets/index-BlVvSIic.js differ
 
lightrag/api/webui/index.html CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
 
lightrag/kg/neo4j_impl.py CHANGED
@@ -553,18 +553,6 @@ class Neo4JStorage(BaseGraphStorage):
553
  logger.error(f"Error during upsert: {str(e)}")
554
  raise
555
 
556
- @retry(
557
- stop=stop_after_attempt(3),
558
- wait=wait_exponential(multiplier=1, min=4, max=10),
559
- retry=retry_if_exception_type(
560
- (
561
- neo4jExceptions.ServiceUnavailable,
562
- neo4jExceptions.TransientError,
563
- neo4jExceptions.WriteServiceUnavailable,
564
- neo4jExceptions.ClientError,
565
- )
566
- ),
567
- )
568
  @retry(
569
  stop=stop_after_attempt(3),
570
  wait=wait_exponential(multiplier=1, min=4, max=10),
@@ -666,7 +654,7 @@ class Neo4JStorage(BaseGraphStorage):
666
  main_query = """
667
  MATCH (n)
668
  OPTIONAL MATCH (n)-[r]-()
669
- WITH n, count(r) AS degree
670
  WHERE degree >= $min_degree
671
  ORDER BY degree DESC
672
  LIMIT $max_nodes
@@ -703,7 +691,7 @@ class Neo4JStorage(BaseGraphStorage):
703
  WITH start, nodes, relationships
704
  UNWIND nodes AS node
705
  OPTIONAL MATCH (node)-[r]-()
706
- WITH node, count(r) AS degree, start, nodes, relationships
707
  WHERE node = start OR EXISTS((start)--(node)) OR degree >= $min_degree
708
  ORDER BY
709
  CASE
@@ -744,11 +732,7 @@ class Neo4JStorage(BaseGraphStorage):
744
  result.nodes.append(
745
  KnowledgeGraphNode(
746
  id=f"{node_id}",
747
- labels=[
748
- label
749
- for label in node.labels
750
- if label != "base"
751
- ],
752
  properties=dict(node),
753
  )
754
  )
@@ -865,9 +849,7 @@ class Neo4JStorage(BaseGraphStorage):
865
  # Create KnowledgeGraphNode for target
866
  target_node = KnowledgeGraphNode(
867
  id=f"{target_id}",
868
- labels=[
869
- label for label in b_node.labels if label != "base"
870
- ],
871
  properties=dict(b_node.properties),
872
  )
873
 
@@ -907,9 +889,7 @@ class Neo4JStorage(BaseGraphStorage):
907
  # Create initial KnowledgeGraphNode
908
  start_node = KnowledgeGraphNode(
909
  id=f"{node_record['n'].get('entity_id')}",
910
- labels=[
911
- label for label in node_record["n"].labels if label != "base"
912
- ],
913
  properties=dict(node_record["n"].properties),
914
  )
915
  finally:
 
553
  logger.error(f"Error during upsert: {str(e)}")
554
  raise
555
 
 
 
 
 
 
 
 
 
 
 
 
 
556
  @retry(
557
  stop=stop_after_attempt(3),
558
  wait=wait_exponential(multiplier=1, min=4, max=10),
 
654
  main_query = """
655
  MATCH (n)
656
  OPTIONAL MATCH (n)-[r]-()
657
+ WITH n, COALESCE(count(r), 0) AS degree
658
  WHERE degree >= $min_degree
659
  ORDER BY degree DESC
660
  LIMIT $max_nodes
 
691
  WITH start, nodes, relationships
692
  UNWIND nodes AS node
693
  OPTIONAL MATCH (node)-[r]-()
694
+ WITH node, COALESCE(count(r), 0) AS degree, start, nodes, relationships
695
  WHERE node = start OR EXISTS((start)--(node)) OR degree >= $min_degree
696
  ORDER BY
697
  CASE
 
732
  result.nodes.append(
733
  KnowledgeGraphNode(
734
  id=f"{node_id}",
735
+ labels=[node.get("entity_id")],
 
 
 
 
736
  properties=dict(node),
737
  )
738
  )
 
849
  # Create KnowledgeGraphNode for target
850
  target_node = KnowledgeGraphNode(
851
  id=f"{target_id}",
852
+ labels=list(f"{target_id}"),
 
 
853
  properties=dict(b_node.properties),
854
  )
855
 
 
889
  # Create initial KnowledgeGraphNode
890
  start_node = KnowledgeGraphNode(
891
  id=f"{node_record['n'].get('entity_id')}",
892
+ labels=list(f"{node_record['n'].get('entity_id')}"),
 
 
893
  properties=dict(node_record["n"].properties),
894
  )
895
  finally:
lightrag_webui/src/components/graph/PropertiesView.tsx CHANGED
@@ -96,9 +96,9 @@ const refineNodeProperties = (node: RawNodeType): NodeType => {
96
  const neighbour = state.rawGraph.getNode(neighbourId)
97
  if (neighbour) {
98
  relationships.push({
99
- type: isTarget ? 'Target' : 'Source',
100
  id: neighbourId,
101
- label: neighbour.labels.join(', ')
102
  })
103
  }
104
  }
 
96
  const neighbour = state.rawGraph.getNode(neighbourId)
97
  if (neighbour) {
98
  relationships.push({
99
+ type: 'Neighbour',
100
  id: neighbourId,
101
+ label: neighbour.properties['entity_id'] ? neighbour.properties['entity_id'] : neighbour.labels.join(', ')
102
  })
103
  }
104
  }