code-slicer commited on
Commit
1e42a9b
ยท
verified ยท
1 Parent(s): 165e514

Update css.py

Browse files
Files changed (1) hide show
  1. css.py +7 -16
css.py CHANGED
@@ -32,7 +32,7 @@ def render_message(
32
  by_word: bool = False, # ๋‹จ์–ด ๋‹จ์œ„ ์ถœ๋ ฅ
33
  ) -> str | None:
34
  import re, time
35
- # โ‘ข ํ…Œ๋งˆ/์ฝคํŒฉํŠธ ๊ฐ’ ์ฝ๊ธฐ
36
  palette = _get_colors()
37
  show_time = st.session_state.get("show_time", False) and sender == "bot"
38
 
@@ -42,15 +42,11 @@ def render_message(
42
  fsz = "13px"
43
 
44
  message = str(message).rstrip()
45
- # โ‘ฃ ํƒ€์ž„์Šคํƒฌํ”„ HTML
46
- ts_html = (
47
- f'<div style="font-size:11px;color:#888;margin-top:4px;">{datetime.now().strftime("%H:%M")}</div>'
48
- if show_time else ""
49
- )
50
 
51
  # ๊ณตํ†ต ํ’์„  ๋ž˜ํผ
52
- # โœ… ์นดํ†ก์ฒ˜๋Ÿผ: ๋งํ’์„ (๋ฒ„๋ธ”)๊ณผ ์‹œ๊ฐ„์„ ๋‚˜๋ž€ํžˆ ๋ฐฐ์น˜ (์‹œ๊ฐ„์€ ๋ฒ„๋ธ” '๋ฐ–')
53
- def _wrap(html_inner: str) -> str:
54
  bubble = (
55
  f'''<span style="background:{color}; padding:{pad}; border-radius:12px;'''
56
  f'''display:inline-block; max-width:80%; font-size:{fsz}; line-height:1.45;'''
@@ -58,15 +54,10 @@ def render_message(
58
  )
59
  ts = (
60
  f'''<span style="font-size:11px;color:#888;white-space:nowrap;'''
61
- f'''align-self:flex-end;margin:0 2px 2px;">{ts_text}</span>'''
62
- ) if ts_text else ""
63
-
64
- # bot: ์‹œ๊ฐ„ + ๋ฒ„๋ธ” / user: ๋ฒ„๋ธ” + ์‹œ๊ฐ„
65
  inner = (ts + bubble) if sender != "user" else (bubble + ts)
66
- return (
67
- f'''<div style="display:flex;align-items:flex-end;justify-content:{align};'''
68
- f'''gap:6px;margin:6px 0;">{inner}</div>'''
69
- )
70
 
71
  if not animated:
72
  st.markdown(_wrap(message), unsafe_allow_html=True)
 
32
  by_word: bool = False, # ๋‹จ์–ด ๋‹จ์œ„ ์ถœ๋ ฅ
33
  ) -> str | None:
34
  import re, time
35
+ # โ‘ข ํ…Œ๋งˆ ๊ฐ’ ์ฝ๊ธฐ
36
  palette = _get_colors()
37
  show_time = st.session_state.get("show_time", False) and sender == "bot"
38
 
 
42
  fsz = "13px"
43
 
44
  message = str(message).rstrip()
45
+ ts_text = datetime.now().strftime("%H:%M") if show_time else ""
 
 
 
 
46
 
47
  # ๊ณตํ†ต ํ’์„  ๋ž˜ํผ
48
+ # โœ… ์นดํ†ก ์Šคํƒ€์ผ: ์‹œ๊ฐ„์€ ๋งํ’์„  '๋ฐ–' (์™ผ์ชฝ: ๋ด‡=์‹œ๊ฐ+๋ฒ„๋ธ”, ์˜ค๋ฅธ์ชฝ: ์œ ์ €=๋ฒ„๋ธ”+์‹œ๊ฐ)
49
+ def _wrap(html_inner: str, ts_text_local: str = ts_text):
50
  bubble = (
51
  f'''<span style="background:{color}; padding:{pad}; border-radius:12px;'''
52
  f'''display:inline-block; max-width:80%; font-size:{fsz}; line-height:1.45;'''
 
54
  )
55
  ts = (
56
  f'''<span style="font-size:11px;color:#888;white-space:nowrap;'''
57
+ f'''align-self:flex-end;margin:0 2px 2px;">{ts_text_local}</span>'''
58
+ ) if ts_text_local else ""
 
 
59
  inner = (ts + bubble) if sender != "user" else (bubble + ts)
60
+ return f'''<div style="display:flex;align-items:flex-end;justify-content:{align};gap:6px;margin:6px 0;">{inner}</div>'''
 
 
 
61
 
62
  if not animated:
63
  st.markdown(_wrap(message), unsafe_allow_html=True)