Merge pull request #1869 from danielaskdd/file_paths
refactor: unify file_path handling across merge and rebuild functions
This commit is contained in:
commit
358fbd689f
1 changed files with 15 additions and 8 deletions
|
|
@ -681,7 +681,13 @@ async def _rebuild_single_entity(
|
||||||
"description": final_description,
|
"description": final_description,
|
||||||
"entity_type": entity_type,
|
"entity_type": entity_type,
|
||||||
"source_id": GRAPH_FIELD_SEP.join(chunk_ids),
|
"source_id": GRAPH_FIELD_SEP.join(chunk_ids),
|
||||||
"file_path": GRAPH_FIELD_SEP.join(file_paths)
|
"file_path": build_file_path(
|
||||||
|
current_entity.get("file_path", "").split(GRAPH_FIELD_SEP)
|
||||||
|
if current_entity.get("file_path")
|
||||||
|
else [],
|
||||||
|
[{"file_path": fp} for fp in file_paths],
|
||||||
|
entity_name,
|
||||||
|
)
|
||||||
if file_paths
|
if file_paths
|
||||||
else current_entity.get("file_path", "unknown_source"),
|
else current_entity.get("file_path", "unknown_source"),
|
||||||
}
|
}
|
||||||
|
|
@ -894,7 +900,13 @@ async def _rebuild_single_relationship(
|
||||||
"keywords": combined_keywords,
|
"keywords": combined_keywords,
|
||||||
"weight": weight,
|
"weight": weight,
|
||||||
"source_id": GRAPH_FIELD_SEP.join(chunk_ids),
|
"source_id": GRAPH_FIELD_SEP.join(chunk_ids),
|
||||||
"file_path": GRAPH_FIELD_SEP.join([fp for fp in file_paths if fp])
|
"file_path": build_file_path(
|
||||||
|
current_relationship.get("file_path", "").split(GRAPH_FIELD_SEP)
|
||||||
|
if current_relationship.get("file_path")
|
||||||
|
else [],
|
||||||
|
[{"file_path": fp} for fp in file_paths if fp],
|
||||||
|
f"{src}-{tgt}",
|
||||||
|
)
|
||||||
if file_paths
|
if file_paths
|
||||||
else current_relationship.get("file_path", "unknown_source"),
|
else current_relationship.get("file_path", "unknown_source"),
|
||||||
}
|
}
|
||||||
|
|
@ -1100,12 +1112,7 @@ async def _merge_edges_then_upsert(
|
||||||
+ already_source_ids
|
+ already_source_ids
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
file_path = GRAPH_FIELD_SEP.join(
|
file_path = build_file_path(already_file_paths, edges_data, f"{src_id}-{tgt_id}")
|
||||||
set(
|
|
||||||
[dp["file_path"] for dp in edges_data if dp.get("file_path")]
|
|
||||||
+ [fp for fp in already_file_paths if fp]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
for need_insert_id in [src_id, tgt_id]:
|
for need_insert_id in [src_id, tgt_id]:
|
||||||
if not (await knowledge_graph_inst.has_node(need_insert_id)):
|
if not (await knowledge_graph_inst.has_node(need_insert_id)):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue