From 6e3b23069c0a76a5bfa7e27189faac57ff7d0691 Mon Sep 17 00:00:00 2001 From: yangdx Date: Fri, 7 Mar 2025 16:43:18 +0800 Subject: [PATCH] - Remove useless `_label_exists` method --- lightrag/kg/neo4j_impl.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index fec39138..2498341d 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -164,23 +164,13 @@ class Neo4JStorage(BaseGraphStorage): # Noe4J handles persistence automatically pass - async def _label_exists(self, label: str) -> bool: - """Check if a label exists in the Neo4j database.""" - query = "CALL db.labels() YIELD label RETURN label" - try: - async with self._driver.session(database=self._DATABASE) as session: - result = await session.run(query) - labels = [record["label"] for record in await result.data()] - return label in labels - except Exception as e: - logger.error(f"Error checking label existence: {e}") - return False - async def _ensure_label(self, label: str) -> str: - """Ensure a label exists by validating it.""" + """Ensure a label is valid + + Args: + label: The label to validate + """ clean_label = label.strip('"') - if not await self._label_exists(clean_label): - logger.warning(f"Label '{clean_label}' does not exist in Neo4j") return clean_label async def has_node(self, node_id: str) -> bool: @@ -290,7 +280,7 @@ class Neo4JStorage(BaseGraphStorage): if record: try: result = dict(record["edge_properties"]) - logger.info(f"Result: {result}") + logger.debug(f"Result: {result}") # Ensure required keys exist with defaults required_keys = { "weight": 0.0,