Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -173,28 +173,29 @@ if selected_app == "1) Create CSVs":
|
|
173 |
st.session_state.success = None
|
174 |
st.session_state.submit = False
|
175 |
st.rerun()
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
question_protocol
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
answer_protocol
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
191 |
|
192 |
-
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
else:
|
199 |
st.session_state.error = "Please upload at least 1 PDF"
|
200 |
st.session_state.success = None
|
|
|
173 |
st.session_state.success = None
|
174 |
st.session_state.submit = False
|
175 |
st.rerun()
|
176 |
+
|
177 |
+
with st.spinner("Loading, please be patient with us ... 🙏"):
|
178 |
+
textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks)
|
179 |
+
|
180 |
+
df = pd.DataFrame(textify_output)
|
181 |
+
df.columns = ['context']
|
182 |
+
|
183 |
+
if question_protocol == "":
|
184 |
+
question_protocol = "Write questions based on the text"
|
185 |
+
df['questions'] = df.apply(lambda row: get_questions(row['context'], question_protocol), axis=1)
|
186 |
+
|
187 |
+
if answer_protocol == "":
|
188 |
+
answer_protocol = "Write answers based on the text"
|
189 |
+
df['answers'] = df.apply(lambda row: get_answers(row, answer_protocol), axis=1)
|
190 |
+
|
191 |
+
df = df.drop('context', axis=1)
|
192 |
|
193 |
+
csv = df.to_csv(index=False).encode('utf-8')
|
194 |
|
195 |
+
st.session_state.error = ""
|
196 |
+
st.session_state.success = csv
|
197 |
+
st.session_state.submit = False
|
198 |
+
st.rerun()
|
199 |
else:
|
200 |
st.session_state.error = "Please upload at least 1 PDF"
|
201 |
st.session_state.success = None
|