yangdx
commited on
Commit
·
e27d1c6
1
Parent(s):
899105a
Fix linting
Browse files
lightrag/api/routers/document_routes.py
CHANGED
@@ -190,9 +190,7 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
|
|
190 |
|
191 |
docx_file = BytesIO(file)
|
192 |
doc = Document(docx_file)
|
193 |
-
content = "\n".join(
|
194 |
-
[paragraph.text for paragraph in doc.paragraphs]
|
195 |
-
)
|
196 |
case ".pptx":
|
197 |
if not pm.is_installed("pptx"):
|
198 |
pm.install("pptx")
|
@@ -232,19 +230,13 @@ async def pipeline_enqueue_file(rag: LightRAG, file_path: Path) -> bool:
|
|
232 |
# Insert into the RAG queue
|
233 |
if content:
|
234 |
await rag.apipeline_enqueue_documents(content)
|
235 |
-
logging.info(
|
236 |
-
f"Successfully fetched and enqueued file: {file_path.name}"
|
237 |
-
)
|
238 |
return True
|
239 |
else:
|
240 |
-
logging.error(
|
241 |
-
f"No content could be extracted from file: {file_path.name}"
|
242 |
-
)
|
243 |
|
244 |
except Exception as e:
|
245 |
-
logging.error(
|
246 |
-
f"Error processing or enqueueing file {file_path.name}: {str(e)}"
|
247 |
-
)
|
248 |
logging.error(traceback.format_exc())
|
249 |
finally:
|
250 |
if file_path.name.startswith(temp_prefix):
|
|
|
190 |
|
191 |
docx_file = BytesIO(file)
|
192 |
doc = Document(docx_file)
|
193 |
+
content = "\n".join([paragraph.text for paragraph in doc.paragraphs])
|
|
|
|
|
194 |
case ".pptx":
|
195 |
if not pm.is_installed("pptx"):
|
196 |
pm.install("pptx")
|
|
|
230 |
# Insert into the RAG queue
|
231 |
if content:
|
232 |
await rag.apipeline_enqueue_documents(content)
|
233 |
+
logging.info(f"Successfully fetched and enqueued file: {file_path.name}")
|
|
|
|
|
234 |
return True
|
235 |
else:
|
236 |
+
logging.error(f"No content could be extracted from file: {file_path.name}")
|
|
|
|
|
237 |
|
238 |
except Exception as e:
|
239 |
+
logging.error(f"Error processing or enqueueing file {file_path.name}: {str(e)}")
|
|
|
|
|
240 |
logging.error(traceback.format_exc())
|
241 |
finally:
|
242 |
if file_path.name.startswith(temp_prefix):
|