randmimc commited on
Commit
ad08b7c
ยท
verified ยท
1 Parent(s): 1db7faa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -1,8 +1,7 @@
1
- import random
2
  import streamlit as st
3
 
4
  assistant_icon_path = "https://huggingface.co/spaces/randmimc/aitom/resolve/main/chat_icon/assistant.ico"
5
- user_icon_path = "chat_icon/user01.png"
6
 
7
  # ์„ธ์…˜ ์ƒํƒœ์—์„œ approval_state ๋ฐ messages ์ดˆ๊ธฐํ™”
8
  if "approval_state" not in st.session_state:
@@ -10,7 +9,7 @@ if "approval_state" not in st.session_state:
10
  if "messages" not in st.session_state:
11
  st.session_state.messages = []
12
 
13
- # Custom CSS to align messages
14
  st.markdown("""
15
  <style>
16
  .chat-container {
@@ -19,15 +18,17 @@ st.markdown("""
19
  margin-bottom: 10px;
20
  }
21
  .user-container {
22
- justify-content: flex-start;
23
  }
24
  .assistant-container {
25
- justify-content: flex-end;
26
  }
27
  .chat-bubble {
28
  padding: 10px;
29
  border-radius: 10px;
30
  max-width: 70%;
 
 
31
  }
32
  .user-bubble {
33
  background-color: #d1e7dd;
@@ -51,16 +52,16 @@ for message in st.session_state.messages:
51
  st.markdown(
52
  f"""
53
  <div class="chat-container user-container">
54
- <img src="{user_icon_path}" class="avatar">
55
  <div class="chat-bubble user-bubble">{message["content"]}</div>
 
56
  </div>
57
  """, unsafe_allow_html=True)
58
  else:
59
  st.markdown(
60
  f"""
61
  <div class="chat-container assistant-container">
62
- <div class="chat-bubble assistant-bubble">{message["content"]}</div>
63
  <img src="{assistant_icon_path}" class="avatar">
 
64
  </div>
65
  """, unsafe_allow_html=True)
66
 
 
 
1
  import streamlit as st
2
 
3
  assistant_icon_path = "https://huggingface.co/spaces/randmimc/aitom/resolve/main/chat_icon/assistant.ico"
4
+ user_icon_path = "https://huggingface.co/spaces/randmimc/aitom/resolve/main/chat_icon/user01.png"
5
 
6
  # ์„ธ์…˜ ์ƒํƒœ์—์„œ approval_state ๋ฐ messages ์ดˆ๊ธฐํ™”
7
  if "approval_state" not in st.session_state:
 
9
  if "messages" not in st.session_state:
10
  st.session_state.messages = []
11
 
12
+ # Custom CSS to align messages and wrap text
13
  st.markdown("""
14
  <style>
15
  .chat-container {
 
18
  margin-bottom: 10px;
19
  }
20
  .user-container {
21
+ justify-content: flex-end;
22
  }
23
  .assistant-container {
24
+ justify-content: flex-start;
25
  }
26
  .chat-bubble {
27
  padding: 10px;
28
  border-radius: 10px;
29
  max-width: 70%;
30
+ word-wrap: break-word;
31
+ white-space: pre-wrap;
32
  }
33
  .user-bubble {
34
  background-color: #d1e7dd;
 
52
  st.markdown(
53
  f"""
54
  <div class="chat-container user-container">
 
55
  <div class="chat-bubble user-bubble">{message["content"]}</div>
56
+ <img src="{user_icon_path}" class="avatar">
57
  </div>
58
  """, unsafe_allow_html=True)
59
  else:
60
  st.markdown(
61
  f"""
62
  <div class="chat-container assistant-container">
 
63
  <img src="{assistant_icon_path}" class="avatar">
64
+ <div class="chat-bubble assistant-bubble">{message["content"]}</div>
65
  </div>
66
  """, unsafe_allow_html=True)
67