fixed edge
This commit is contained in:
@@ -117,6 +117,7 @@ class MongoKVStorage(BaseKVStorage):
|
|||||||
# Mongo handles persistence automatically
|
# Mongo handles persistence automatically
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@dataclass
|
@dataclass
|
||||||
class MongoDocStatusStorage(DocStatusStorage):
|
class MongoDocStatusStorage(DocStatusStorage):
|
||||||
|
@@ -320,6 +320,7 @@ class OracleKVStorage(BaseKVStorage):
|
|||||||
# Oracle handles persistence automatically
|
# Oracle handles persistence automatically
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@dataclass
|
@dataclass
|
||||||
class OracleVectorDBStorage(BaseVectorStorage):
|
class OracleVectorDBStorage(BaseVectorStorage):
|
||||||
|
@@ -301,6 +301,7 @@ class PGKVStorage(BaseKVStorage):
|
|||||||
# PG handles persistence automatically
|
# PG handles persistence automatically
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@dataclass
|
@dataclass
|
||||||
class PGVectorStorage(BaseVectorStorage):
|
class PGVectorStorage(BaseVectorStorage):
|
||||||
|
@@ -214,6 +214,7 @@ class TiDBKVStorage(BaseKVStorage):
|
|||||||
# Ti handles persistence automatically
|
# Ti handles persistence automatically
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@dataclass
|
@dataclass
|
||||||
class TiDBVectorDBStorage(BaseVectorStorage):
|
class TiDBVectorDBStorage(BaseVectorStorage):
|
||||||
|
@@ -228,27 +228,23 @@ async def _merge_nodes_then_upsert(
|
|||||||
async def _merge_edges_then_upsert(
|
async def _merge_edges_then_upsert(
|
||||||
src_id: str,
|
src_id: str,
|
||||||
tgt_id: str,
|
tgt_id: str,
|
||||||
edges_data: list[dict],
|
edges_data: list[dict[str, Any]],
|
||||||
knowledge_graph_inst: BaseGraphStorage,
|
knowledge_graph_inst: BaseGraphStorage,
|
||||||
global_config: dict,
|
global_config: dict[str, str],
|
||||||
):
|
):
|
||||||
already_weights = []
|
already_weights: list[float] = []
|
||||||
already_source_ids = []
|
already_source_ids: list[str] = []
|
||||||
already_description = []
|
already_description: list[str] = []
|
||||||
already_keywords = []
|
already_keywords: list[str] = []
|
||||||
|
|
||||||
if await knowledge_graph_inst.has_edge(src_id, tgt_id):
|
if await knowledge_graph_inst.has_edge(src_id, tgt_id):
|
||||||
already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
|
already_edge = await knowledge_graph_inst.get_edge(src_id, tgt_id)
|
||||||
|
# Handle the case where get_edge returns None or missing fields
|
||||||
if not already_edge:
|
if not already_edge:
|
||||||
return
|
return
|
||||||
# Handle the case where get_edge returns None or missing fields
|
|
||||||
|
|
||||||
# Get weight with default 0.0 if missing
|
# Get weight with default 0.0 if missing
|
||||||
if "weight" in already_edge:
|
already_weights.append(already_edge.get("weight", 0.0))
|
||||||
already_weights.append(already_edge["weight"])
|
|
||||||
else:
|
|
||||||
logger.warning(f"Edge between {src_id} and {tgt_id} missing weight field")
|
|
||||||
already_weights.append(0.0)
|
|
||||||
|
|
||||||
# Get source_id with empty string default if missing or None
|
# Get source_id with empty string default if missing or None
|
||||||
if "source_id" in already_edge and already_edge["source_id"] is not None:
|
if "source_id" in already_edge and already_edge["source_id"] is not None:
|
||||||
|
Reference in New Issue
Block a user