Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,10 +29,6 @@ st.markdown("""
|
|
29 |
border: 2px solid #FF5722;
|
30 |
border-radius: 8px;
|
31 |
}
|
32 |
-
.input-style {
|
33 |
-
border: 2px solid #4CAF50;
|
34 |
-
border-radius: 8px;
|
35 |
-
}
|
36 |
.stButton>button {
|
37 |
border: 2px solid #FF5722 !important;
|
38 |
border-radius: 8px !important;
|
@@ -42,29 +38,42 @@ st.markdown("""
|
|
42 |
border: 2px solid #4CAF50 !important;
|
43 |
border-radius: 8px !important;
|
44 |
}
|
45 |
-
/* Style for active input (red) - will be applied with JavaScript */
|
46 |
</style>
|
47 |
|
48 |
<script>
|
49 |
document.addEventListener('DOMContentLoaded', function() {
|
50 |
-
//
|
51 |
-
|
52 |
-
|
53 |
-
if (inputElement) {
|
54 |
-
// Add event listeners
|
55 |
-
inputElement.addEventListener('focus', function() {
|
56 |
-
this.style.border = '2px solid #FF5722 !important';
|
57 |
-
});
|
58 |
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
});
|
62 |
-
|
63 |
-
// Set initial state
|
64 |
-
if (document.activeElement === inputElement) {
|
65 |
-
inputElement.style.border = '2px solid #FF5722 !important';
|
66 |
-
}
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
});
|
69 |
</script>
|
70 |
|
@@ -115,25 +124,6 @@ query = st.text_input(
|
|
115 |
on_change=process_input
|
116 |
)
|
117 |
|
118 |
-
# Add JavaScript to change input border color
|
119 |
-
st.markdown("""
|
120 |
-
<script>
|
121 |
-
// Get the input element
|
122 |
-
const inputElement = document.querySelector('.stTextInput input');
|
123 |
-
|
124 |
-
// Add event listeners for focus and blur
|
125 |
-
if (inputElement) {
|
126 |
-
inputElement.addEventListener('focus', function() {
|
127 |
-
this.style.borderColor = '#FF5722';
|
128 |
-
});
|
129 |
-
|
130 |
-
inputElement.addEventListener('blur', function() {
|
131 |
-
this.style.borderColor = '#4CAF50';
|
132 |
-
});
|
133 |
-
}
|
134 |
-
</script>
|
135 |
-
""", unsafe_allow_html=True)
|
136 |
-
|
137 |
# Display the current question if there is one
|
138 |
if st.session_state.last_query:
|
139 |
st.markdown("### Current Question:")
|
@@ -170,6 +160,6 @@ if st.button("Get Answer") or st.session_state.submit_clicked:
|
|
170 |
st.markdown("---")
|
171 |
st.markdown("""
|
172 |
### About this app
|
173 |
-
This application uses a Retrieval-Augmented Generation (RAG) system to answer questions about
|
174 |
It searches through a database of texts to find relevant passages and generates answers based on those passages.
|
175 |
""")
|
|
|
29 |
border: 2px solid #FF5722;
|
30 |
border-radius: 8px;
|
31 |
}
|
|
|
|
|
|
|
|
|
32 |
.stButton>button {
|
33 |
border: 2px solid #FF5722 !important;
|
34 |
border-radius: 8px !important;
|
|
|
38 |
border: 2px solid #4CAF50 !important;
|
39 |
border-radius: 8px !important;
|
40 |
}
|
|
|
41 |
</style>
|
42 |
|
43 |
<script>
|
44 |
document.addEventListener('DOMContentLoaded', function() {
|
45 |
+
// Function to apply focus styles
|
46 |
+
function applyFocusStyles() {
|
47 |
+
const inputElements = document.querySelectorAll('.stTextInput input');
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
inputElements.forEach(function(input) {
|
50 |
+
// Add focus event
|
51 |
+
input.addEventListener('focus', function() {
|
52 |
+
this.style.border = '2px solid #FF5722 !important';
|
53 |
+
this.style.borderWidth = '2px !important';
|
54 |
+
this.style.borderStyle = 'solid !important';
|
55 |
+
this.style.borderColor = '#FF5722 !important';
|
56 |
+
});
|
57 |
+
|
58 |
+
// Add blur event
|
59 |
+
input.addEventListener('blur', function() {
|
60 |
+
this.style.border = '2px solid #4CAF50 !important';
|
61 |
+
this.style.borderWidth = '2px !important';
|
62 |
+
this.style.borderStyle = 'solid !important';
|
63 |
+
this.style.borderColor = '#4CAF50 !important';
|
64 |
+
});
|
65 |
});
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
+
|
68 |
+
// Initial call
|
69 |
+
applyFocusStyles();
|
70 |
+
|
71 |
+
// MutationObserver to handle dynamically added elements
|
72 |
+
const observer = new MutationObserver(function(mutations) {
|
73 |
+
applyFocusStyles();
|
74 |
+
});
|
75 |
+
|
76 |
+
observer.observe(document.body, { childList: true, subtree: true });
|
77 |
});
|
78 |
</script>
|
79 |
|
|
|
124 |
on_change=process_input
|
125 |
)
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
# Display the current question if there is one
|
128 |
if st.session_state.last_query:
|
129 |
st.markdown("### Current Question:")
|
|
|
160 |
st.markdown("---")
|
161 |
st.markdown("""
|
162 |
### About this app
|
163 |
+
This application uses a Retrieval-Augmented Generation (RAG) system to answer questions about Indian spiritual texts.
|
164 |
It searches through a database of texts to find relevant passages and generates answers based on those passages.
|
165 |
""")
|