Madiharehan commited on
Commit
8d32e6d
1 Parent(s): 7306933

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -53,11 +53,16 @@ def process_single_pdf(file_path):
53
  # Function to load PDFs with progress display
54
  def load_pdfs_with_progress(folder_path):
55
  all_text = ""
 
 
 
 
 
56
  pdf_files = [os.path.join(folder_path, filename) for filename in os.listdir(folder_path) if filename.endswith('.pdf')]
57
  num_files = len(pdf_files)
58
 
59
  if num_files == 0:
60
- st.error("No PDF files found in the specified folder.")
61
  st.session_state['vector_store'] = None
62
  st.session_state['loading'] = False
63
  return
@@ -113,7 +118,9 @@ def main():
113
  # Start loading documents if not already loaded
114
  if 'loading' not in st.session_state or st.session_state['loading']:
115
  st.session_state['loading'] = True
116
- load_pdfs_with_progress('documents1')
 
 
117
 
118
  user_question = st.text_input("Ask a Question:", placeholder="Type your question here...")
119
 
@@ -130,4 +137,3 @@ def main():
130
 
131
  if __name__ == "__main__":
132
  main()
133
-
 
53
  # Function to load PDFs with progress display
54
  def load_pdfs_with_progress(folder_path):
55
  all_text = ""
56
+ # Check if the folder exists before proceeding
57
+ if not os.path.exists(folder_path):
58
+ st.error(f"The folder {folder_path} does not exist.")
59
+ return
60
+
61
  pdf_files = [os.path.join(folder_path, filename) for filename in os.listdir(folder_path) if filename.endswith('.pdf')]
62
  num_files = len(pdf_files)
63
 
64
  if num_files == 0:
65
+ st.error(f"No PDF files found in the folder: {folder_path}")
66
  st.session_state['vector_store'] = None
67
  st.session_state['loading'] = False
68
  return
 
118
  # Start loading documents if not already loaded
119
  if 'loading' not in st.session_state or st.session_state['loading']:
120
  st.session_state['loading'] = True
121
+ # Update folder path for your environment, e.g., 'documents1' should be checked
122
+ folder_path = 'documents1'
123
+ load_pdfs_with_progress(folder_path)
124
 
125
  user_question = st.text_input("Ask a Question:", placeholder="Type your question here...")
126
 
 
137
 
138
  if __name__ == "__main__":
139
  main()