JanviMl commited on
Commit
fd44a50
Β·
verified Β·
1 Parent(s): a7c22d2

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +125 -45
src/streamlit_app.py CHANGED
@@ -14,6 +14,7 @@ import sys
14
  from typing import Dict, List, Optional
15
  from datetime import datetime
16
  import json
 
17
 
18
  # Add the src directory to Python path for imports
19
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
@@ -72,7 +73,8 @@ def check_tech_stack():
72
  tech_status['fastapi'] = {'available': True, 'status': 'Simulated API'}
73
 
74
  return tech_status
75
- # Enhanced CSS with tech stack indicators
 
76
  st.markdown("""
77
  <style>
78
  .main-header {
@@ -84,22 +86,38 @@ st.markdown("""
84
  text-align: center;
85
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
86
  }
87
- .tech-stack-status {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  display: flex;
89
- justify-content: center;
90
- gap: 0.5rem;
91
- margin: 1rem 0;
92
  flex-wrap: wrap;
 
93
  }
94
- .tech-item {
95
- padding: 0.3rem 0.6rem;
96
- border-radius: 12px;
97
- font-size: 0.75rem;
98
  font-weight: bold;
99
  color: white;
100
  display: flex;
101
  align-items: center;
102
- gap: 0.3rem;
103
  }
