DrishtiSharma commited on
Commit
5a1233f
Β·
verified Β·
1 Parent(s): 07386f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -18,7 +18,7 @@ rag_llm = ChatGroq(model="mixtral-8x7b-32768")
18
 
19
  st.title("❓")
20
 
21
- # Options for PDF input
22
  pdf_source = st.radio("Upload or provide a link to a PDF:", ["Upload a PDF", "Enter a PDF URL"], index=0)
23
 
24
  if pdf_source == "Upload a PDF":
@@ -31,18 +31,20 @@ if pdf_source == "Upload a PDF":
31
  elif pdf_source == "Enter a PDF URL":
32
  pdf_url = st.text_input("Enter PDF URL:")
33
  if pdf_url:
34
- try:
35
- response = requests.get(pdf_url)
36
- if response.status_code == 200:
37
- with open("temp.pdf", "wb") as f:
38
- f.write(response.content)
39
- pdf_path = "temp.pdf"
40
- st.success("βœ… PDF Downloaded Successfully!")
41
- else:
42
- st.error("❌ Failed to download PDF. Check the URL.")
 
 
 
 
43
  pdf_path = None
44
- except Exception as e:
45
- st.error(f"Error downloading PDF: {e}")
46
- pdf_path = None
47
  else:
48
  pdf_path = None
 
 
18
 
19
  st.title("❓")
20
 
21
+ # Step 1: Choose PDF Source
22
  pdf_source = st.radio("Upload or provide a link to a PDF:", ["Upload a PDF", "Enter a PDF URL"], index=0)
23
 
24
  if pdf_source == "Upload a PDF":
 
31
  elif pdf_source == "Enter a PDF URL":
32
  pdf_url = st.text_input("Enter PDF URL:")
33
  if pdf_url:
34
+ with st.spinner("Downloading PDF..."):
35
+ try:
36
+ response = requests.get(pdf_url)
37
+ if response.status_code == 200:
38
+ with open("temp.pdf", "wb") as f:
39
+ f.write(response.content)
40
+ pdf_path = "temp.pdf"
41
+ st.success("βœ… PDF Downloaded Successfully!")
42
+ else:
43
+ st.error("❌ Failed to download PDF. Check the URL.")
44
+ pdf_path = None
45
+ except Exception as e:
46
+ st.error(f"Error downloading PDF: {e}")
47
  pdf_path = None
 
 
 
48
  else:
49
  pdf_path = None
50
+