Spaces:
Sleeping
Sleeping
Commit
·
b7a27fc
1
Parent(s):
0be1b9d
Hide loan application form automatically
Browse files
app.py
CHANGED
|
@@ -92,6 +92,10 @@ with st.sidebar:
|
|
| 92 |
client = Client(**client_options)
|
| 93 |
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
def submit_and_clear():
|
| 96 |
try:
|
| 97 |
# Call the explain endpoint as it also includes the prediction
|
|
@@ -102,6 +106,7 @@ def submit_and_clear():
|
|
| 102 |
st.session_state.eval_selected = False
|
| 103 |
st.session_state.predict_button_clicked = False
|
| 104 |
st.session_state.eval_selected = False
|
|
|
|
| 105 |
except Exception as e:
|
| 106 |
logging.error(e)
|
| 107 |
st.error(
|
|
@@ -112,9 +117,15 @@ def submit_and_clear():
|
|
| 112 |
st.toast(f"Failed to submit feedback: {e}")
|
| 113 |
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
# Attributes
|
| 116 |
st.subheader("Loan Application")
|
| 117 |
-
with st.expander("Application form", expanded=
|
| 118 |
# Split view in 2 columns
|
| 119 |
col1, col2 = st.columns(2)
|
| 120 |
with col1:
|
|
@@ -194,7 +205,7 @@ if "predict_button_clicked" not in st.session_state:
|
|
| 194 |
st.session_state.predict_button_clicked = False
|
| 195 |
if deployment_token != "my-secret-token":
|
| 196 |
predict_button = st.button(
|
| 197 |
-
"Predict", key="predict_button", help="Click to get the AI prediction."
|
| 198 |
)
|
| 199 |
if predict_button:
|
| 200 |
st.session_state.predict_button_clicked = True
|
|
|
|
| 92 |
client = Client(**client_options)
|
| 93 |
|
| 94 |
|
| 95 |
+
if "expander_toggle" not in st.session_state:
|
| 96 |
+
st.session_state.expander_toggle = True
|
| 97 |
+
|
| 98 |
+
|
| 99 |
def submit_and_clear():
|
| 100 |
try:
|
| 101 |
# Call the explain endpoint as it also includes the prediction
|
|
|
|
| 106 |
st.session_state.eval_selected = False
|
| 107 |
st.session_state.predict_button_clicked = False
|
| 108 |
st.session_state.eval_selected = False
|
| 109 |
+
show_expander()
|
| 110 |
except Exception as e:
|
| 111 |
logging.error(e)
|
| 112 |
st.error(
|
|
|
|
| 117 |
st.toast(f"Failed to submit feedback: {e}")
|
| 118 |
|
| 119 |
|
| 120 |
+
def hide_expander():
|
| 121 |
+
st.session_state.expander_toggle = False
|
| 122 |
+
|
| 123 |
+
def show_expander():
|
| 124 |
+
st.session_state.expander_toggle = True
|
| 125 |
+
|
| 126 |
# Attributes
|
| 127 |
st.subheader("Loan Application")
|
| 128 |
+
with st.expander("Application form", expanded=st.session_state.expander_toggle):
|
| 129 |
# Split view in 2 columns
|
| 130 |
col1, col2 = st.columns(2)
|
| 131 |
with col1:
|
|
|
|
| 205 |
st.session_state.predict_button_clicked = False
|
| 206 |
if deployment_token != "my-secret-token":
|
| 207 |
predict_button = st.button(
|
| 208 |
+
"Predict", key="predict_button", help="Click to get the AI prediction.", on_click=hide_expander
|
| 209 |
)
|
| 210 |
if predict_button:
|
| 211 |
st.session_state.predict_button_clicked = True
|