DrishtiSharma commited on
Commit
4dc4073
Β·
verified Β·
1 Parent(s): 956c481

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -54,8 +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")
58
- if pdf_url and not st.session_state.pdf_path:
 
 
59
  with st.spinner("Downloading PDF..."):
60
  try:
61
  response = requests.get(pdf_url)
@@ -63,9 +65,12 @@ elif pdf_source == "Enter a PDF URL":
63
  st.session_state.pdf_path = "temp.pdf"
64
  with open(st.session_state.pdf_path, "wb") as f:
65
  f.write(response.content)
 
 
66
  st.session_state.pdf_loaded = False
67
  st.session_state.chunked = False
68
  st.session_state.vector_created = False
 
69
  st.success("βœ… PDF Downloaded Successfully!")
70
  else:
71
  st.error("❌ Failed to download PDF. Check the URL.")
 
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)
 
65
  st.session_state.pdf_path = "temp.pdf"
66
  with open(st.session_state.pdf_path, "wb") as f:
67
  f.write(response.content)
68
+
69
+ # Reset states
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:
76
  st.error("❌ Failed to download PDF. Check the URL.")