Spaces:
Sleeping
Sleeping
Update app,py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ from utils import setup_all_auth
|
|
27 |
# Create a placeholder for our initialization message
|
28 |
init_message = st.empty()
|
29 |
|
30 |
-
# Custom
|
31 |
st.markdown("""
|
32 |
<style>
|
33 |
/* Styling for the main title */
|
@@ -38,7 +38,7 @@ st.markdown("""
|
|
38 |
margin-bottom: 1rem;
|
39 |
}
|
40 |
|
41 |
-
/* β
|
42 |
input[type="text"] {
|
43 |
border: 2px solid #4CAF50 !important;
|
44 |
border-radius: 8px !important;
|
@@ -50,17 +50,17 @@ input[type="text"]:focus {
|
|
50 |
border: 2px solid #FF5722 !important;
|
51 |
}
|
52 |
|
53 |
-
/* β
|
54 |
-
.answered
|
55 |
border: 2px solid #4CAF50 !important;
|
56 |
}
|
57 |
|
58 |
-
/* β
|
59 |
.stButton>button {
|
|
|
|
|
60 |
border: 2px solid #4CAF50 !important;
|
61 |
border-radius: 8px !important;
|
62 |
-
color: black !important;
|
63 |
-
background-color: white !important;
|
64 |
}
|
65 |
</style>
|
66 |
<div class="main-title">Indian Spiritual Texts Q&A</div>
|
@@ -106,6 +106,12 @@ def handle_form_submit():
|
|
106 |
st.session_state.query_answered = False # Mark as not yet answered
|
107 |
st.session_state.query_input = "" # Clear input box after submission
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
# β
Create a form for handling user input
|
110 |
with st.form(key="query_form"):
|
111 |
# Input field with dynamic border behavior
|
@@ -119,6 +125,8 @@ with st.form(key="query_form"):
|
|
119 |
# Submit button
|
120 |
submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit)
|
121 |
|
|
|
|
|
122 |
# β
Display the last question after submission
|
123 |
if st.session_state.submit_clicked and st.session_state.last_query:
|
124 |
st.markdown("### Current Question:")
|
@@ -147,6 +155,7 @@ if st.session_state.submit_clicked and st.session_state.last_query:
|
|
147 |
st.write(citation)
|
148 |
|
149 |
st.session_state.query_answered = True # β
Mark query as answered
|
|
|
150 |
|
151 |
except Exception as e:
|
152 |
st.error(f"Error processing query: {str(e)}")
|
|
|
27 |
# Create a placeholder for our initialization message
|
28 |
init_message = st.empty()
|
29 |
|
30 |
+
# β
Custom CSS to handle dynamic text box color change
|
31 |
st.markdown("""
|
32 |
<style>
|
33 |
/* Styling for the main title */
|
|
|
38 |
margin-bottom: 1rem;
|
39 |
}
|
40 |
|
41 |
+
/* β
Green by default */
|
42 |
input[type="text"] {
|
43 |
border: 2px solid #4CAF50 !important;
|
44 |
border-radius: 8px !important;
|
|
|
50 |
border: 2px solid #FF5722 !important;
|
51 |
}
|
52 |
|
53 |
+
/* β
Change back to green AFTER submission */
|
54 |
+
.answered input[type="text"] {
|
55 |
border: 2px solid #4CAF50 !important;
|
56 |
}
|
57 |
|
58 |
+
/* β
FULLY GREEN BUTTON */
|
59 |
.stButton>button {
|
60 |
+
background-color: #4CAF50 !important;
|
61 |
+
color: #E8F5E9 !important;
|
62 |
border: 2px solid #4CAF50 !important;
|
63 |
border-radius: 8px !important;
|
|
|
|
|
64 |
}
|
65 |
</style>
|
66 |
<div class="main-title">Indian Spiritual Texts Q&A</div>
|
|
|
106 |
st.session_state.query_answered = False # Mark as not yet answered
|
107 |
st.session_state.query_input = "" # Clear input box after submission
|
108 |
|
109 |
+
# β
Conditionally apply CSS class based on query answered status
|
110 |
+
input_css_class = "answered" if st.session_state.query_answered else ""
|
111 |
+
|
112 |
+
# β
Wrap the text input inside a div to allow dynamic styling
|
113 |
+
st.markdown(f'<div class="{input_css_class}">', unsafe_allow_html=True)
|
114 |
+
|
115 |
# β
Create a form for handling user input
|
116 |
with st.form(key="query_form"):
|
117 |
# Input field with dynamic border behavior
|
|
|
125 |
# Submit button
|
126 |
submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit)
|
127 |
|
128 |
+
st.markdown("</div>", unsafe_allow_html=True) # β
Close the div for styling
|
129 |
+
|
130 |
# β
Display the last question after submission
|
131 |
if st.session_state.submit_clicked and st.session_state.last_query:
|
132 |
st.markdown("### Current Question:")
|
|
|
155 |
st.write(citation)
|
156 |
|
157 |
st.session_state.query_answered = True # β
Mark query as answered
|
158 |
+
st.rerun() # β
Refresh UI so that text box turns green again
|
159 |
|
160 |
except Exception as e:
|
161 |
st.error(f"Error processing query: {str(e)}")
|