randmimc commited on
Commit
a8c8bb5
Β·
verified Β·
1 Parent(s): 56f5bf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -46
app.py CHANGED
@@ -3,37 +3,6 @@ import streamlit as st
3
  assistant_icon_path = "chat_icon/assistant.ico"
4
  user_icon_path = "chat_icon/user01.png"
5
 
6
- # Custom CSS for alignment
7
- st.markdown("""
8
- <style>
9
- .chat-container {
10
- display: flex;
11
- width: 100%;
12
- }
13
- .chat-left {
14
- justify-content: flex-start;
15
- text-align: left;
16
- }
17
- .chat-right {
18
- justify-content: flex-end;
19
- text-align: right;
20
- }
21
- .chat-box {
22
- max-width: 60%;
23
- padding: 10px;
24
- margin: 5px;
25
- border-radius: 10px;
26
- display: inline-block;
27
- }
28
- .user-box {
29
- background-color: #d1e7fd;
30
- }
31
- .assistant-box {
32
- background-color: #f1f1f1;
33
- }
34
- </style>
35
- """, unsafe_allow_html=True)
36
-
37
  # μ„Έμ…˜ μƒνƒœμ—μ„œ approval_state 및 messages μ΄ˆκΈ°ν™”
38
  if "approval_state" not in st.session_state:
39
  st.session_state.approval_state = "require"
@@ -42,23 +11,16 @@ if "messages" not in st.session_state:
42
 
43
  # Display chat messages from history on app rerun
44
  for message in st.session_state.messages:
 
 
45
  if message["role"] == "user":
46
- align_class = "chat-left"
47
- box_class = "user-box"
 
48
  else:
49
- align_class = "chat-right"
50
- box_class = "assistant-box"
51
-
52
- st.markdown(
53
- f"""
54
- <div class="chat-container {align_class}">
55
- <div class="chat-box {box_class}">
56
- <b>{message["role"].capitalize()}:</b> {message["content"]}
57
- </div>
58
- </div>
59
- """,
60
- unsafe_allow_html=True
61
- )
62
 
63
  # Start with an assistant message
64
  if not st.session_state.messages:
 
3
  assistant_icon_path = "chat_icon/assistant.ico"
4
  user_icon_path = "chat_icon/user01.png"
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # μ„Έμ…˜ μƒνƒœμ—μ„œ approval_state 및 messages μ΄ˆκΈ°ν™”
7
  if "approval_state" not in st.session_state:
8
  st.session_state.approval_state = "require"
 
11
 
12
  # Display chat messages from history on app rerun
13
  for message in st.session_state.messages:
14
+ col1, col2 = st.columns([1, 1]) # 두 개의 λ™μΌν•œ 크기의 μ—΄ 생성
15
+
16
  if message["role"] == "user":
17
+ with col1: # μ™Όμͺ½ 열에 μ‚¬μš©μž λ©”μ‹œμ§€ ν‘œμ‹œ
18
+ with st.chat_message("user", avatar=user_icon_path):
19
+ st.markdown(message["content"])
20
  else:
21
+ with col2: # 였λ₯Έμͺ½ 열에 AI λ©”μ‹œμ§€ ν‘œμ‹œ
22
+ with st.chat_message("assistant", avatar=assistant_icon_path):
23
+ st.markdown(message["content"])
 
 
 
 
 
 
 
 
 
 
24
 
25
  # Start with an assistant message
26
  if not st.session_state.messages: