From 99315c48276811d94a6f14dbdf677c6b01cdc64f Mon Sep 17 00:00:00 2001 From: Estelle Scifo Date: Mon, 25 Nov 2024 13:31:33 +0100 Subject: [PATCH] Remove misleading warning about Document node not being created (#218) * Remove misleading warning * Update message --- examples/build_graph/simple_kg_builder_from_text.py | 4 +++- .../experimental/components/lexical_graph.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/build_graph/simple_kg_builder_from_text.py b/examples/build_graph/simple_kg_builder_from_text.py index 2dec770e..67ed6776 100644 --- a/examples/build_graph/simple_kg_builder_from_text.py +++ b/examples/build_graph/simple_kg_builder_from_text.py @@ -3,6 +3,8 @@ This example assumes a Neo4j db is up and running. Update the credentials below if needed. + +NB: when building a KG from text, no 'Document' node is created in the Knowledge Graph. """ import asyncio @@ -21,7 +23,7 @@ # Neo4j db infos URI = "neo4j://localhost:7687" AUTH = ("neo4j", "password") -DATABASE = "newdb" +DATABASE = "neo4j" # Text to process TEXT = """The son of Duke Leto Atreides and the Lady Jessica, Paul is the heir of House Atreides, diff --git a/src/neo4j_graphrag/experimental/components/lexical_graph.py b/src/neo4j_graphrag/experimental/components/lexical_graph.py index d2a63569..92681a8b 100644 --- a/src/neo4j_graphrag/experimental/components/lexical_graph.py +++ b/src/neo4j_graphrag/experimental/components/lexical_graph.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import asyncio -import warnings +import logging from typing import Any, Dict, Optional from pydantic import validate_call @@ -30,6 +30,8 @@ ) from neo4j_graphrag.experimental.pipeline import Component +logger = logging.getLogger(__name__) + class LexicalGraphBuilder(Component): """Builds the lexical graph to be inserted into neo4j. @@ -53,8 +55,9 @@ async def run( document_info: Optional[DocumentInfo] = None, ) -> GraphResult: if document_info is None: - warnings.warn( - "No document metadata provided, the document node won't be created in the lexical graph" + logger.info( + "Document node not created in the lexical graph " + "because no document metadata is provided" ) graph = Neo4jGraph() document_id = None