feat: fix delete by document id

This commit is contained in:
Huỳnh Triệu Vĩ
2025-02-27 23:34:57 +07:00
parent 781ce7dfe2
commit 2f7fe5e4b6
2 changed files with 70 additions and 36 deletions

View File

@@ -323,6 +323,7 @@ async def _merge_edges_then_upsert(
tgt_id=tgt_id,
description=description,
keywords=keywords,
source_id=source_id,
)
return edge_data
@@ -548,6 +549,7 @@ async def extract_entities(
compute_mdhash_id(dp["entity_name"], prefix="ent-"): {
"content": dp["entity_name"] + dp["description"],
"entity_name": dp["entity_name"],
"source_id": dp["source_id"],
}
for dp in all_entities_data
}
@@ -558,6 +560,7 @@ async def extract_entities(
compute_mdhash_id(dp["src_id"] + dp["tgt_id"], prefix="rel-"): {
"src_id": dp["src_id"],
"tgt_id": dp["tgt_id"],
"source_id": dp["source_id"],
"content": dp["keywords"]
+ dp["src_id"]
+ dp["tgt_id"]
@@ -1113,7 +1116,7 @@ async def _get_node_data(
len_node_datas = len(node_datas)
node_datas = truncate_list_by_token_size(
node_datas,
key=lambda x: x["description"],
key=lambda x: x["description"] if x["description"] is not None else "",
max_token_size=query_param.max_token_for_local_context,
)
logger.debug(
@@ -1296,7 +1299,7 @@ async def _find_most_related_edges_from_entities(
)
all_edges_data = truncate_list_by_token_size(
all_edges_data,
key=lambda x: x["description"],
key=lambda x: x["description"] if x["description"] is not None else "",
max_token_size=query_param.max_token_for_global_context,
)
@@ -1350,7 +1353,7 @@ async def _get_edge_data(
)
edge_datas = truncate_list_by_token_size(
edge_datas,
key=lambda x: x["description"],
key=lambda x: x["description"] if x["description"] is not None else "",
max_token_size=query_param.max_token_for_global_context,
)
use_entities, use_text_units = await asyncio.gather(
@@ -1454,7 +1457,7 @@ async def _find_most_related_entities_from_relationships(
len_node_datas = len(node_datas)
node_datas = truncate_list_by_token_size(
node_datas,
key=lambda x: x["description"],
key=lambda x: x["description"] if x["description"] is not None else "",
max_token_size=query_param.max_token_for_local_context,
)
logger.debug(