Samarth991 commited on
Commit
a1c0614
·
verified ·
1 Parent(s): 03c9778

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  from QA_Bot import QA_Bot
3
  from PDF_Reader import PDF_4_QA
4
  from PIL import Image
 
5
 
6
  # Streamlit app
7
  def main():
@@ -14,6 +15,7 @@ def main():
14
 
15
  st.sidebar.title("Upload PDF")
16
  st.sidebar.write("Download Demo PDF file from Below....")
 
17
  with open("docs/SamarthTandon_cv_2.pdf", "rb") as file:
18
  btn = st.sidebar.download_button(
19
  label="Download PDF",
@@ -22,7 +24,12 @@ def main():
22
  )
23
 
24
  uploaded_file = st.sidebar.file_uploader("Choose a PDF file", type="pdf")
25
-
 
 
 
 
 
26
  api_input = st.sidebar.text_input(
27
  "Enter The API KEY 👇",
28
  label_visibility=st.session_state.visibility,
@@ -30,12 +37,13 @@ def main():
30
  type="password"
31
  )
32
 
33
- # if uploaded_file is not None:
34
- # st.sidebar.success("File uploaded successfully.")
35
- # print(uploaded_file)
36
- # vector_store = PDF_4_QA(uploaded_file)
37
- # QA_Bot(vector_store,api_input)
38
- # else:
 
39
  vector_store = PDF_4_QA("docs/SamarthTandon_cv_2.pdf")
40
  QA_Bot(vector_store,api_input)
41
 
 
2
  from QA_Bot import QA_Bot
3
  from PDF_Reader import PDF_4_QA
4
  from PIL import Image
5
+ from pathlib import Path
6
 
7
  # Streamlit app
8
  def main():
 
15
 
16
  st.sidebar.title("Upload PDF")
17
  st.sidebar.write("Download Demo PDF file from Below....")
18
+
19
  with open("docs/SamarthTandon_cv_2.pdf", "rb") as file:
20
  btn = st.sidebar.download_button(
21
  label="Download PDF",
 
24
  )
25
 
26
  uploaded_file = st.sidebar.file_uploader("Choose a PDF file", type="pdf")
27
+ save_folder = 'docs/'
28
+ save_path = Path(save_folder, File.name)
29
+ print(save_path)
30
+ with open(save_path, mode='wb') as w:
31
+ w.write(uploaded_file.getvalue())
32
+
33
  api_input = st.sidebar.text_input(
34
  "Enter The API KEY 👇",
35
  label_visibility=st.session_state.visibility,
 
37
  type="password"
38
  )
39
 
40
+ if uploaded_file is not None:
41
+ st.sidebar.success("File uploaded successfully.")
42
+ print(save_path)
43
+ vector_store = PDF_4_QA(save_path)
44
+ QA_Bot(vector_store,api_input)
45
+
46
+ else:
47
  vector_store = PDF_4_QA("docs/SamarthTandon_cv_2.pdf")
48
  QA_Bot(vector_store,api_input)
49