Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,15 @@ from langchain.chains.question_answering import load_qa_chain
|
|
| 9 |
from langchain.llms import OpenAI
|
| 10 |
import time
|
| 11 |
import logging
|
|
|
|
| 12 |
import os
|
| 13 |
|
| 14 |
def process_pdf(pdf):
|
| 15 |
start_time = time.time()
|
| 16 |
-
pdf_reader = PdfReader(pdf)
|
| 17 |
text = ""
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
end_time = time.time()
|
| 21 |
logging.info(f"Processed PDF in {end_time - start_time} seconds")
|
| 22 |
return text
|
|
@@ -61,7 +62,7 @@ def main():
|
|
| 61 |
st.sidebar.write("Need assistance? Reach out to our support team.")
|
| 62 |
|
| 63 |
# Footer
|
| 64 |
-
st.sidebar.text("© 2024
|
| 65 |
|
| 66 |
# Logging and exception handling remain the same
|
| 67 |
|
|
|
|
| 9 |
from langchain.llms import OpenAI
|
| 10 |
import time
|
| 11 |
import logging
|
| 12 |
+
import pdfplumber
|
| 13 |
import os
|
| 14 |
|
| 15 |
def process_pdf(pdf):
|
| 16 |
start_time = time.time()
|
|
|
|
| 17 |
text = ""
|
| 18 |
+
with pdfplumber.open(pdf) as pdf_reader:
|
| 19 |
+
for page in pdf_reader.pages:
|
| 20 |
+
text += page.extract_text() or ""
|
| 21 |
end_time = time.time()
|
| 22 |
logging.info(f"Processed PDF in {end_time - start_time} seconds")
|
| 23 |
return text
|
|
|
|
| 62 |
st.sidebar.write("Need assistance? Reach out to our support team.")
|
| 63 |
|
| 64 |
# Footer
|
| 65 |
+
st.sidebar.text("© 2024 MosaicAI")
|
| 66 |
|
| 67 |
# Logging and exception handling remain the same
|
| 68 |
|