104
  .tech-available {
105
  background-color: #28a745;
@@ -176,42 +194,97 @@ st.markdown("""
176
  padding: 0.25rem 0;
177
  border-bottom: 1px solid #dee2e6;
178
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  </style>
180
  """, unsafe_allow_html=True)
181
 
182
- def display_tech_stack_status():
183
- """Display current tech stack status"""
184
- tech_status = check_tech_stack()
185
-
186
- st.markdown('<div class="tech-stack-status">', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
187
 
188
- for component, info in tech_status.items():
189
- if info['available']:
190
- if component == 'fastapi':
191
- css_class = "tech-demo"
192
- icon = "πŸ”„"
193
- else:
194
- css_class = "tech-available"
195
- icon = "βœ…"
196
- else:
197
- css_class = "tech-unavailable"
198
- icon = "⚠️"
199
 
200
- component_names = {
201
- 'python': 'Python',
202
- 'streamlit': 'Streamlit',
203
- 'vector_store': 'Vector Store',
204
- 'llm': 'LLM',
205
- 'fastapi': 'FastAPI'
206
- }
207
 
208
- st.markdown(f"""
209
- <div class="tech-item {css_class}">
210
- {icon} {component_names.get(component, component)}: {info['status']}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  </div>
212
- """, unsafe_allow_html=True)
213
-
214
- st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
215
 
216
  def initialize_session_state():
217
  """Initialize session state variables"""
@@ -259,12 +332,11 @@ def demo_role_switch():
259
  st.markdown('</div>', unsafe_allow_html=True)
260
 
261
  def login_page():
262
- """Display enhanced login page with tech stack status"""
263
  st.markdown('<div class="main-header"><h1>πŸ€– FinSolve AI Assistant</h1><p>Complete Tech Stack Implementation</p></div>', unsafe_allow_html=True)
264
 
265
- # Display tech stack status
266
- st.markdown("### πŸ—οΈ **Tech Stack Status**")
267
- display_tech_stack_status()
268
 
269
  col1, col2, col3 = st.columns([1, 2, 1])
270
 
@@ -282,6 +354,9 @@ def login_page():
282
  st.session_state.authenticated = True
283
  st.session_state.username = username
284
  st.session_state.user_role = auth_system.get_user_role(username)
 
 
 
285
  st.success(f"Welcome {username}! Your role: {st.session_state.user_role}")
286
  st.rerun()
287
  else:
@@ -385,17 +460,22 @@ def display_system_metrics():
385
 
386
  def main_app():
387
  """Enhanced main application interface"""
 
 
 
 
 
 
388
  # Initialize Enhanced RAG system if not done
389
  if st.session_state.enhanced_rag_system is None:
390
  with st.spinner("πŸš€ Initializing Complete RAG System..."):
391
  st.session_state.enhanced_rag_system = EnhancedRAGSystem()
392
  st.session_state.enhanced_rag_system.initialize_system()
393
 
394
- # Header with tech stack status
395
  col1, col2, col3 = st.columns([3, 2, 1])
396
  with col1:
397
  st.markdown('<div class="main-header"><h1>πŸ€– FinSolve AI Assistant</h1><p>Complete Tech Stack RAG System</p></div>', unsafe_allow_html=True)
398
- display_tech_stack_status()
399
  with col2:
400
  current_role = st.session_state.demo_role if st.session_state.demo_mode else st.session_state.user_role
401
  demo_indicator = " (Demo)" if st.session_state.demo_mode else ""
 
14
  from typing import Dict, List, Optional
15
  from datetime import datetime
16
  import json
17
+ import time
18
 
19
  # Add the src directory to Python path for imports
20
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 
73
  tech_status['fastapi'] = {'available': True, 'status': 'Simulated API'}
74
 
75
  return tech_status
76
+
77
+ # Enhanced CSS with small popup tech stack indicators
78
  st.markdown("""
79
  <style>
80
  .main-header {
 
86
  text-align: center;
87
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
88
  }
89
+ .tech-stack-popup {
90
+ position: fixed;
91
+ top: 20px;
92
+ right: 20px;
93
+ z-index: 1000;
94
+ background: rgba(255, 255, 255, 0.95);
95
+ border-radius: 8px;
96
+ padding: 0.8rem;
97
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
98
+ border-left: 4px solid #1f4e79;
99
+ max-width: 300px;
100
+ animation: slideIn 0.5s ease-out;
101
+ }
102
+ @keyframes slideIn {
103
+ from { transform: translateX(100%); opacity: 0; }
104
+ to { transform: translateX(0); opacity: 1; }
105
+ }
106
+ .tech-stack-mini {
107
  display: flex;
108
+ gap: 0.3rem;
 
 
109
  flex-wrap: wrap;
110
+ margin-top: 0.5rem;
111
  }
112
+ .tech-item-mini {
113
+ padding: 0.2rem 0.4rem;
114
+ border-radius: 6px;
115
+ font-size: 0.65rem;
116
  font-weight: bold;
117
  color: white;
118
  display: flex;
119
  align-items: center;
120
+ gap: 0.2rem;
121
  }
122
  .tech-available {
123
  background-color: #28a745;
 
194
  padding: 0.25rem 0;
195
  border-bottom: 1px solid #dee2e6;
196
  }
197
+ .tech-status-toggle {
198
+ position: fixed;
199
+ bottom: 20px;
200
+ right: 20px;
201
+ z-index: 999;
202
+ background: #1f4e79;
203
+ color: white;
204
+ border: none;
205
+ border-radius: 50%;
206
+ width: 50px;
207
+ height: 50px;
208
+ cursor: pointer;
209
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
210
+ font-size: 1.2rem;
211
+ }
212
+ .tech-status-toggle:hover {
213
+ background: #2d5aa0;
214
+ transform: scale(1.05);
215
+ }
216
  </style>
217
  """, unsafe_allow_html=True)
218
 
219
+ def display_tech_stack_popup():
220
+ """Display small popup tech stack status that auto-disappears"""
221
+ # Initialize popup state
222
+ if 'show_tech_popup' not in st.session_state:
223
+ st.session_state.show_tech_popup = True
224
+ st.session_state.popup_start_time = time.time()
225
+
226
+ # Auto-hide popup after 4 seconds
227
+ if st.session_state.show_tech_popup:
228
+ current_time = time.time()
229
+ if current_time - st.session_state.popup_start_time > 4:
230
+ st.session_state.show_tech_popup = False
231
+ st.rerun()
232
 
233
+ # Show popup if enabled
234
+ if st.session_state.show_tech_popup:
235
+ tech_status = check_tech_stack()
 
 
 
 
 
 
 
 
236
 
237
+ popup_html = f"""
238
+ <div class="tech-stack-popup">
239
+ <div style="font-weight: bold; color: #1f4e79; margin-bottom: 0.5rem;">
240
+ πŸ—οΈ Tech Stack Status
241
+ </div>
242
+ <div class="tech-stack-mini">
243
+ """
244
 
245
+ for component, info in tech_status.items():
246
+ if info['available']:
247
+ if component == 'fastapi':
248
+ css_class = "tech-demo"
249
+ icon = "πŸ”„"
250
+ else:
251
+ css_class = "tech-available"
252
+ icon = "βœ…"
253
+ else:
254
+ css_class = "tech-unavailable"
255
+ icon = "⚠️"
256
+
257
+ component_names = {
258
+ 'python': 'Python',
259
+ 'streamlit': 'Streamlit',
260
+ 'vector_store': 'Vector Store',
261
+ 'llm': 'LLM',
262
+ 'fastapi': 'FastAPI'
263
+ }
264
+
265
+ popup_html += f"""
266
+ <div class="tech-item-mini {css_class}">
267
+ {icon} {component_names.get(component, component)}
268
+ </div>
269
+ """
270
+
271
+ popup_html += """
272
+ </div>
273
+ <div style="font-size: 0.6rem; color: #666; margin-top: 0.5rem; text-align: center;">
274
+ Auto-hiding in 4 seconds...
275
+ </div>
276
  </div>
277
+ """
278
+
279
+ st.markdown(popup_html, unsafe_allow_html=True)
280
+
281
+ def display_tech_status_toggle():
282
+ """Display floating button to show tech status"""
283
+ st.markdown("""
284
+ <button class="tech-status-toggle" onclick="window.parent.location.reload();" title="Show Tech Stack Status">
285
+ πŸ”§
286
+ </button>
287
+ """, unsafe_allow_html=True)
288
 
289
  def initialize_session_state():
290
  """Initialize session state variables"""
 
332
  st.markdown('</div>', unsafe_allow_html=True)
333
 
334
  def login_page():
335
+ """Display enhanced login page with small tech stack popup"""
336
  st.markdown('<div class="main-header"><h1>πŸ€– FinSolve AI Assistant</h1><p>Complete Tech Stack Implementation</p></div>', unsafe_allow_html=True)
337
 
338
+ # Display small tech stack popup
339
+ display_tech_stack_popup()
 
340
 
341
  col1, col2, col3 = st.columns([1, 2, 1])
342
 
 
354
  st.session_state.authenticated = True
355
  st.session_state.username = username
356
  st.session_state.user_role = auth_system.get_user_role(username)
357
+ # Reset popup for next page
358
+ st.session_state.show_tech_popup = True
359
+ st.session_state.popup_start_time = time.time()
360
  st.success(f"Welcome {username}! Your role: {st.session_state.user_role}")
361
  st.rerun()
362
  else:
 
460
 
461
  def main_app():
462
  """Enhanced main application interface"""
463
+ # Display small tech stack popup on every page
464
+ display_tech_stack_popup()
465
+
466
+ # Display floating tech status toggle button
467
+ display_tech_status_toggle()
468
+
469
  # Initialize Enhanced RAG system if not done
470
  if st.session_state.enhanced_rag_system is None:
471
  with st.spinner("πŸš€ Initializing Complete RAG System..."):
472
  st.session_state.enhanced_rag_system = EnhancedRAGSystem()
473
  st.session_state.enhanced_rag_system.initialize_system()
474
 
475
+ # Header without tech stack status (now in popup)
476
  col1, col2, col3 = st.columns([3, 2, 1])
477
  with col1:
478
  st.markdown('<div class="main-header"><h1>πŸ€– FinSolve AI Assistant</h1><p>Complete Tech Stack RAG System</p></div>', unsafe_allow_html=True)
 
479
  with col2:
480
  current_role = st.session_state.demo_role if st.session_state.demo_mode else st.session_state.user_role
481
  demo_indicator = " (Demo)" if st.session_state.demo_mode else ""