ankanghosh commited on
Commit
1d4d07f
·
verified ·
1 Parent(s): f637309

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py CHANGED
@@ -8,6 +8,14 @@ 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
  # Display title with custom styling
12
  st.markdown("""
13
  <style>
@@ -29,11 +37,37 @@ st.markdown("""
29
  border: 2px solid #FF5722 !important;
30
  border-radius: 8px !important;
31
  }
 
32
  .stTextInput>div>div>input {
33
  border: 2px solid #4CAF50 !important;
34
  border-radius: 8px !important;
35
  }
 
36
  </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  <div class="main-title">Indian Spiritual Texts Q&A</div>
38
  """, unsafe_allow_html=True)
39
 
@@ -81,6 +115,25 @@ query = st.text_input(
81
  on_change=process_input
82
  )
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  # Display the current question if there is one
85
  if st.session_state.last_query:
86
  st.markdown("### Current Question:")
 
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>
 
37
  border: 2px solid #FF5722 !important;
38
  border-radius: 8px !important;
39
  }
40
+ /* Default style for input (green) */
41
  .stTextInput>div>div>input {
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
+ // Get the input element
51
+ const inputElement = document.querySelector('.stTextInput input');
52
+
53
+ if (inputElement) {
54
+ // Add event listeners
55
+ inputElement.addEventListener('focus', function() {
56
+ this.style.border = '2px solid #FF5722 !important';
57
+ });
58
+
59
+ inputElement.addEventListener('blur', function() {
60
+ this.style.border = '2px solid #4CAF50 !important';
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
+
71
  <div class="main-title">Indian Spiritual Texts Q&A</div>
72
  """, unsafe_allow_html=True)
73
 
 
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:")