DrishtiSharma commited on
Commit
fff2b0a
Β·
verified Β·
1 Parent(s): 26803b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -54,10 +54,10 @@ if pdf_source == "Upload a PDF file":
54
  st.session_state.vector_created = False
55
 
56
  elif pdf_source == "Enter a PDF URL":
57
- pdf_url = st.text_input("Enter PDF URL:", value="https://arxiv.org/pdf/2406.06998", key="pdf_url")
58
 
59
- # βœ… Button to manually trigger the download
60
- if st.button("Download and Process PDF") or pdf_url.strip() != "" and st.session_state.get("pdf_path") is None:
61
  with st.spinner("Downloading PDF..."):
62
  try:
63
  response = requests.get(pdf_url)
@@ -70,6 +70,7 @@ elif pdf_source == "Enter a PDF URL":
70
  st.session_state.pdf_loaded = False
71
  st.session_state.chunked = False
72
  st.session_state.vector_created = False
 
73
 
74
  st.success("βœ… PDF Downloaded Successfully!")
75
  else:
 
54
  st.session_state.vector_created = False
55
 
56
  elif pdf_source == "Enter a PDF URL":
57
+ pdf_url = st.text_input("Enter PDF URL:", value="https://arxiv.org/pdf/2406.06998", key="pdf_url", on_change=lambda: st.session_state.update(trigger_download=True))
58
 
59
+ # Button OR Enter key will trigger download
60
+ if st.button("Download and Process PDF") or st.session_state.get("trigger_download", False):
61
  with st.spinner("Downloading PDF..."):
62
  try:
63
  response = requests.get(pdf_url)
 
70
  st.session_state.pdf_loaded = False
71
  st.session_state.chunked = False
72
  st.session_state.vector_created = False
73
+ st.session_state.trigger_download = False # Reset trigger
74
 
75
  st.success("βœ… PDF Downloaded Successfully!")
76
  else: