KeshavRa commited on
Commit
6117d34
·
verified ·
1 Parent(s): 4f4ce1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -117,30 +117,30 @@ if 'last_selected_app' in st.session_state:
117
 
118
  st.session_state.last_selected_app = selected_app
119
 
120
- if selected_app == "1) Create CSVs":
121
- if 'submit' not in st.session_state:
122
- st.session_state.submit = False
123
- if 'error' not in st.session_state:
124
- st.session_state.error = ""
125
- if 'success' not in st.session_state:
126
- st.session_state.success = None
127
-
128
- if st.session_state.error != "":
129
- st.error(st.session_state.error)
130
-
131
- if st.session_state.success != None:
132
- st.success("Success! Download the Q/A pairs below / Click reset to upload more PDFs")
133
- st.download_button(
134
- label="Download CSV",
135
- data=st.session_state.success,
136
- file_name='questions_answers.csv',
137
- mime='text/csv',
138
- )
139
- if st.button('Reset'):
140
- st.session_state.clear()
141
- st.rerun()
142
-
143
- else:
144
  uploaded_files = st.file_uploader("Upload PDFs Here", type="pdf", accept_multiple_files=True)
145
 
146
  question_protocol = st.text_input("Provide instructions for how questions should be generated", "Write a question based on the text")
@@ -151,7 +151,6 @@ if selected_app == "1) Create CSVs":
151
  openai_api_key = st.text_input("Enter your OpenAI API key", type="password")
152
 
153
  submit = st.button("Submit")
154
-
155
  if submit:
156
  st.session_state.submit = True
157
 
@@ -203,18 +202,19 @@ if selected_app == "1) Create CSVs":
203
  st.rerun()
204
 
205
  if selected_app == "2) Merge CSVs":
206
- uploaded_files = st.file_uploader("Upload CSV files to merge", accept_multiple_files=True, type="csv")
207
-
208
- submit = st.button("Submit")
209
- if submit:
210
- st.session_state.submit = True
211
 
212
- if st.session_state.submit:
213
- if len(uploaded_files) > 1:
214
- a = 1
215
- else:
216
- st.session_state.error = "Please upload at least 2 CSVs to merge"
217
- st.session_state.success = None
218
- st.session_state.submit = False
219
- st.rerun()
 
 
 
 
220
 
 
117
 
118
  st.session_state.last_selected_app = selected_app
119
 
120
+ if 'submit' not in st.session_state:
121
+ st.session_state.submit = False
122
+ if 'error' not in st.session_state:
123
+ st.session_state.error = ""
124
+ if 'success' not in st.session_state:
125
+ st.session_state.success = None
126
+
127
+ if st.session_state.error != "":
128
+ st.error(st.session_state.error)
129
+
130
+ if st.session_state.success != None:
131
+ st.success("Success! Download the Q/A pairs below / Click reset to upload more PDFs")
132
+ st.download_button(
133
+ label="Download CSV",
134
+ data=st.session_state.success,
135
+ file_name='questions_answers.csv',
136
+ mime='text/csv',
137
+ )
138
+ if st.button('Reset'):
139
+ st.session_state.clear()
140
+ st.rerun()
141
+
142
+ if selected_app == "1) Create CSVs":
143
+ if st.session_state.success == None:
144
  uploaded_files = st.file_uploader("Upload PDFs Here", type="pdf", accept_multiple_files=True)
145
 
146
  question_protocol = st.text_input("Provide instructions for how questions should be generated", "Write a question based on the text")
 
151
  openai_api_key = st.text_input("Enter your OpenAI API key", type="password")
152
 
153
  submit = st.button("Submit")
 
154
  if submit:
155
  st.session_state.submit = True
156
 
 
202
  st.rerun()
203
 
204
  if selected_app == "2) Merge CSVs":
205
+ if st.session_state.success == None:
206
+ uploaded_files = st.file_uploader("Upload CSV files to merge", accept_multiple_files=True, type="csv")
 
 
 
207
 
208
+ submit = st.button("Submit")
209
+ if submit:
210
+ st.session_state.submit = True
211
+
212
+ if st.session_state.submit:
213
+ if len(uploaded_files) > 1:
214
+ a = 1
215
+ else:
216
+ st.session_state.error = "Please upload at least 2 CSVs to merge"
217
+ st.session_state.success = None
218
+ st.session_state.submit = False
219
+ st.rerun()
220