Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,14 +8,6 @@ st.set_page_config(page_title="Indian Spiritual RAG")
|
|
8 |
from rag_engine import process_query, load_model
|
9 |
from utils import setup_all_auth
|
10 |
|
11 |
-
# Define state for input box style
|
12 |
-
if 'input_focused' not in st.session_state:
|
13 |
-
st.session_state.input_focused = False
|
14 |
-
|
15 |
-
# Function to update input focus state
|
16 |
-
def set_input_focus(focused):
|
17 |
-
st.session_state.input_focused = focused
|
18 |
-
|
19 |
# Display title with custom styling
|
20 |
st.markdown("""
|
21 |
<style>
|
@@ -25,55 +17,70 @@ st.markdown("""
|
|
25 |
text-align: center;
|
26 |
margin-bottom: 1rem;
|
27 |
}
|
28 |
-
.button-style {
|
29 |
-
border: 2px solid #FF5722;
|
30 |
-
border-radius: 8px;
|
31 |
-
}
|
32 |
.stButton>button {
|
33 |
border: 2px solid #FF5722 !important;
|
34 |
border-radius: 8px !important;
|
35 |
}
|
36 |
-
/*
|
37 |
-
|
38 |
-
border:
|
39 |
-
|
|
|
|
|
40 |
}
|
41 |
</style>
|
42 |
|
43 |
<script>
|
44 |
document.addEventListener('DOMContentLoaded', function() {
|
45 |
-
|
46 |
-
|
47 |
-
const inputElements = document.querySelectorAll('.stTextInput input');
|
48 |
|
49 |
-
|
50 |
-
//
|
51 |
-
input.
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
-
// Add
|
59 |
-
input.addEventListener('
|
60 |
-
|
61 |
-
this.style.borderWidth = '2px !important';
|
62 |
-
this.style.borderStyle = 'solid !important';
|
63 |
-
this.style.borderColor = '#4CAF50 !important';
|
64 |
-
});
|
65 |
});
|
66 |
}
|
67 |
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
//
|
72 |
const observer = new MutationObserver(function(mutations) {
|
73 |
-
|
74 |
});
|
75 |
|
76 |
-
observer.observe(document.body, {
|
|
|
|
|
|
|
77 |
});
|
78 |
</script>
|
79 |
|
@@ -104,10 +111,12 @@ if not st.session_state.initialized:
|
|
104 |
# Force model loading at startup to avoid session state issues
|
105 |
load_model()
|
106 |
|
107 |
-
#
|
|
|
|
|
|
|
108 |
time.sleep(2)
|
109 |
init_message.success("System initialized successfully!")
|
110 |
-
st.session_state.initialized = True
|
111 |
except Exception as e:
|
112 |
st.error(f"Error initializing: {str(e)}")
|
113 |
|
|
|
8 |
from rag_engine import process_query, load_model
|
9 |
from utils import setup_all_auth
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Display title with custom styling
|
12 |
st.markdown("""
|
13 |
<style>
|
|
|
17 |
text-align: center;
|
18 |
margin-bottom: 1rem;
|
19 |
}
|
|
|
|
|
|
|
|
|
20 |
.stButton>button {
|
21 |
border: 2px solid #FF5722 !important;
|
22 |
border-radius: 8px !important;
|
23 |
}
|
24 |
+
/* Override Streamlit's default input styling */
|
25 |
+
div[data-baseweb="input"] {
|
26 |
+
border-radius: 8px;
|
27 |
+
}
|
28 |
+
div[data-baseweb="input"] > div {
|
29 |
+
background-color: transparent;
|
30 |
}
|
31 |
</style>
|
32 |
|
33 |
<script>
|
34 |
document.addEventListener('DOMContentLoaded', function() {
|
35 |
+
function setupInputStyles() {
|
36 |
+
const inputs = document.querySelectorAll('.stTextInput input');
|
|
|
37 |
|
38 |
+
inputs.forEach(function(input) {
|
39 |
+
// Remove any existing listeners to prevent duplicates
|
40 |
+
input.removeEventListener('focus', onFocus);
|
41 |
+
input.removeEventListener('blur', onBlur);
|
42 |
+
|
43 |
+
// Set initial style (green)
|
44 |
+
const parent = input.closest('div[data-baseweb="input"]');
|
45 |
+
if (parent) {
|
46 |
+
parent.style.border = '2px solid #4CAF50';
|
47 |
+
parent.style.boxShadow = 'none';
|
48 |
+
}
|
49 |
|
50 |
+
// Add new listeners
|
51 |
+
input.addEventListener('focus', onFocus);
|
52 |
+
input.addEventListener('blur', onBlur);
|
|
|
|
|
|
|
|
|
53 |
});
|
54 |
}
|
55 |
|
56 |
+
function onFocus(event) {
|
57 |
+
const parent = event.target.closest('div[data-baseweb="input"]');
|
58 |
+
if (parent) {
|
59 |
+
parent.style.border = '2px solid #FF5722';
|
60 |
+
parent.style.boxShadow = 'none';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
function onBlur(event) {
|
65 |
+
const parent = event.target.closest('div[data-baseweb="input"]');
|
66 |
+
if (parent) {
|
67 |
+
parent.style.border = '2px solid #4CAF50';
|
68 |
+
parent.style.boxShadow = 'none';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
// Initial setup
|
73 |
+
setupInputStyles();
|
74 |
|
75 |
+
// Setup observer to handle dynamically added elements
|
76 |
const observer = new MutationObserver(function(mutations) {
|
77 |
+
setupInputStyles();
|
78 |
});
|
79 |
|
80 |
+
observer.observe(document.body, {
|
81 |
+
childList: true,
|
82 |
+
subtree: true
|
83 |
+
});
|
84 |
});
|
85 |
</script>
|
86 |
|
|
|
111 |
# Force model loading at startup to avoid session state issues
|
112 |
load_model()
|
113 |
|
114 |
+
# First set initialized to True
|
115 |
+
st.session_state.initialized = True
|
116 |
+
|
117 |
+
# Then keep the message for 2 seconds before replacing it
|
118 |
time.sleep(2)
|
119 |
init_message.success("System initialized successfully!")
|
|
|
120 |
except Exception as e:
|
121 |
st.error(f"Error initializing: {str(e)}")
|
122 |
|