Spaces:
Sleeping
Sleeping
Update agents/document_agent.py
Browse files- agents/document_agent.py +6 -3
agents/document_agent.py
CHANGED
|
@@ -253,9 +253,12 @@ class DocumentAgent(BaseAgent):
|
|
| 253 |
text = ""
|
| 254 |
try:
|
| 255 |
self.logger.logger.info("[DocumentAgent] Extracting text using PyMuPDF...")
|
| 256 |
-
with fitz.open(file_name) as doc:
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
| 259 |
if len(text.strip()) < 5:
|
| 260 |
raise ValueError("PyMuPDF extraction too short, switching to PDFPlumber")
|
| 261 |
except Exception as e:
|
|
|
|
| 253 |
text = ""
|
| 254 |
try:
|
| 255 |
self.logger.logger.info("[DocumentAgent] Extracting text using PyMuPDF...")
|
| 256 |
+
# with fitz.open(file_name) as doc:
|
| 257 |
+
# for page in doc:
|
| 258 |
+
# text += page.get_text()
|
| 259 |
+
with pdfplumber.open(file_name) as pdf:
|
| 260 |
+
for page in pdf.pages:
|
| 261 |
+
text += page.extract_text()
|
| 262 |
if len(text.strip()) < 5:
|
| 263 |
raise ValueError("PyMuPDF extraction too short, switching to PDFPlumber")
|
| 264 |
except Exception as e:
|