joshuadunlop commited on
Commit
590eb55
·
1 Parent(s): 4731465

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -131,24 +131,27 @@ st.markdown(description)
131
 
132
  openAI_key = st.sidebar.text_input('Enter your OpenAI API key here')
133
 
134
- url = st.text_input('Enter PDF URL here')
135
- question = st.text_input('Enter your question here')
136
-
137
- answer = ''
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() == '':
143
- st.error('URL field is empty')
144
- elif question.strip() == '':
145
- st.error('Question field is empty')
146
- else:
147
- glob_url = url
148
- download_pdf(glob_url, 'corpus.pdf')
149
- load_recommender('corpus.pdf')
150
-
151
- answer = generate_answer(question,openAI_key)
152
-
153
- st.text_area('The answer to your question is :', value=answer, height=200)
154
 
 
 
 
 
131
 
132
  openAI_key = st.sidebar.text_input('Enter your OpenAI API key here')
133
 
134
+ col1, col2, col3, col4 = st.columns(4)
135
+
136
+ with col1:
137
+ url = st.text_input('Enter PDF URL here')
138
+ with col2:
139
+ question = st.text_input('Enter your question here')
140
+ with col3:
141
+ answer = st.text_area('The answer to your question is :', value='', height=80)
142
+ with col4:
143
+ if st.button('Submit'):
144
+ if openAI_key.strip()=='':
145
+ st.error('Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys')
146
+ elif url.strip() == '':
147
+ st.error('URL field is empty')
148
+ elif question.strip() == '':
149
+ st.error('Question field is empty')
150
+ else:
151
+ glob_url = url
152
+ download_pdf(glob_url, 'corpus.pdf')
153
+ load_recommender('corpus.pdf')
154
 
155
+ answer = generate_answer(question,openAI_key)
156
+ # Update the answer text area
157
+ col3.text_area('The answer to your question is :', value=answer, height=200)