From 2ea8a832a0ac46c38aac59ede51526ec9b2dd5c5 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 11 Feb 2024 20:40:31 +0530 Subject: [PATCH] Log error when fail to index md file. Fix, improve typing in md_to_entries --- .../processor/content/markdown/markdown_to_entries.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/khoj/processor/content/markdown/markdown_to_entries.py b/src/khoj/processor/content/markdown/markdown_to_entries.py index e36d5ee1..300b543e 100644 --- a/src/khoj/processor/content/markdown/markdown_to_entries.py +++ b/src/khoj/processor/content/markdown/markdown_to_entries.py @@ -58,7 +58,7 @@ class MarkdownToEntries(TextToEntries): def extract_markdown_entries(markdown_files, max_tokens=256) -> List[Entry]: "Extract entries by heading from specified Markdown files" entries: List[str] = [] - entry_to_file_map: List[Tuple[str, Path]] = [] + entry_to_file_map: List[Tuple[str, str]] = [] for markdown_file in markdown_files: try: markdown_content = markdown_files[markdown_file] @@ -66,7 +66,7 @@ class MarkdownToEntries(TextToEntries): markdown_content, markdown_file, entries, entry_to_file_map, max_tokens ) except Exception as e: - logger.warning( + logger.error( f"Unable to process file: {markdown_file}. This file will not be indexed.\n{e}", exc_info=True ) @@ -75,12 +75,12 @@ class MarkdownToEntries(TextToEntries): @staticmethod def process_single_markdown_file( markdown_content: str, - markdown_file: Path, + markdown_file: str, entries: List[str], - entry_to_file_map: List[Tuple[str, Path]], + entry_to_file_map: List[Tuple[str, str]], max_tokens=256, ancestry: Dict[int, str] = {}, - ): + ) -> Tuple[List[str], List[Tuple[str, str]]]: # Prepend the markdown section's heading ancestry ancestry_string = "\n".join([f"{'#' * key} {ancestry[key]}" for key in sorted(ancestry.keys())]) markdown_content_with_ancestry = f"{ancestry_string}{markdown_content}"