joshuadunlop commited on
Commit
523de2b
·
1 Parent(s): 76bb384

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -15
app.py CHANGED
@@ -133,29 +133,20 @@ st.markdown(description)
133
  openAI_key = st.sidebar.text_input('Enter your OpenAI API key here')
134
 
135
  url = st.text_input('Enter PDF URL here')
136
- file = st.file_uploader('Upload your PDF/ Research Paper / Book here', type=['pdf'])
137
  question = st.text_input('Enter your question here')
138
 
139
  if st.button('Submit'):
140
  if openAI_key.strip()=='':
141
  st.error('Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys')
142
- elif url.strip() == '' and file == None:
143
- st.error('Both URL and PDF is empty. Provide atleast one.')
144
- elif url.strip() != '' and file != None:
145
- st.error('Both URL and PDF is provided. Please provide only one (eiter URL or PDF).')
146
  elif question.strip() == '':
147
  st.error('Question field is empty')
148
  else:
149
- if url.strip() != '':
150
- glob_url = url
151
- download_pdf(glob_url, 'corpus.pdf')
152
- load_recommender('corpus.pdf')
153
- elif file != None:
154
- old_file_name = file.name
155
- file_name = file.name
156
- file_name = file_name[:-12] + file_name[-4:]
157
- os.rename(old_file_name, file_name)
158
- load_recommender(file_name)
159
 
160
  answer = generate_answer(question,openAI_key)
161
  st.text_area('The answer to your question is :', value=answer, height=200)
 
 
133
  openAI_key = st.sidebar.text_input('Enter your OpenAI API key here')
134
 
135
  url = st.text_input('Enter PDF URL here')
 
136
  question = st.text_input('Enter your question here')
137
 
138
  if st.button('Submit'):
139
  if openAI_key.strip()=='':
140
  st.error('Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys')
141
+ elif url.strip() == '':
142
+ st.error('URL field is empty')
 
 
143
  elif question.strip() == '':
144
  st.error('Question field is empty')
145
  else:
146
+ glob_url = url
147
+ download_pdf(glob_url, 'corpus.pdf')
148
+ load_recommender('corpus.pdf')
 
 
 
 
 
 
 
149
 
150
  answer = generate_answer(question,openAI_key)
151
  st.text_area('The answer to your question is :', value=answer, height=200)
152
+