Spaces:
Sleeping
Sleeping
Commit
·
590eb55
1
Parent(s):
4731465
Update app.py
Browse files
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 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
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)
|