trohith89 commited on
Commit
1f5d4a9
Β·
verified Β·
1 Parent(s): 996808d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -14
app.py CHANGED
@@ -52,14 +52,15 @@ if "session_id" not in st.session_state:
52
  st.markdown("""
53
  <style>
54
  body {
55
- background-color: #E3F2FD;
56
  }
57
  .title-text {
58
  text-align: center;
59
- font-size: 28px;
60
  font-weight: bold;
61
- color: #1976D2;
62
  padding: 15px;
 
63
  }
64
  .stTextInput {
65
  position: fixed;
@@ -67,21 +68,35 @@ st.markdown("""
67
  width: 80%;
68
  left: 10%;
69
  z-index: 999;
 
 
 
70
  }
71
  .chat-container {
72
  background-color: white;
73
  padding: 20px;
74
- border-radius: 10px;
75
- box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
 
 
 
 
 
 
 
 
76
  }
77
  </style>
78
  """, unsafe_allow_html=True)
79
 
80
- # Display title
81
- st.markdown("""<h1 class='title-text'>πŸ’¬ AI Data Science Tutor</h1>""", unsafe_allow_html=True)
 
 
82
 
83
- # New Chat Button
84
- if st.button("πŸ†• New Chat"):
 
85
  st.session_state.session_id = str(uuid.uuid4()) # Generate new session
86
  st.session_state.messages = [] # Clear chat history
87
  st.rerun() # Refresh the app
@@ -117,7 +132,7 @@ chat = RunnableWithMessageHistory(
117
  )
118
 
119
  # Chat History Container
120
- st.markdown("### Chat History")
121
  chat_container = st.container()
122
 
123
  # Load chat history and display it
@@ -127,10 +142,13 @@ if "messages" not in st.session_state:
127
  with chat_container:
128
  for role, content in st.session_state.messages:
129
  with st.chat_message(role):
130
- st.markdown(content)
 
 
 
131
 
132
  # User input at the bottom
133
- user_input = st.text_input("Type your message here:", key="user_message")
134
 
135
  # If user submits a message
136
  if user_input:
@@ -144,10 +162,10 @@ if user_input:
144
  save_message(session_id, "assistant", response)
145
  st.session_state.messages.append(("assistant", response))
146
 
147
- # Display AI response
148
  with chat_container:
149
  with st.chat_message("assistant"):
150
- st.markdown(response)
151
 
152
  # Clear the input field
153
  st.session_state.pop("user_message")
 
52
  st.markdown("""
53
  <style>
54
  body {
55
+ background-color: #F0F8FF;
56
  }
57
  .title-text {
58
  text-align: center;
59
+ font-size: 32px;
60
  font-weight: bold;
61
+ color: #1E88E5;
62
  padding: 15px;
63
+ text-shadow: 2px 2px 5px rgba(0,0,0,0.2);
64
  }
65
  .stTextInput {
66
  position: fixed;
 
68
  width: 80%;
69
  left: 10%;
70
  z-index: 999;
71
+ border-radius: 20px;
72
+ padding: 10px;
73
+ border: 2px solid #1E88E5;
74
  }
75
  .chat-container {
76
  background-color: white;
77
  padding: 20px;
78
+ border-radius: 15px;
79
+ box-shadow: 3px 3px 12px rgba(0,0,0,0.2);
80
+ }
81
+ .user-message {
82
+ color: #00897B;
83
+ font-weight: bold;
84
+ }
85
+ .assistant-message {
86
+ color: #D81B60;
87
+ font-weight: bold;
88
  }
89
  </style>
90
  """, unsafe_allow_html=True)
91
 
92
+ # Display title with animation
93
+ st.markdown("""
94
+ <h1 class='title-text'>βœ¨πŸ’¬ AI Data Science Tutor πŸš€βœ¨</h1>
95
+ """, unsafe_allow_html=True)
96
 
97
+ # New Chat Button with emoji
98
+ theme_button = st.button("πŸ”„ Start a New Chat")
99
+ if theme_button:
100
  st.session_state.session_id = str(uuid.uuid4()) # Generate new session
101
  st.session_state.messages = [] # Clear chat history
102
  st.rerun() # Refresh the app
 
132
  )
133
 
134
  # Chat History Container
135
+ st.markdown("### πŸ“œ Chat History")
136
  chat_container = st.container()
137
 
138
  # Load chat history and display it
 
142
  with chat_container:
143
  for role, content in st.session_state.messages:
144
  with st.chat_message(role):
145
+ if role == "user":
146
+ st.markdown(f"<p class='user-message'>πŸ‘€ {content}</p>", unsafe_allow_html=True)
147
+ else:
148
+ st.markdown(f"<p class='assistant-message'>πŸ€– {content}</p>", unsafe_allow_html=True)
149
 
150
  # User input at the bottom
151
+ user_input = st.text_input("πŸ’‘ Type your message here:", key="user_message")
152
 
153
  # If user submits a message
154
  if user_input:
 
162
  save_message(session_id, "assistant", response)
163
  st.session_state.messages.append(("assistant", response))
164
 
165
+ # Display AI response with animation
166
  with chat_container:
167
  with st.chat_message("assistant"):
168
+ st.markdown(f"<p class='assistant-message'>πŸ€– {response}</p>", unsafe_allow_html=True)
169
 
170
  # Clear the input field
171
  st.session_state.pop("user_message")