fix existing justification bug
This commit is contained in:
parent
598cc69d38
commit
5707aab6bd
1 changed files with 14 additions and 10 deletions
|
|
@ -1843,9 +1843,10 @@ class LightRAG:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 1. Get current entity information
|
# 1. Get current entity information
|
||||||
node_data = await self.chunk_entity_relation_graph.get_node(entity_name)
|
node_exists = await self.chunk_entity_relation_graph.has_node(entity_name)
|
||||||
if not node_data:
|
if not node_exists:
|
||||||
raise ValueError(f"Entity '{entity_name}' does not exist")
|
raise ValueError(f"Entity '{entity_name}' does not exist")
|
||||||
|
node_data = await self.chunk_entity_relation_graph.get_node(entity_name)
|
||||||
|
|
||||||
# Check if entity is being renamed
|
# Check if entity is being renamed
|
||||||
new_entity_name = updated_data.get("entity_name", entity_name)
|
new_entity_name = updated_data.get("entity_name", entity_name)
|
||||||
|
|
@ -1858,7 +1859,7 @@ class LightRAG:
|
||||||
"Entity renaming is not allowed. Set allow_rename=True to enable this feature"
|
"Entity renaming is not allowed. Set allow_rename=True to enable this feature"
|
||||||
)
|
)
|
||||||
|
|
||||||
existing_node = await self.chunk_entity_relation_graph.get_node(
|
existing_node = await self.chunk_entity_relation_graph.has_node(
|
||||||
new_entity_name
|
new_entity_name
|
||||||
)
|
)
|
||||||
if existing_node:
|
if existing_node:
|
||||||
|
|
@ -2040,14 +2041,16 @@ class LightRAG:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 1. Get current relation information
|
# 1. Get current relation information
|
||||||
edge_data = await self.chunk_entity_relation_graph.get_edge(
|
edge_exists = await self.chunk_entity_relation_graph.has_edge(
|
||||||
source_entity, target_entity
|
source_entity, target_entity
|
||||||
)
|
)
|
||||||
if not edge_data:
|
if not edge_exists:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Relation from '{source_entity}' to '{target_entity}' does not exist"
|
f"Relation from '{source_entity}' to '{target_entity}' does not exist"
|
||||||
)
|
)
|
||||||
|
edge_data = await self.chunk_entity_relation_graph.get_edge(
|
||||||
|
source_entity, target_entity
|
||||||
|
)
|
||||||
# Important: First delete the old relation record from the vector database
|
# Important: First delete the old relation record from the vector database
|
||||||
old_relation_id = compute_mdhash_id(
|
old_relation_id = compute_mdhash_id(
|
||||||
source_entity + target_entity, prefix="rel-"
|
source_entity + target_entity, prefix="rel-"
|
||||||
|
|
@ -2156,7 +2159,7 @@ class LightRAG:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Check if entity already exists
|
# Check if entity already exists
|
||||||
existing_node = await self.chunk_entity_relation_graph.get_node(entity_name)
|
existing_node = await self.chunk_entity_relation_graph.has_node(entity_name)
|
||||||
if existing_node:
|
if existing_node:
|
||||||
raise ValueError(f"Entity '{entity_name}' already exists")
|
raise ValueError(f"Entity '{entity_name}' already exists")
|
||||||
|
|
||||||
|
|
@ -2250,7 +2253,7 @@ class LightRAG:
|
||||||
raise ValueError(f"Target entity '{target_entity}' does not exist")
|
raise ValueError(f"Target entity '{target_entity}' does not exist")
|
||||||
|
|
||||||
# Check if relation already exists
|
# Check if relation already exists
|
||||||
existing_edge = await self.chunk_entity_relation_graph.get_edge(
|
existing_edge = await self.chunk_entity_relation_graph.has_edge(
|
||||||
source_entity, target_entity
|
source_entity, target_entity
|
||||||
)
|
)
|
||||||
if existing_edge:
|
if existing_edge:
|
||||||
|
|
@ -2383,9 +2386,10 @@ class LightRAG:
|
||||||
# 1. Check if all source entities exist
|
# 1. Check if all source entities exist
|
||||||
source_entities_data = {}
|
source_entities_data = {}
|
||||||
for entity_name in source_entities:
|
for entity_name in source_entities:
|
||||||
node_data = await self.chunk_entity_relation_graph.get_node(entity_name)
|
node_exists = await self.chunk_entity_relation_graph.has_node(entity_name)
|
||||||
if not node_data:
|
if not node_exists:
|
||||||
raise ValueError(f"Source entity '{entity_name}' does not exist")
|
raise ValueError(f"Source entity '{entity_name}' does not exist")
|
||||||
|
node_data = await self.chunk_entity_relation_graph.get_node(entity_name)
|
||||||
source_entities_data[entity_name] = node_data
|
source_entities_data[entity_name] = node_data
|
||||||
|
|
||||||
# 2. Check if target entity exists and get its data if it does
|
# 2. Check if target entity exists and get its data if it does
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue