Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -135,12 +135,19 @@ def main():
|
|
| 135 |
background-color: #2980b9;
|
| 136 |
}
|
| 137 |
.chat-message {
|
| 138 |
-
|
|
|
|
| 139 |
padding: 15px;
|
| 140 |
border-radius: 10px;
|
| 141 |
margin-bottom: 10px;
|
| 142 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
.user-message {
|
| 145 |
background-color: #d6eaf8;
|
| 146 |
}
|
|
@@ -183,12 +190,13 @@ def main():
|
|
| 183 |
# Display chat messages
|
| 184 |
for message in st.session_state.messages:
|
| 185 |
css_class = "user-message" if message["role"] == "user" else "assistant-message"
|
| 186 |
-
|
|
|
|
| 187 |
|
| 188 |
# Chat input
|
| 189 |
if prompt := st.chat_input():
|
| 190 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 191 |
-
st.markdown(f'<div class="chat-message user-message">{prompt}</div>', unsafe_allow_html=True)
|
| 192 |
|
| 193 |
# Generate bot response
|
| 194 |
if st.session_state.messages[-1]["role"] != "assistant":
|
|
@@ -197,7 +205,7 @@ def main():
|
|
| 197 |
response = user_input(prompt)
|
| 198 |
if response:
|
| 199 |
full_response = ''.join(response['output_text'])
|
| 200 |
-
st.markdown(f'<div class="chat-message assistant-message">{full_response}</div>', unsafe_allow_html=True)
|
| 201 |
message = {"role": "assistant", "content": full_response}
|
| 202 |
st.session_state.messages.append(message)
|
| 203 |
except RuntimeError as e:
|
|
|
|
| 135 |
background-color: #2980b9;
|
| 136 |
}
|
| 137 |
.chat-message {
|
| 138 |
+
display: flex;
|
| 139 |
+
align-items: center;
|
| 140 |
padding: 15px;
|
| 141 |
border-radius: 10px;
|
| 142 |
margin-bottom: 10px;
|
| 143 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 144 |
}
|
| 145 |
+
.chat-message img {
|
| 146 |
+
width: 40px;
|
| 147 |
+
height: 40px;
|
| 148 |
+
border-radius: 50%;
|
| 149 |
+
margin-right: 10px;
|
| 150 |
+
}
|
| 151 |
.user-message {
|
| 152 |
background-color: #d6eaf8;
|
| 153 |
}
|
|
|
|
| 190 |
# Display chat messages
|
| 191 |
for message in st.session_state.messages:
|
| 192 |
css_class = "user-message" if message["role"] == "user" else "assistant-message"
|
| 193 |
+
icon = "user_icon.png" if message["role"] == "user" else "assistant_icon.png"
|
| 194 |
+
st.markdown(f'<div class="chat-message {css_class}"><img src="{icon}" alt="icon"><div>{message["content"]}</div></div>', unsafe_allow_html=True)
|
| 195 |
|
| 196 |
# Chat input
|
| 197 |
if prompt := st.chat_input():
|
| 198 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 199 |
+
st.markdown(f'<div class="chat-message user-message"><img src="user_icon.png" alt="User"><div>{prompt}</div></div>', unsafe_allow_html=True)
|
| 200 |
|
| 201 |
# Generate bot response
|
| 202 |
if st.session_state.messages[-1]["role"] != "assistant":
|
|
|
|
| 205 |
response = user_input(prompt)
|
| 206 |
if response:
|
| 207 |
full_response = ''.join(response['output_text'])
|
| 208 |
+
st.markdown(f'<div class="chat-message assistant-message"><img src="assistant_icon.png" alt="Assistant"><div>{full_response}</div></div>', unsafe_allow_html=True)
|
| 209 |
message = {"role": "assistant", "content": full_response}
|
| 210 |
st.session_state.messages.append(message)
|
| 211 |
except RuntimeError as e:
|