This commit is contained in:
Saifeddine ALOUI
2025-03-05 15:36:47 +01:00
committed by GitHub
parent 39c24f4a59
commit 6e4daea056

View File

@@ -241,6 +241,7 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
if not pm.is_installed("docling"): # type: ignore
pm.install("docling")
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert(file_path)
content = result.document.export_to_markdown()
@@ -259,6 +260,7 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
if not pm.is_installed("docling"): # type: ignore
pm.install("docling")
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert(file_path)
content = result.document.export_to_markdown()
@@ -270,12 +272,15 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
docx_file = BytesIO(file)
doc = Document(docx_file)
content = "\n".join([paragraph.text for paragraph in doc.paragraphs])
content = "\n".join(
[paragraph.text for paragraph in doc.paragraphs]
)
case ".pptx":
if global_args["main_args"].document_loading_tool == "DOCLING":
if not pm.is_installed("docling"): # type: ignore
pm.install("docling")
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert(file_path)
content = result.document.export_to_markdown()
@@ -296,6 +301,7 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
if not pm.is_installed("docling"): # type: ignore
pm.install("docling")
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert(file_path)
content = result.document.export_to_markdown()
@@ -312,7 +318,8 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
for row in sheet.iter_rows(values_only=True):
content += (
"\t".join(
str(cell) if cell is not None else "" for cell in row
str(cell) if cell is not None else ""
for cell in row
)
+ "\n"
)