DrishtiSharma commited on
Commit
2af0ce8
·
verified ·
1 Parent(s): 08b924e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -251,7 +251,7 @@ if __name__ == "__main__":
251
  )
252
 
253
  # Initialize session state
254
- for key in ["LOADED_PATENT", "pdf_preview", "loaded_pdf_path", "chain", "messages"]:
255
  if key not in st.session_state:
256
  st.session_state[key] = None
257
 
@@ -295,17 +295,22 @@ if __name__ == "__main__":
295
  st.session_state.pdf_preview = None
296
 
297
  # Load the document into the system
 
298
  with st.spinner("🔄 Loading document into the system..."):
299
  try:
300
  st.session_state.chain = load_chain(pdf_path)
301
  st.session_state.LOADED_PATENT = patent_number
302
  st.session_state.loaded_pdf_path = pdf_path
303
  st.session_state.messages = [{"role": "assistant", "content": "Hello! How can I assist you with this patent?"}]
304
- st.success("🚀 Document successfully loaded! You can now start asking questions.")
305
  except Exception as e:
306
  st.error(f"Failed to load the document: {e}")
 
307
  st.stop()
308
 
 
 
 
309
  # Display previous chat messages
310
  if st.session_state.messages:
311
  for message in st.session_state.messages:
 
251
  )
252
 
253
  # Initialize session state
254
+ for key in ["LOADED_PATENT", "pdf_preview", "loaded_pdf_path", "chain", "messages", "loading_complete"]:
255
  if key not in st.session_state:
256
  st.session_state[key] = None
257
 
 
295
  st.session_state.pdf_preview = None
296
 
297
  # Load the document into the system
298
+ st.session_state["loading_complete"] = False
299
  with st.spinner("🔄 Loading document into the system..."):
300
  try:
301
  st.session_state.chain = load_chain(pdf_path)
302
  st.session_state.LOADED_PATENT = patent_number
303
  st.session_state.loaded_pdf_path = pdf_path
304
  st.session_state.messages = [{"role": "assistant", "content": "Hello! How can I assist you with this patent?"}]
305
+ st.session_state["loading_complete"] = True
306
  except Exception as e:
307
  st.error(f"Failed to load the document: {e}")
308
+ st.session_state["loading_complete"] = False
309
  st.stop()
310
 
311
+ if st.session_state["loading_complete"]:
312
+ st.success("🚀 Document successfully loaded! You can now start asking questions.")
313
+
314
  # Display previous chat messages
315
  if st.session_state.messages:
316
  for message in st.session_state.messages: