-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.py
More file actions
64 lines (50 loc) · 2.2 KB
/
UI.py
File metadata and controls
64 lines (50 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
from Chatbot import response # <- import the response logic
st.set_page_config(page_title="IndraAI", layout="centered")
st.title("🔱 Indra AI")
#Sidebar
menu = st.sidebar.selectbox(
"Menu",
["💬 New Chat", "📁 Search history", "🧠 Gpts", "🔍 Search", "⚙️ Settings"]
)
# ---------- Initialize Session State ----------
if "messages" not in st.session_state:
st.session_state.messages = []
if "bot_name" not in st.session_state:
st.session_state.bot_name = "Indra AI"
if "theme" not in st.session_state:
st.session_state.theme = "Light"
# ---------- Settings Page ----------
if menu == "⚙️ Settings":
st.subheader("⚙️ Chatbot Settings")
new_name = st.text_input("🤖 Bot name", st.session_state.bot_name)
if new_name != st.session_state.bot_name:
st.session_state.bot_name = new_name
st.success(f"Bot name updated to '{new_name}'")
theme = st.selectbox("🎨 Select Theme", ["Light", "Dark"], index=0 if st.session_state.theme == "Light" else 1)
if theme != st.session_state.theme:
st.session_state.theme = theme
st.info(f"Theme set to {theme}")
if st.button("🔄 Reset Chat History"):
st.session_state.messages = []
st.warning("Chat history cleared.")
# ---------- New Chat Page ----------
elif menu == "💬 New Chat":
st.subheader("💬 New Chat")
for msg in st.session_state.messages:
with st.chat_message(msg["role"]):
st.markdown(msg["content"])
user_input = st.chat_input("Type your message...")
if user_input:
st.session_state.messages.append({"role": "user", "content": user_input})
with st.chat_message("user"):
st.markdown(user_input)
# Get bot response from chatbot.py
bot_reply = response(user_input)
st.session_state.messages.append({"role": "assistant", "content": bot_reply})
with st.chat_message("assistant"):
st.markdown(bot_reply)
# ---------- History Placeholder ----------
elif menu == "📁 Search history":
st.subheader("📁 Search History")
st.info("History view not implemented yet. Coming soon!")