File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
context_chat_backend/chain/ingest Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change 1616from odfdo import Document
1717from pandas import read_csv , read_excel
1818from pypdf import PdfReader
19+ from pypdf .errors import FileNotDecryptedError as PdfFileNotDecryptedError
1920from striprtf import striprtf
2021
2122logger = logging .getLogger ('ccb.doc_loader' )
@@ -133,6 +134,9 @@ def decode_source(source: UploadFile) -> str | None:
133134 result = source .file .read ().decode ('utf-8' , 'ignore' )
134135 source .file .close ()
135136 return result
137+ except PdfFileNotDecryptedError :
138+ logger .warning (f'PDF file ({ source .filename } ) is encrypted and cannot be read' )
139+ return None
136140 except Exception :
137141 logger .exception (f'Error decoding source file ({ source .filename } )' , stack_info = True )
138142 return None
Original file line number Diff line number Diff line change 11apscheduler
22chromadb
3+ cryptography
34ctransformers
45epub2txt
56fastapi
You can’t perform that action at this time.
0 commit comments