From 5d86ad6961795edb71c5cee555b76b307da2b9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nielson=20Jann=C3=A9?= Date: Fri, 28 Mar 2025 18:56:01 +0100 Subject: [PATCH] Add logging warning when no page number is found --- generic_rag/graphs/ret_gen.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/generic_rag/graphs/ret_gen.py b/generic_rag/graphs/ret_gen.py index b3c97f4..c30d6e2 100644 --- a/generic_rag/graphs/ret_gen.py +++ b/generic_rag/graphs/ret_gen.py @@ -1,3 +1,4 @@ +import logging from pathlib import Path from typing import Any, Union @@ -7,6 +8,9 @@ from langgraph.checkpoint.memory import MemorySaver from langgraph.graph import END, START, StateGraph from typing_extensions import List, TypedDict +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + class State(TypedDict): question: str @@ -79,6 +83,9 @@ class RetGenLangGraph: else: pdf_sources[source].add(page_number) + if len(pdf_sources[source]) == 0: + logging.warning(f"PDF source {source} has no page number. Please check the metadata of the document.") + return pdf_sources def get_last_web_sources(self) -> set: