devfire commited on
Commit
bdc7837
·
verified ·
1 Parent(s): b77d772

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -10,9 +10,31 @@ os.environ["GROQ_API_KEY"] = GROQ_API_KEY
10
  client = Groq(api_key=GROQ_API_KEY)
11
 
12
  # Streamlit user interface setup
13
- st.title("Subject-specific AI Chatbot")
 
14
  st.write("Hello! I'm your AI Study Assistant. You can ask me any questions related to your subjects, and I'll try to help.")
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Initialize session state for maintaining conversation
17
  if 'conversation_history' not in st.session_state:
18
  st.session_state.conversation_history = []
@@ -48,6 +70,7 @@ def generate_chatbot_response(user_message):
48
  return response
49
 
50
  # User input for conversation (now placed at the bottom)
 
51
  user_input = st.chat_input("Ask me a subject-related question:")
52
 
53
  # Handle user input and display conversation
@@ -58,6 +81,8 @@ if user_input:
58
  st.session_state.conversation_history.append(("User: " + user_input, "Chatbot: " + chatbot_response))
59
 
60
  # Display chat history
 
 
61
  for question, answer in st.session_state.conversation_history:
62
  st.write(f"**{question}**")
63
  st.write(answer)
 
10
  client = Groq(api_key=GROQ_API_KEY)
11
 
12
  # Streamlit user interface setup
13
+ st.set_page_config(page_title="AI Study Assistant", page_icon="🤖", layout="wide")
14
+ st.title("📚 Subject-specific AI Chatbot")
15
  st.write("Hello! I'm your AI Study Assistant. You can ask me any questions related to your subjects, and I'll try to help.")
16
 
17
+ # Add sidebar with styling options
18
+ st.sidebar.header("Settings")
19
+ st.sidebar.write("Customize your chatbot experience!")
20
+ chat_theme = st.sidebar.radio("Choose a theme:", ["Light", "Dark"])
21
+
22
+ # Apply theme
23
+ if chat_theme == "Dark":
24
+ st.markdown("""
25
+ <style>
26
+ body {background-color: #1e1e1e; color: white;}
27
+ .stButton>button {background-color: #4CAF50; color: white;}
28
+ </style>
29
+ """, unsafe_allow_html=True)
30
+ else:
31
+ st.markdown("""
32
+ <style>
33
+ body {background-color: #ffffff; color: black;}
34
+ .stButton>button {background-color: #008CBA; color: white;}
35
+ </style>
36
+ """, unsafe_allow_html=True)
37
+
38
  # Initialize session state for maintaining conversation
39
  if 'conversation_history' not in st.session_state:
40
  st.session_state.conversation_history = []
 
70
  return response
71
 
72
  # User input for conversation (now placed at the bottom)
73
+ st.markdown("### 💬 Chat with me")
74
  user_input = st.chat_input("Ask me a subject-related question:")
75
 
76
  # Handle user input and display conversation
 
81
  st.session_state.conversation_history.append(("User: " + user_input, "Chatbot: " + chatbot_response))
82
 
83
  # Display chat history
84
+ st.markdown("---")
85
+ st.markdown("### 🗨️ Chat History")
86
  for question, answer in st.session_state.conversation_history:
87
  st.write(f"**{question}**")
88
  st.write(answer)