Pijush2023 commited on
Commit
740f5fc
·
verified ·
1 Parent(s): af6c182

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1575,6 +1575,8 @@ from datetime import datetime
1575
  from langchain_core.documents import Document
1576
  # Function to process PDF, extract text, split it into chunks, and upload to the vector DB
1577
  def process_pdf(pdf_file,uploaded_documents):
 
 
1578
  with pdfplumber.open(pdf_file) as pdf:
1579
  all_text = ""
1580
  for page in pdf.pages:
@@ -1602,7 +1604,10 @@ def process_pdf(pdf_file,uploaded_documents):
1602
  # Add the record to the global list
1603
  uploaded_documents.append(document_record)
1604
 
1605
- return uploaded_documents, f"Uploaded {len(chunks)} chunks to the vector database."
 
 
 
1606
 
1607
 
1608
 
 
1575
  from langchain_core.documents import Document
1576
  # Function to process PDF, extract text, split it into chunks, and upload to the vector DB
1577
  def process_pdf(pdf_file,uploaded_documents):
1578
+ if pdf_file is None:
1579
+ return uploaded_documents, "No PDF file uploaded."
1580
  with pdfplumber.open(pdf_file) as pdf:
1581
  all_text = ""
1582
  for page in pdf.pages:
 
1604
  # Add the record to the global list
1605
  uploaded_documents.append(document_record)
1606
 
1607
+ # Convert the list of dictionaries into a list of lists for the dataframe
1608
+ table_data = [[doc["Document Name"], doc["Upload Time"], doc["Chunks"], doc["Pinecone Index"]] for doc in uploaded_documents]
1609
+
1610
+ return table_data, f"Uploaded {len(chunks)} chunks to the vector database."
1611
 
1612
 
1613