Spaces:
Sleeping
Sleeping
vishalkatheriya
commited on
Update app.py
Browse files
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 |
-
#
|
101 |
-
st.
|
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 |
-
|
112 |
-
|
|
|
|
|
|
|
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
|
221 |
-
st.subheader("
|
222 |
|
223 |
-
#
|
224 |
-
|
225 |
-
|
226 |
-
st.write("DB Status: π’ Connected")
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
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
|
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 |
|