YanSte commited on
Commit
872fa96
·
1 Parent(s): 38e998f
Files changed (1) hide show
  1. lightrag/operate.py +9 -9
lightrag/operate.py CHANGED
@@ -228,21 +228,21 @@ async def _merge_nodes_then_upsert(
228
  async def _merge_edges_then_upsert(
229
  src_id: str,
230
  tgt_id: str,
231
- edges_data: list[dict[str, Any]],
232
  knowledge_graph_inst: BaseGraphStorage,
233
- global_config: dict[str, str],
234
  ):
235
- already_weights: list[float] = []
236
- already_source_ids: list[str] = []
237
- already_description: list[str] = []
238
- already_keywords: list[str] = []
239
 
240
  if await knowledge_graph_inst.has_edge(src_id, tgt_id):
241
  already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
242
  # Handle the case where get_edge returns None or missing fields
243
  if not already_edge:
244
  return
245
-
246
  # Get weight with default 0.0 if missing
247
  already_weights.append(already_edge.get("weight", 0.0))
248
 
@@ -254,11 +254,11 @@ async def _merge_edges_then_upsert(
254
  )
255
  )
256
 
257
- # Get description with empty string default if missing or None
258
  if "description" in already_edge and already_edge["description"] is not None:
259
  already_description.append(already_edge["description"])
260
 
261
- # Get keywords with empty string default if missing or None
262
  if "keywords" in already_edge and already_edge["keywords"] is not None:
263
  already_keywords.extend(
264
  split_string_by_multi_markers(
 
228
  async def _merge_edges_then_upsert(
229
  src_id: str,
230
  tgt_id: str,
231
+ edges_data: list[dict],
232
  knowledge_graph_inst: BaseGraphStorage,
233
+ global_config: dict,
234
  ):
235
+ already_weights = []
236
+ already_source_ids = []
237
+ already_description = []
238
+ already_keywords = []
239
 
240
  if await knowledge_graph_inst.has_edge(src_id, tgt_id):
241
  already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
242
  # Handle the case where get_edge returns None or missing fields
243
  if not already_edge:
244
  return
245
+
246
  # Get weight with default 0.0 if missing
247
  already_weights.append(already_edge.get("weight", 0.0))
248
 
 
254
  )
255
  )
256
 
257
+ # Get description with empty string default if missing or None
258
  if "description" in already_edge and already_edge["description"] is not None:
259
  already_description.append(already_edge["description"])
260
 
261
+ # Get keywords with empty string default if missing or None
262
  if "keywords" in already_edge and already_edge["keywords"] is not None:
263
  already_keywords.extend(
264
  split_string_by_multi_markers(