Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
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 |
-
|
207 |
-
|
208 |
-
submit = st.button("Submit")
|
209 |
-
if submit:
|
210 |
-
st.session_state.submit = True
|
211 |
|
212 |
-
|
213 |
-
if
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
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 |
|