vishalkatheriya commited on
Commit
44fa3c6
Β·
verified Β·
1 Parent(s): 24fcaf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -26
app.py CHANGED
@@ -3,7 +3,6 @@ import time
3
  import random
4
  import psutil
5
  import base64
6
- import mimetypes
7
 
8
  # Set page config
9
  st.set_page_config(page_title="Enhanced Chatbot", layout="wide")
@@ -97,19 +96,21 @@ if 'messages' not in st.session_state:
97
  if 'uploaded_file' not in st.session_state:
98
  st.session_state.uploaded_file = None
99
 
100
- # Header
101
- st.title("πŸ€– Enhanced Chatbot")
102
-
103
- # Main layout
104
- col1, col2, col3 = st.columns([1, 2, 1])
105
-
106
- with col1:
107
  st.subheader("Chat History")
108
  if st.button("Clear History"):
109
  st.session_state.messages = []
 
 
 
 
110
 
111
- with col2:
112
- st.subheader("Chat")
 
 
 
113
 
114
  # Chat container with fixed height and scrolling
115
  chat_container = st.container()
@@ -217,29 +218,32 @@ with col2:
217
  # Rerun to update the chat display
218
  st.rerun()
219
 
220
- with col3:
221
- st.subheader("Settings")
222
 
223
- # Use expanders for settings to save space
224
- with st.expander("System Status", expanded=True):
225
- st.write("LLM Status: 🟒 Online")
226
- st.write("DB Status: 🟒 Connected")
227
 
228
- with st.expander("Resource Usage", expanded=True):
229
- # Fetch real CPU usage
230
- cpu_usage = psutil.cpu_percent(interval=1)
231
- st.progress(cpu_usage, text=f"CPU Usage: {cpu_usage}%")
232
-
233
- # Fetch real memory usage
234
- memory = psutil.virtual_memory()
235
- memory_usage = memory.percent
236
- st.progress(memory_usage, text=f"Memory Usage: {memory_usage}%")
 
 
 
 
237
 
238
  # Accessibility considerations
239
  st.markdown("""
240
  <div class="sr-only">
241
  This is a chatbot interface. You can type messages in the input field and press send to chat with the bot.
242
- There's also an option to upload files. The left sidebar shows chat history, and the right sidebar displays system settings.
243
  </div>
244
  """, unsafe_allow_html=True)
245
 
 
3
  import random
4
  import psutil
5
  import base64
 
6
 
7
  # Set page config
8
  st.set_page_config(page_title="Enhanced Chatbot", layout="wide")
 
96
  if 'uploaded_file' not in st.session_state:
97
  st.session_state.uploaded_file = None
98
 
99
+ # Sidebar - Left
100
+ with st.sidebar:
 
 
 
 
 
101
  st.subheader("Chat History")
102
  if st.button("Clear History"):
103
  st.session_state.messages = []
104
+
105
+ st.subheader("Recent Conversations")
106
+ for i, msg in enumerate(st.session_state.messages[-5:]):
107
+ st.text(f"{msg['role'].capitalize()}: {msg['content'][:30]}...")
108
 
109
+ # Main layout
110
+ col1, col2 = st.columns([3, 1])
111
+
112
+ with col1:
113
+ st.title("πŸ€– Enhanced Chatbot")
114
 
115
  # Chat container with fixed height and scrolling
116
  chat_container = st.container()
 
218
  # Rerun to update the chat display
219
  st.rerun()
220
 
221
+ with col2:
222
+ st.subheader("System Status")
223
 
224
+ # Fetch real CPU usage
225
+ cpu_usage = psutil.cpu_percent(interval=1)
226
+ st.progress(cpu_usage / 100, text=f"CPU Usage: {cpu_usage}%")
 
227
 
228
+ # Fetch real memory usage
229
+ memory = psutil.virtual_memory()
230
+ memory_usage = memory.percent
231
+ st.progress(memory_usage / 100, text=f"Memory Usage: {memory_usage}%")
232
+
233
+ # Dynamic status indicators
234
+ st.write("LLM Status: 🟒 Online" if random.random() > 0.1 else "LLM Status: πŸ”΄ Offline")
235
+ st.write("DB Status: 🟒 Connected" if random.random() > 0.1 else "DB Status: πŸ”΄ Disconnected")
236
+
237
+ # Add more dynamic elements
238
+ st.subheader("Active Users")
239
+ active_users = random.randint(50, 200)
240
+ st.metric(label="Current Active Users", value=active_users, delta=random.randint(-10, 10))
241
 
242
  # Accessibility considerations
243
  st.markdown("""
244
  <div class="sr-only">
245
  This is a chatbot interface. You can type messages in the input field and press send to chat with the bot.
246
+ There's also an option to upload files. The left sidebar shows chat history, and the right column displays system status.
247
  </div>
248
  """, unsafe_allow_html=True)
249