Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,7 @@ if st.session_state.success != None:
|
|
| 140 |
st.rerun()
|
| 141 |
|
| 142 |
if selected_app == "1) Create CSVs":
|
| 143 |
-
if st.session_state.success
|
| 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")
|
|
@@ -168,9 +168,8 @@ if selected_app == "1) Create CSVs":
|
|
| 168 |
]
|
| 169 |
)
|
| 170 |
except:
|
|
|
|
| 171 |
st.session_state.error = "OpenAI API key is invalid"
|
| 172 |
-
st.session_state.success = None
|
| 173 |
-
st.session_state.submit = False
|
| 174 |
st.rerun()
|
| 175 |
|
| 176 |
with st.spinner("Loading, please be patient with us ... 🙏"):
|
|
@@ -190,19 +189,17 @@ if selected_app == "1) Create CSVs":
|
|
| 190 |
df = df.drop('context', axis=1)
|
| 191 |
|
| 192 |
csv = df.to_csv(index=False).encode('utf-8')
|
| 193 |
-
|
| 194 |
-
st.session_state.
|
| 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
|
| 201 |
-
st.session_state.submit = False
|
| 202 |
st.rerun()
|
| 203 |
|
| 204 |
if selected_app == "2) Merge CSVs":
|
| 205 |
-
if st.session_state.success
|
| 206 |
uploaded_files = st.file_uploader("Upload CSV files to merge", accept_multiple_files=True, type="csv")
|
| 207 |
|
| 208 |
submit = st.button("Submit")
|
|
@@ -213,8 +210,6 @@ if selected_app == "2) Merge CSVs":
|
|
| 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.
|
| 218 |
-
st.session_state.submit = False
|
| 219 |
-
st.rerun()
|
| 220 |
-
|
|
|
|
| 140 |
st.rerun()
|
| 141 |
|
| 142 |
if selected_app == "1) Create CSVs":
|
| 143 |
+
if not st.session_state.success:
|
| 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")
|
|
|
|
| 168 |
]
|
| 169 |
)
|
| 170 |
except:
|
| 171 |
+
st.session_state.clear()
|
| 172 |
st.session_state.error = "OpenAI API key is invalid"
|
|
|
|
|
|
|
| 173 |
st.rerun()
|
| 174 |
|
| 175 |
with st.spinner("Loading, please be patient with us ... 🙏"):
|
|
|
|
| 189 |
df = df.drop('context', axis=1)
|
| 190 |
|
| 191 |
csv = df.to_csv(index=False).encode('utf-8')
|
| 192 |
+
|
| 193 |
+
st.session_state.clear()
|
| 194 |
st.session_state.success = csv
|
|
|
|
| 195 |
st.rerun()
|
| 196 |
else:
|
| 197 |
+
st.session_state.clear()
|
| 198 |
st.session_state.error = "Please upload at least 1 PDF"
|
|
|
|
|
|
|
| 199 |
st.rerun()
|
| 200 |
|
| 201 |
if selected_app == "2) Merge CSVs":
|
| 202 |
+
if not st.session_state.success:
|
| 203 |
uploaded_files = st.file_uploader("Upload CSV files to merge", accept_multiple_files=True, type="csv")
|
| 204 |
|
| 205 |
submit = st.button("Submit")
|
|
|
|
| 210 |
if len(uploaded_files) > 1:
|
| 211 |
a = 1
|
| 212 |
else:
|
| 213 |
+
st.session_state.clear()
|
| 214 |
st.session_state.error = "Please upload at least 2 CSVs to merge"
|
| 215 |
+
st.rerun()
|
|
|
|
|
|
|
|
|