Spaces:
Sleeping
Sleeping
Commit
·
6e8b587
1
Parent(s):
e1c5134
Update app.py
Browse files
app.py
CHANGED
@@ -129,29 +129,37 @@ description = """ PDF GPT allows you to chat with your PDF file using Universal
|
|
129 |
|
130 |
st.markdown(description)
|
131 |
|
132 |
-
openAI_key = st.sidebar.text_input('
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
st.markdown(description)
|
131 |
|
132 |
+
openAI_key = st.sidebar.text_input('API Key', value='sk-')
|
133 |
+
|
134 |
+
add_row = st.sidebar.button("Add row")
|
135 |
+
row_count = st.session_state.get("row_count", 1)
|
136 |
+
|
137 |
+
if add_row:
|
138 |
+
row_count += 1
|
139 |
+
st.session_state.row_count = row_count
|
140 |
+
|
141 |
+
for i in range(row_count):
|
142 |
+
col1, col2, col3, col4 = st.columns(4)
|
143 |
+
|
144 |
+
with col1:
|
145 |
+
url = st.text_input(f'PDF URL {i+1}', key=f'url{i}')
|
146 |
+
with col2:
|
147 |
+
question = st.text_input(f'Question {i+1}', key=f'question{i}')
|
148 |
+
with col3:
|
149 |
+
answer_placeholder = st.empty()
|
150 |
+
answer_placeholder.text_area(f'Answer {i+1}', key=f'answer{i}', value='')
|
151 |
+
with col4:
|
152 |
+
if st.button(f'Submit {i+1}'):
|
153 |
+
if openAI_key.strip()=='':
|
154 |
+
st.error('Please enter you Open AI Key')
|
155 |
+
elif url.strip() == '':
|
156 |
+
st.error('URL field is empty')
|
157 |
+
elif question.strip() == '':
|
158 |
+
st.error('Question field is empty')
|
159 |
+
else:
|
160 |
+
glob_url = url
|
161 |
+
download_pdf(glob_url, 'corpus.pdf')
|
162 |
+
load_recommender('corpus.pdf')
|
163 |
+
|
164 |
+
answer = generate_answer(question,openAI_key)
|
165 |
+
answer_placeholder.text_area(f'Answer {i+1}', key=f'answer{i}', value=answer)
|