From d283e2b6a674347c1106d51061ebf340ef6bd17b Mon Sep 17 00:00:00 2001 From: "Tuan Anh Nguyen Dang (Tadashi_Cin)" Date: Tue, 3 Sep 2024 23:15:26 +0700 Subject: [PATCH] feat: add markdown file support (#202) * feat: add support for .md * fix: disable download all on private collection --- flowsettings.py | 4 ++-- libs/kotaemon/kotaemon/indices/ingests/files.py | 3 +++ libs/ktem/ktem/index/file/ui.py | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/flowsettings.py b/flowsettings.py index 4e6b14a6b..cae5c68a0 100644 --- a/flowsettings.py +++ b/flowsettings.py @@ -222,7 +222,7 @@ "config": { "supported_file_types": ( ".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, " - ".pptx, .csv, .html, .mhtml, .txt, .zip" + ".pptx, .csv, .html, .mhtml, .txt, .md, .zip" ), "private": False, }, @@ -233,7 +233,7 @@ "config": { "supported_file_types": ( ".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, " - ".pptx, .csv, .html, .mhtml, .txt, .zip" + ".pptx, .csv, .html, .mhtml, .txt, .md, .zip" ), "private": False, }, diff --git a/libs/kotaemon/kotaemon/indices/ingests/files.py b/libs/kotaemon/kotaemon/indices/ingests/files.py index 7da371373..0176ca8ca 100644 --- a/libs/kotaemon/kotaemon/indices/ingests/files.py +++ b/libs/kotaemon/kotaemon/indices/ingests/files.py @@ -18,6 +18,7 @@ OCRReader, PandasExcelReader, PDFThumbnailReader, + TxtReader, UnstructuredReader, ) @@ -47,6 +48,8 @@ ".tiff": unstructured, ".tif": unstructured, ".pdf": PDFThumbnailReader(), + ".txt": TxtReader(), + ".md": TxtReader(), } diff --git a/libs/ktem/ktem/index/file/ui.py b/libs/ktem/ktem/index/file/ui.py index a639c4321..3315a222e 100644 --- a/libs/ktem/ktem/index/file/ui.py +++ b/libs/ktem/ktem/index/file/ui.py @@ -353,6 +353,9 @@ def download_single_file(self, is_zipped_state, file_id): return not is_zipped_state, new_button def download_all_files(self): + if self._index.config.get("private", False): + raise gr.Error("This feature is not available for private collection.") + zip_files = [] for file_name in os.listdir(flowsettings.KH_CHUNKS_OUTPUT_DIR): zip_files.append(os.path.join(flowsettings.KH_CHUNKS_OUTPUT_DIR, file_name))