KeshavRa commited on
Commit
5040d0d
·
verified ·
1 Parent(s): c73033b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
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
- textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks)
178
-
179
- df = pd.DataFrame(textify_output)
180
- df.columns = ['context']
181
-
182
- if question_protocol == "":
183
- question_protocol = "Write questions based on the text"
184
- df['questions'] = df.apply(lambda row: get_questions(row['context'], question_protocol), axis=1)
185
-
186
- if answer_protocol == "":
187
- answer_protocol = "Write answers based on the text"
188
- df['answers'] = df.apply(lambda row: get_answers(row, answer_protocol), axis=1)
189
-
190
- df = df.drop('context', axis=1)
 
191
 
192
- csv = df.to_csv(index=False).encode('utf-8')
193
 
194
- st.session_state.error = ""
195
- st.session_state.success = csv
196
- st.session_state.submit = False
197
- st.rerun()
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