Spaces:
Runtime error

kchaeyeonn commited on
Commit
e4a4650
ยท
verified ยท
1 Parent(s): 24bfd35

Upload src/app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/app.py +603 -56
src/app.py CHANGED
@@ -1,67 +1,614 @@
1
 
2
- import os, base64, json, requests
 
 
 
 
 
 
3
  import streamlit as st
4
  from openai import OpenAI
5
 
6
- # OpenAI ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ
 
 
7
  client = OpenAI()
8
 
9
- # ํŽ˜์ด์ง€ ์„ค์ •
10
- st.set_page_config(page_title="์Œ์„ฑ AI ์„œ๋น„์Šค", page_icon="๐Ÿค–", layout="wide")
11
- st.title("์Œ์„ฑ ์ธ์‹ AI ์„œ๋น„์Šค")
12
- st.write("์Œ์„ฑ์œผ๋กœ ์งˆ๋ฌธํ•˜์‹œ๋ฉด ๋‹ต๋ณ€ํ•ด ๋“œ๋ฆฝ๋‹ˆ๋‹ค.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- # ์—ญํ•  ์ง€์ •
15
- sys_role = """
16
- ๋‹น์‹ ์€ ๋‹ค์–‘ํ•œ ์—…๋ฌด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” AI ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค.
17
- ๊ฐœ์ธ ๋น„์„œ์ฒ˜๋Ÿผ ์นœ์ ˆํ•˜๊ฒŒ ์‘๋Œ€ํ•ฉ๋‹ˆ๋‹ค.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- # ์ƒํƒœ ์ดˆ๊ธฐํ™”
21
- if "messages" not in st.session_state:
22
- st.session_state.messages = []
23
-
24
- # ์ง€์‹œ ์˜์—ญ
25
- with st.form("task_form"):
26
- uploaded_file = st.file_uploader("ํ…์ŠคํŠธ ํŒŒ์ผ ์—…๋กœ๋“œ", type=["txt"])
27
- audio_value = st.audio_input("๋ฌด์—‡์„ ๋„์™€๋“œ๋ฆด๊นŒ์š”?")
28
- submit = st.form_submit_button("์‹คํ–‰")
29
-
30
- # ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ๋งŒ ์‹คํ–‰
31
- if submit:
32
- # ์—…๋กœ๋“œ ๋œ ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด ๋””์ฝ”๋”ฉ
33
- text = ""
34
- if uploaded_file is not None:
35
- text = uploaded_file.read().decode("utf-8")
36
-
37
- # ๋…น์Œ์ด ์—†์œผ๋ฉด ๋…น์Œ ์š”์ฒญ
38
- if audio_value is None:
39
- st.warning("์Œ์„ฑ์„ ๋…น์Œํ•ด์ฃผ์„ธ์š”.")
40
- st.stop()
41
-
42
- # ์‹œ์Šคํ…œ ๋ฉ”์„ธ์ง€
43
- system_content = sys_role
44
- if text:
45
- system_content += f"\n\n๋‹ค์Œ ๋‚ด์šฉ์„ ์ฐธ๊ณ ํ•˜์„ธ์š”:\n{text}"
46
- input_messages = [{"role": "system", "content": system_content}]
47
-
48
- # STT: ์Œ์„ฑ โ†’ ํ…์ŠคํŠธ
49
- transcript = client.audio.transcriptions.create(
50
- model="whisper-1",
51
- file=("audio.wav", audio_value, "audio/wav"))
52
-
53
- # ์‚ฌ์šฉ์ž ๋ฉ”์‹œ์ง€
54
- input_messages.append({"role": "user", "content": transcript.text})
55
-
56
- # LLM ํ˜ธ์ถœ ๋ฐ ์‘๋‹ต ๋“ฃ๊ธฐ
57
- with st.spinner("๋‹ต๋ณ€์„ ์ค€๋น„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค..."):
58
- # LLM ํ˜ธ์ถœ
59
- response = client.responses.create(
60
- model="gpt-4o-mini",
61
- input=input_messages
62
  )
63
- answer = response.output_text
64
 
65
- # ์‘๋‹ต ์ถœ๋ ฅ
66
- st.subheader("AI ๋‹ต๋ณ€")
67
- st.write(answer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import os
3
+ import io
4
+ import json
5
+ import re
6
+ import requests
7
+ from datetime import datetime
8
+
9
  import streamlit as st
10
  from openai import OpenAI
11
 
12
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
13
+ # ๊ธฐ๋ณธ ์„ค์ •
14
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
15
  client = OpenAI()
16
 
17
+ st.set_page_config(
18
+ page_title="MeetingAI | KT Enterprise",
19
+ page_icon="๐ŸŽ™๏ธ",
20
+ layout="wide",
21
+ initial_sidebar_state="expanded",
22
+ )
23
+
24
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
25
+ # CSS (์ •์  ์š”์†Œ ์ „์šฉ โ€” ๋™์  HTML์€ inline style ์‚ฌ์šฉ)
26
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
27
+ st.markdown("""
28
+ <style>
29
+ @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&family=Rajdhani:wght@500;600;700&display=swap');
30
+
31
+ html, body, [data-testid="stAppViewContainer"] {
32
+ background: #1A1A2E !important;
33
+ font-family: 'Noto Sans KR', sans-serif !important;
34
+ color: #FFFFFF !important;
35
+ }
36
+ [data-testid="stSidebar"] {
37
+ background: #16213E !important;
38
+ border-right: 1px solid #2A3550;
39
+ }
40
+ [data-testid="stMainBlockContainer"] { padding-top: 24px !important; }
41
+
42
+ /* ์ž…๋ ฅ ์ปจํ…Œ์ด๋„ˆ */
43
+ .input-title {
44
+ background: #16213E;
45
+ border: 1px solid #2A3550;
46
+ border-bottom: none;
47
+ border-radius: 12px 12px 0 0;
48
+ padding: 14px 22px 10px 22px;
49
+ font-size: 0.74rem; font-weight: 600;
50
+ color: #8892A4; letter-spacing: 1.5px; text-transform: uppercase;
51
+ }
52
+ [data-testid="stVerticalBlockBorderWrapper"] {
53
+ background: #16213E !important;
54
+ border: 1px solid #2A3550 !important;
55
+ border-top: none !important;
56
+ border-radius: 0 0 12px 12px !important;
57
+ padding: 16px 20px 20px !important;
58
+ margin-bottom: 14px !important;
59
+ }
60
+
61
+ /* ์‚ฌ์ด๋“œ๋ฐ” ๋ผ๋ฒจ */
62
+ .sb-label {
63
+ font-size: 0.7rem; color: #8892A4;
64
+ letter-spacing: 1.2px; text-transform: uppercase;
65
+ margin: 4px 0 8px 0;
66
+ }
67
+
68
+ /* Streamlit ์œ„์ ฏ */
69
+ [data-testid="stButton"] > button {
70
+ background: #E3000B !important; color: white !important;
71
+ border: none !important; border-radius: 8px !important;
72
+ font-family: 'Noto Sans KR', sans-serif !important;
73
+ font-weight: 600 !important; font-size: 0.9rem !important;
74
+ padding: 10px 24px !important; transition: all 0.2s !important;
75
+ }
76
+ [data-testid="stButton"] > button:hover {
77
+ background: #c0000a !important;
78
+ box-shadow: 0 4px 16px rgba(227,0,11,0.4) !important;
79
+ transform: translateY(-1px) !important;
80
+ }
81
+ [data-testid="stTextArea"] textarea,
82
+ [data-testid="stTextInput"] input {
83
+ background: rgba(15,33,62,0.9) !important;
84
+ border: 1px solid #2A3550 !important;
85
+ color: #FFFFFF !important; border-radius: 8px !important;
86
+ font-family: 'Noto Sans KR', sans-serif !important;
87
+ }
88
+ [data-testid="stTextArea"] textarea:focus,
89
+ [data-testid="stTextInput"] input:focus {
90
+ border-color: #E3000B !important;
91
+ box-shadow: 0 0 0 2px rgba(227,0,11,0.2) !important;
92
+ }
93
+ [data-testid="stFileUploader"] {
94
+ border: 1.5px dashed #2A3550 !important;
95
+ border-radius: 8px !important; background: rgba(15,33,62,0.5) !important;
96
+ }
97
+ [data-testid="stTabs"] [data-baseweb="tab-list"] {
98
+ background: #16213E !important; border-bottom: 1px solid #2A3550 !important;
99
+ }
100
+ [data-testid="stTabs"] [data-baseweb="tab"] {
101
+ background: transparent !important; color: #8892A4 !important;
102
+ font-family: 'Noto Sans KR', sans-serif !important;
103
+ font-size: 0.875rem !important; font-weight: 500 !important;
104
+ padding: 10px 18px !important;
105
+ }
106
+ [data-testid="stTabs"] [aria-selected="true"] {
107
+ background: rgba(227,0,11,0.08) !important;
108
+ color: #FFFFFF !important; border-bottom: 2px solid #E3000B !important;
109
+ }
110
+ [data-testid="stExpander"] {
111
+ background: rgba(15,52,96,0.3) !important;
112
+ border: 1px solid #2A3550 !important; border-radius: 8px !important;
113
+ }
114
+ label, [data-testid="stWidgetLabel"] p {
115
+ color: #8892A4 !important; font-size: 0.82rem !important;
116
+ }
117
+ p, .stMarkdown p { color: #F0F4F8 !important; }
118
+ h1,h2,h3 { color: #FFFFFF !important; }
119
+ [data-testid="stRadio"] label { color: #F0F4F8 !important; font-size: 0.88rem !important; }
120
+ [data-testid="stToggle"] p { color: #F0F4F8 !important; font-size: 0.88rem !important; }
121
+
122
+ /* Hugging Face Space ์ƒ๋‹จ ์—ฌ๋ฐฑ & ํฐ์ƒ‰ ํ—ค๋” ์ œ๊ฑฐ */
123
+ [data-testid="stAppViewContainer"] > .main { padding-top: 1rem !important; }
124
+ [data-testid="stHeader"] { background: #1A1A2E !important; border-bottom: none !important; }
125
+ [data-testid="stToolbar"] { background: #1A1A2E !important; }
126
+ [data-testid="stDecoration"] { background: #1A1A2E !important; }
127
+ </style>
128
+ """, unsafe_allow_html=True)
129
+
130
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
131
+ # ์ธ๋ผ์ธ ์Šคํƒ€์ผ ์ƒ์ˆ˜ (๋™์  HTML์—์„œ ํด๋ž˜์Šค ๋Œ€์‹  ์‚ฌ์šฉ)
132
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
133
+ S = {
134
+ "card": (
135
+ "background:#16213E;border:1px solid #2A3550;border-radius:12px;"
136
+ "padding:20px 24px;margin-bottom:14px;box-shadow:0 4px 24px rgba(0,0,0,0.35);"
137
+ ),
138
+ "card_title": (
139
+ "font-size:0.74rem;font-weight:600;color:#8892A4;"
140
+ "letter-spacing:1.5px;text-transform:uppercase;margin-bottom:14px;"
141
+ ),
142
+ "timeline_row": "display:flex;gap:12px;margin-bottom:10px;align-items:flex-start;",
143
+ "timeline_dot": (
144
+ "width:9px;height:9px;border-radius:50%;background:#E3000B;"
145
+ "margin-top:5px;flex-shrink:0;"
146
+ ),
147
+ "timeline_text": "font-size:0.875rem;color:#F0F4F8;line-height:1.6;",
148
+ "badge_high": "display:inline-block;padding:2px 9px;border-radius:20px;font-size:0.7rem;font-weight:600;background:rgba(227,0,11,0.15);color:#E3000B;border:1px solid rgba(227,0,11,0.3);",
149
+ "badge_med": "display:inline-block;padding:2px 9px;border-radius:20px;font-size:0.7rem;font-weight:600;background:rgba(255,184,0,0.12);color:#FFB800;border:1px solid rgba(255,184,0,0.3);",
150
+ "badge_low": "display:inline-block;padding:2px 9px;border-radius:20px;font-size:0.7rem;font-weight:600;background:rgba(0,200,151,0.12);color:#00C897;border:1px solid rgba(0,200,151,0.3);",
151
+ "badge_gray": "display:inline-block;padding:2px 9px;border-radius:20px;font-size:0.7rem;font-weight:600;background:rgba(136,146,164,0.12);color:#8892A4;border:1px solid rgba(136,146,164,0.3);",
152
+ }
153
+
154
+ PRIORITY_LABEL = {"high": "๐Ÿ”ด ๋†’์Œ", "medium": "๐ŸŸก ๋ณดํ†ต", "low": "๐ŸŸข ๋‚ฎ์Œ"}
155
+ PRIORITY_BADGE_KEY = {"high": "badge_high", "medium": "badge_med", "low": "badge_low"}
156
+ PRIORITY_BORDER = {"high": "#FF4444", "medium": "#FFB800", "low": "#00C897"}
157
+
158
+
159
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
160
+ # ์„ธ์…˜ ์ƒํƒœ
161
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
162
+ for k, v in {
163
+ "transcript": "", "analysis": None,
164
+ "audio_bytes": None, "mail_body": "", "tts_bytes": None,
165
+ }.items():
166
+ if k not in st.session_state:
167
+ st.session_state[k] = v
168
+
169
+
170
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
171
+ # ํ—ฌํผ ํ•จ์ˆ˜
172
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
173
+ SECURE_KEYWORDS = ["๋ณด์•ˆ", "๊ธฐ๋ฐ€", "๋Œ€์™ธ๋น„", "๊ตฐ์‚ฌ", "๋น„๋ฐ€", "๋‚ด๋ถ€์ž๋ฃŒ", "confidential"]
174
+ SENSITIVE_PATTERNS = [
175
+ (r"๊ธฐ๋ฐ€|๋น„๋ฐ€|๋Œ€์™ธ๋น„|๋‚ด๋ถ€.*๋ณด์•ˆ|๋ณด์•ˆ.*์œ ์ง€|confidential", "๊ธฐ๋ฐ€/๋Œ€์™ธ๋น„ ํ‘œํ˜„"),
176
+ (r"๊ธ‰์—ฌ|์—ฐ๋ด‰|์ž„๊ธˆ|salary", "๊ธ‰์—ฌยท์ธ์‚ฌ ์ •๋ณด"),
177
+ (r"๊ฐœ์ธ์ •๋ณด|์ฃผ๋ฏผ|์ƒ๋…„์›”์ผ", "๊ฐœ์ธ์ •๋ณด"),
178
+ (r"\d{3}-\d{4}-\d{4}", "์ „ํ™”๋ฒˆํ˜ธ ํŒจํ„ด"),
179
+ (r"\d{6}-\d{7}", "์ฃผ๋ฏผ๋ฒˆํ˜ธ ํŒจํ„ด"),
180
+ (r"๊ณ„์•ฝ๊ธˆ|๋‹จ๊ฐ€|์˜ˆ์‚ฐ.*์–ต|์˜ˆ์‚ฐ.*์ฒœ๋งŒ", "๊ธˆ์•กยท๊ณ„์•ฝ ์ •๋ณด"),
181
+ ]
182
+
183
+ def is_secure_content(text):
184
+ return any(kw in text for kw in SECURE_KEYWORDS)
185
+
186
+ def detect_sensitive(text):
187
+ return list({label for pat, label in SENSITIVE_PATTERNS
188
+ if re.search(pat, text, re.IGNORECASE)})
189
+
190
+ def stt(audio_file):
191
+ return client.audio.transcriptions.create(
192
+ model="whisper-1", file=audio_file, language="ko"
193
+ ).text
194
+
195
+ SYS_ROLE = """
196
+ ## ์—ญํ• 
197
+ ๋‹น์‹ ์€ KT Enterprise IT๊ธฐ์ˆ ํ˜์‹ ํŒ€ DX Consulting์˜ AI ํšŒ์˜ ๋น„์„œ์ž…๋‹ˆ๋‹ค.
198
+ ํšŒ์˜ ๋‚ด์šฉ์„ ์ •ํ™•ํ•˜๊ณ  ์‹ ์†ํ•˜๊ฒŒ ๋ถ„์„ยท์ •๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ์‘๋‹ต์€ ํ•œ๊ตญ์–ด๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
199
 
200
+ ## ํšŒ์˜๋ก ์ •๋ฆฌ ๊ทœ์น™
201
+ 1. ํšŒ์˜ ๊ฐœ์š” โ€” ์ œ๋ชฉ / ๋ชฉ์  / ์ฃผ์š” ์•ˆ๊ฑด
202
+ 2. ๊ฒฐ์ •๋œ ์‚ฌํ•ญ โ€” ํ•ต์‹ฌ ๊ฒฐ์ •๋งŒ ๊ฐ„๊ฒฐํ•˜๊ฒŒ
203
+ 3. ๋‹ด๋‹น ์—…๋ฌด(Action Items) โ€” [๋‹ด๋‹น์ž]:[์—…๋ฌด]/๊ธฐํ•œ/์šฐ์„ ์ˆœ์œ„
204
+ 4. ์ผ์ • ์š”์•ฝ โ€” ๋งˆ๊ฐ ๊ธฐํ•œ ์‹œ๊ฐ„์ˆœ ์ •๋ฆฌ
205
+
206
+ ## ์ฃผ์˜์‚ฌํ•ญ
207
+ - ํšŒ์˜๋ก์— ์—†๋Š” ๋‚ด์šฉ์€ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
208
+ - ๋ถˆ๋ช…ํ™•ํ•œ ๋‚ด์šฉ์€ 'ํ™•์ธ ํ•„์š”'๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
209
+ """
210
+
211
+ def analyze_meeting(text):
212
+ today = datetime.now().strftime("%Y๋…„ %m์›” %d์ผ")
213
+ prompt = f"""
214
+ ๋‹ค์Œ์€ ์˜ค๋Š˜({today}) ์ง„ํ–‰๋œ ํšŒ์˜ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
215
+ ์•„๋ž˜ JSON ํ˜•์‹์œผ๋กœ ๋ถ„์„ํ•˜์„ธ์š”. ๋ฐ˜๋“œ์‹œ JSON๋งŒ ์ถœ๋ ฅํ•˜์„ธ์š”.
216
+
217
+ ํšŒ์˜ ๋‚ด๏ฟฝ๏ฟฝ:
218
+ {text}
219
+
220
+ {{
221
+ "meeting_title": "ํšŒ์˜ ์ œ๋ชฉ",
222
+ "purpose": "ํšŒ์˜ ๋ชฉ์  (2-3๋ฌธ์žฅ)",
223
+ "decisions": ["๊ฒฐ์ • ์‚ฌํ•ญ 1", "๊ฒฐ์ • ์‚ฌํ•ญ 2"],
224
+ "tasks": [
225
+ {{"person":"๋‹ด๋‹น์ž","task":"์—…๋ฌด ๋‚ด์šฉ","deadline":"๊ธฐํ•œ ๋˜๋Š” null","priority":"high|medium|low"}}
226
+ ],
227
+ "agenda_items": ["์•ˆ๊ฑด 1", "์•ˆ๊ฑด 2"],
228
+ "next_meeting": "๋‹ค์Œ ํšŒ์˜ ์ผ์ • ๋˜๋Š” null",
229
+ "summary": "์ „์ฒด ์š”์•ฝ (4-5๋ฌธ์žฅ)",
230
+ "keywords": ["ํ‚ค์›Œ๋“œ1", "ํ‚ค์›Œ๋“œ2", "ํ‚ค์›Œ๋“œ3"]
231
+ }}
232
  """
233
+ resp = client.chat.completions.create(
234
+ model="gpt-4o",
235
+ messages=[{"role":"system","content":SYS_ROLE},
236
+ {"role":"user", "content":prompt}],
237
+ temperature=0.2,
238
+ )
239
+ raw = re.sub(r"^```json\s*|```\s*$", "", resp.choices[0].message.content.strip())
240
+ return json.loads(raw)
241
+
242
+ def generate_tts(text):
243
+ resp = client.audio.speech.create(model="gpt-4o-mini-tts", voice="nova", input=text)
244
+ buf = io.BytesIO()
245
+ for chunk in resp.iter_bytes():
246
+ buf.write(chunk)
247
+ buf.seek(0)
248
+ return buf.read()
249
+
250
+ def generate_email_body(analysis, recipient_name):
251
+ tasks_txt = "\n".join(
252
+ f" - [{t['person']}] {t['task']}" + (f" (๊ธฐํ•œ:{t['deadline']})" if t.get("deadline") else "")
253
+ for t in analysis.get("tasks", [])
254
+ )
255
+ decisions_txt = "\n".join(f" โ€ข {d}" for d in analysis.get("decisions", []))
256
+ resp = client.chat.completions.create(
257
+ model="gpt-4o-mini",
258
+ messages=[{"role":"user","content":f"""
259
+ {recipient_name}์—๊ฒŒ ๋ณด๋‚ด๋Š” ๊ณต์‹ ๋ฆฌ๋งˆ์ธ๋“œ ์ด๋ฉ”์ผ์„ ์ž‘์„ฑํ•˜์„ธ์š”.
260
+ KT Enterprise IT๊ธฐ์ˆ ํ˜์‹ ํŒ€ DX Consulting ์†Œ์† ์ง์› ํ˜•์‹์œผ๋กœ ์ž‘์„ฑํ•˜์„ธ์š”.
261
+ ํšŒ์˜ ์ œ๋ชฉ: {analysis.get('meeting_title','ํšŒ์˜')}
262
+ ๊ฒฐ์ • ์‚ฌํ•ญ:\n{decisions_txt}
263
+ ๋‹ด๋‹น ์—…๋ฌด:\n{tasks_txt}
264
+ ์ด๋ฉ”์ผ ๋ณธ๋ฌธ๋งŒ ์ถœ๋ ฅํ•˜์„ธ์š” (์ œ๋ชฉ ์ œ์™ธ).
265
+ """}],
266
+ temperature=0.4,
267
+ )
268
+ return resp.choices[0].message.content.strip()
269
+
270
+ def send_email(to, subject, body):
271
+ if is_secure_content(body) or is_secure_content(subject):
272
+ return {"status":"blocked","reason":"๋ณด์•ˆ ํ‚ค์›Œ๋“œ ํฌํ•จ์œผ๋กœ ์ž๋™ ์ฐจ๋‹จ๋จ"}
273
+ api_key = os.getenv("SENDGRID_API_KEY","")
274
+ sender = os.getenv("EMAIL_ADDRESS","")
275
+ resp = requests.post(
276
+ "https://api.sendgrid.com/v3/mail/send",
277
+ headers={"Authorization":f"Bearer {api_key}","Content-Type":"application/json"},
278
+ json={"personalizations":[{"to":[{"email":to}],"subject":subject}],
279
+ "from":{"email":sender},
280
+ "content":[{"type":"text/plain","value":body}]},
281
+ )
282
+ return {"status":"success"} if resp.status_code==202 \
283
+ else {"status":"failed","error":resp.text}
284
+
285
+
286
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
287
+ # ์‚ฌ์ด๋“œ๋ฐ”
288
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
289
+ with st.sidebar:
290
+ st.markdown("""
291
+ <div style="padding:14px 0 6px 0;">
292
+ <div style="font-family:'Rajdhani',sans-serif;font-size:1.7rem;font-weight:700;
293
+ color:#E3000B;letter-spacing:2px;">KT</div>
294
+ <div style="font-size:0.8rem;color:#8892A4;margin-top:2px;">IT๊ธฐ์ˆ ํ˜์‹ ํŒ€ ยท DX Consulting</div>
295
+ </div>
296
+ <div style="height:1px;background:#2A3550;margin:12px 0 18px 0;"></div>
297
+ """, unsafe_allow_html=True)
298
+
299
+ st.markdown('<div class="sb-label">์ž…๋ ฅ ๋ฐฉ์‹</div>', unsafe_allow_html=True)
300
+ input_mode = st.radio("์ž…๋ ฅ๋ฐฉ์‹", ["๐ŸŽ™๏ธ ์Œ์„ฑ ๋…น์Œ","๐Ÿ“ ํŒŒ์ผ ์—…๋กœ๋“œ","๐Ÿ“ ํ…์ŠคํŠธ ์ง์ ‘ ์ž…๋ ฅ"],
301
+ label_visibility="collapsed")
302
+
303
+ st.markdown('<div style="height:1px;background:#2A3550;margin:14px 0;"></div>', unsafe_allow_html=True)
304
+ st.markdown('<div class="sb-label">์ด๋ฉ”์ผ ์„ค์ •</div>', unsafe_allow_html=True)
305
+ email_enabled = st.toggle("๋ฆฌ๋งˆ์ธ๋“œ ๋ฉ”์ผ ๋ฐœ์†ก", value=False)
306
+ email_recipient, email_name = "", ""
307
+ if email_enabled:
308
+ email_recipient = st.text_input("์ˆ˜์‹ ์ž ์ด๋ฉ”์ผ", placeholder="kim@kt.com")
309
+ email_name = st.text_input("์ˆ˜์‹ ์ž ์ด๋ฆ„", placeholder="๊น€๋Œ€๋ฆฌ")
310
+
311
+ st.markdown('<div style="height:1px;background:#2A3550;margin:14px 0;"></div>', unsafe_allow_html=True)
312
+ st.markdown('<div class="sb-label">๋ถ„์„ ์˜ต์…˜</div>', unsafe_allow_html=True)
313
+ show_sensitive = st.toggle("๋ฏผ๊ฐ์ •๋ณด ๊ฐ์ง€", value=True)
314
+ show_priority = st.toggle("์šฐ์„ ์ˆœ์œ„ ์ •๋ ฌ", value=True)
315
+ tts_enabled = st.toggle("์Œ์„ฑ ๋‹ต๋ณ€ (TTS)", value=False)
316
+
317
+ st.markdown('<div style="margin-top:40px;font-size:0.7rem;color:#2A3550;">MeetingAI v1.3 ยท KT Enterprise</div>',
318
+ unsafe_allow_html=True)
319
+
320
+
321
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
322
+ # ํ—ค๋”
323
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
324
+ st.markdown("""
325
+ <div style="display:flex;align-items:center;gap:14px;padding:18px 24px;
326
+ background:linear-gradient(135deg,#16213E 0%,#0F3460 100%);
327
+ border-bottom:2px solid #E3000B;border-radius:12px;margin-bottom:20px;">
328
+ <div style="font-family:'Rajdhani',sans-serif;font-size:2.2rem;font-weight:700;
329
+ color:#E3000B;letter-spacing:2px;line-height:1;">KT</div>
330
+ <div>
331
+ <div style="font-size:1.1rem;font-weight:600;color:#fff;line-height:1.3;">
332
+ MeetingAI ยท ํšŒ์˜ ๋ถ„์„ ์–ด์‹œ์Šคํ„ดํŠธ</div>
333
+ <div style="font-size:0.76rem;color:#8892A4;letter-spacing:0.5px;">
334
+ IT๊ธฐ์ˆ ํ˜์‹ ํŒ€ DX Consulting ยท AI ๊ธฐ๋ฐ˜ ํšŒ์˜ ์ž๋™ํ™” ์„œ๋น„์Šค</div>
335
+ </div>
336
+ </div>
337
+ """, unsafe_allow_html=True)
338
 
339
+
340
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
341
+ # ์ž…๋ ฅ ์˜์—ญ
342
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
343
+ st.markdown('<div class="input-title">๐ŸŽ™ ํšŒ์˜ ๋‚ด์šฉ ์ž…๋ ฅ</div>', unsafe_allow_html=True)
344
+
345
+ transcript_input = ""
346
+ with st.container(border=True):
347
+ if input_mode == "๐ŸŽ™๏ธ ์Œ์„ฑ ๋…น์Œ":
348
+ audio_value = st.audio_input("์Œ์„ฑ์œผ๋กœ ํšŒ์˜ ๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
349
+ if audio_value:
350
+ st.session_state.audio_bytes = audio_value
351
+
352
+ elif input_mode == "๐Ÿ“ ํŒŒ์ผ ์—…๋กœ๋“œ":
353
+ ca, cb = st.columns(2)
354
+ with ca:
355
+ audio_file = st.file_uploader("์Œ์„ฑ ํŒŒ์ผ (mp3/wav/m4a/ogg)",
356
+ type=["mp3","wav","m4a","ogg"])
357
+ with cb:
358
+ text_file = st.file_uploader("ํ…์ŠคํŠธ ํŒŒ์ผ (txt)", type=["txt"])
359
+ if audio_file: st.session_state.audio_bytes = audio_file
360
+ if text_file: transcript_input = text_file.read().decode("utf-8")
361
+
362
+ else:
363
+ transcript_input = st.text_area(
364
+ "ํšŒ์˜ ๋‚ด์šฉ", height=180, label_visibility="collapsed",
365
+ placeholder="์˜ˆ) ํŒ€์žฅ: ์˜ค๋Š˜ ํšŒ์˜ ์ฃผ์ œ๋Š” ์‹ ์ œํ’ˆ ์ถœ์‹œ ๋งˆ์ผ€ํŒ… ์ „๋žต์ž…๋‹ˆ๋‹ค...",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  )
 
367
 
368
+ st.button("๐Ÿ” ํšŒ์˜ ๋ถ„์„ ์‹œ์ž‘", use_container_width=True, key="analyze_btn")
369
+
370
+
371
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
372
+ # ๋ถ„์„ ์‹คํ–‰
373
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
374
+ if st.session_state.get("analyze_btn"):
375
+ final_text = transcript_input.strip()
376
+
377
+ if not final_text and st.session_state.audio_bytes:
378
+ with st.spinner("๐ŸŽ™๏ธ ์Œ์„ฑ์„ ํ…์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ค‘..."):
379
+ try:
380
+ src = st.session_state.audio_bytes
381
+ fname = getattr(src, "name", "audio.wav")
382
+ ext = fname.rsplit(".",1)[-1].lower() if "." in fname else "wav"
383
+ mime = {"mp3":"audio/mpeg","wav":"audio/wav",
384
+ "m4a":"audio/mp4","ogg":"audio/ogg"}.get(ext,"audio/wav")
385
+ final_text = stt((fname, src, mime))
386
+ st.session_state.transcript = final_text
387
+ except Exception as e:
388
+ st.error(f"STT ์˜ค๋ฅ˜: {e}"); st.stop()
389
+ elif final_text:
390
+ st.session_state.transcript = final_text
391
+
392
+ if not st.session_state.transcript:
393
+ st.warning("โš ๏ธ ์Œ์„ฑ ๋˜๋Š” ํ…์ŠคํŠธ๏ฟฝ๏ฟฝ ๋จผ์ € ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”."); st.stop()
394
+
395
+ with st.spinner("๐Ÿค– ํšŒ์˜ ๋‚ด์šฉ์„ ๋ถ„์„ํ•˜๋Š” ์ค‘..."):
396
+ try:
397
+ st.session_state.analysis = analyze_meeting(st.session_state.transcript)
398
+ st.session_state.mail_body = ""
399
+ st.session_state.tts_bytes = None
400
+ except Exception as e:
401
+ st.error(f"๋ถ„์„ ์˜ค๋ฅ˜: {e}"); st.stop()
402
+
403
+ if tts_enabled and st.session_state.analysis:
404
+ with st.spinner("๐Ÿ”Š ์Œ์„ฑ ๋‹ต๋ณ€ ์ƒ์„ฑ ์ค‘..."):
405
+ try:
406
+ st.session_state.tts_bytes = generate_tts(
407
+ st.session_state.analysis.get("summary",""))
408
+ except Exception as e:
409
+ st.warning(f"TTS ์˜ค๋ฅ˜: {e}")
410
+
411
+
412
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
413
+ # ๊ฒฐ๊ณผ ์ถœ๋ ฅ
414
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
415
+ if st.session_state.analysis:
416
+ a = st.session_state.analysis
417
+
418
+ if st.session_state.tts_bytes:
419
+ st.audio(st.session_state.tts_bytes, format="audio/mp3", autoplay=True)
420
+
421
+ # ๋ฏผ๊ฐ์ •๋ณด ๊ฒฝ๊ณ 
422
+ if show_sensitive:
423
+ hits = detect_sensitive(st.session_state.transcript)
424
+ if hits:
425
+ labels = " | ".join(f"โš ๏ธ {s}" for s in hits)
426
+ st.markdown(
427
+ f'<div style="background:rgba(255,68,68,0.07);border:1px solid rgba(255,68,68,0.35);'
428
+ f'border-radius:12px;padding:14px 20px;margin-bottom:16px;">'
429
+ f'<div style="font-size:0.85rem;font-weight:700;color:#FF4444;margin-bottom:6px;">๐Ÿ”’ ๋ฏผ๊ฐ์ •๋ณด ๊ฐ์ง€๋จ</div>'
430
+ f'<div style="font-size:0.82rem;color:#ffaaaa;line-height:1.6;">{labels}<br>'
431
+ f'์™ธ๋ถ€ ๊ณต์œ  ์‹œ ๋‚ด๋ถ€ ๋ณด์•ˆ ์ •์ฑ…์— ๋”ฐ๋ผ ์ฒ˜๋ฆฌํ•˜์„ธ์š”. ์ด๋ฉ”์ผ ๋ฐœ์†ก ์‹œ ๋ณด์•ˆ ํ‚ค์›Œ๋“œ ํฌํ•จ ๋‚ด์šฉ์€ ์ž๋™ ์ฐจ๋‹จ๋ฉ๋‹ˆ๋‹ค.</div>'
432
+ f'</div>',
433
+ unsafe_allow_html=True,
434
+ )
435
+
436
+ tab1, tab2, tab3, tab4 = st.tabs([
437
+ "๐Ÿ“‹ ํšŒ์˜ ์š”์•ฝ","โœ… ํ•  ์ผ & ์šฐ์„ ์ˆœ์œ„","๐Ÿ“„ ์›๋ฌธ & ํ‚ค์›Œ๋“œ","โœ‰๏ธ ๋ฆฌ๋งˆ์ธ๋“œ ๋ฉ”์ผ"
438
+ ])
439
+
440
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
441
+ # ํƒญ1: ํšŒ์˜ ์š”์•ฝ โ€” ๋ชจ๋“  HTML์„ inline style๋กœ, st.markdown ์ตœ์†Œ ํ˜ธ์ถœ
442
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
443
+ with tab1:
444
+ # ํšŒ์˜ ๊ฐœ์š”
445
+ st.markdown(
446
+ f'<div style="{S["card"]}">'
447
+ f'<div style="{S["card_title"]}">๐Ÿ“Œ ํšŒ์˜ ๊ฐœ์š”</div>'
448
+ f'<div style="font-size:1.1rem;font-weight:700;color:#fff;margin-bottom:10px;">'
449
+ f'{a.get("meeting_title","โ€”")}</div>'
450
+ f'<div style="font-size:0.875rem;color:#C8D0DC;line-height:1.75;">'
451
+ f'{a.get("purpose","โ€”")}</div>'
452
+ f'</div>',
453
+ unsafe_allow_html=True,
454
+ )
455
+
456
+ # ๊ฒฐ์ •๋œ ์‚ฌํ•ญ HTML ์กฐ๋ฆฝ
457
+ dec_rows = "".join(
458
+ f'<div style="{S["timeline_row"]}">'
459
+ f'<div style="{S["timeline_dot"]}"></div>'
460
+ f'<div style="{S["timeline_text"]}">{d}</div>'
461
+ f'</div>'
462
+ for d in a.get("decisions", [])
463
+ ) or f'<div style="color:#8892A4;font-size:0.85rem;">๊ฒฐ์ • ์‚ฌํ•ญ ์—†์Œ</div>'
464
+
465
+ # ์ฃผ์š” ์•ˆ๊ฑด HTML ์กฐ๋ฆฝ (๊ฒฐ์ •๋œ ์‚ฌํ•ญ๊ณผ ๋™์ผํ•œ ๋นจ๊ฐ„ ์›ํ˜• ์ )
466
+ ag_rows = "".join(
467
+ f'<div style="{S["timeline_row"]}">'
468
+ f'<div style="{S["timeline_dot"]}"></div>'
469
+ f'<div style="{S["timeline_text"]}">{ag}</div>'
470
+ f'</div>'
471
+ for ag in a.get("agenda_items", [])
472
+ ) or f'<div style="color:#8892A4;font-size:0.85rem;">์•ˆ๊ฑด ์—†์Œ</div>'
473
+
474
+ next_html = ""
475
+ if a.get("next_meeting"):
476
+ next_html = (
477
+ f'<div style="margin-top:14px;padding:9px 14px;'
478
+ f'background:rgba(0,200,151,0.08);border-radius:8px;'
479
+ f'border:1px solid rgba(0,200,151,0.22);">'
480
+ f'<span style="font-size:0.76rem;color:#00C897;font-weight:600;">๐Ÿ“… ๋‹ค์Œ ํšŒ์˜</span>'
481
+ f'<div style="font-size:0.85rem;color:#C8D0DC;margin-top:3px;">{a["next_meeting"]}</div>'
482
+ f'</div>'
483
+ )
484
+
485
+ # ๊ฒฐ์ •๋œ ์‚ฌํ•ญ + ์ฃผ์š” ์•ˆ๊ฑด: CSS grid 2์—ด, st.markdown 1ํšŒ
486
+ st.markdown(
487
+ f'<div style="display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px;">'
488
+ f'<div style="{S["card"]}margin-bottom:0;">'
489
+ f'<div style="{S["card_title"]}">โœ… ๊ฒฐ์ •๋œ ์‚ฌํ•ญ</div>{dec_rows}</div>'
490
+ f'<div style="{S["card"]}margin-bottom:0;">'
491
+ f'<div style="{S["card_title"]}">๐Ÿ“Œ ์ฃผ์š” ์•ˆ๊ฑด</div>{ag_rows}{next_html}</div>'
492
+ f'</div>',
493
+ unsafe_allow_html=True,
494
+ )
495
+
496
+ # ์ „์ฒด ์š”์•ฝ
497
+ st.markdown(
498
+ f'<div style="{S["card"]}">'
499
+ f'<div style="{S["card_title"]}">๐Ÿ’ฌ ์ „์ฒด ์š”์•ฝ</div>'
500
+ f'<div style="font-size:0.9rem;color:#C8D0DC;line-height:1.85;'
501
+ f'border-left:3px solid #E3000B;padding-left:16px;">'
502
+ f'{a.get("summary","โ€”")}</div>'
503
+ f'</div>',
504
+ unsafe_allow_html=True,
505
+ )
506
+
507
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
508
+ # ํƒญ2: ํ•  ์ผ & ์šฐ์„ ์ˆœ์œ„
509
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
510
+ with tab2:
511
+ tasks = list(a.get("tasks", []))
512
+ if show_priority:
513
+ tasks = sorted(tasks,
514
+ key=lambda t: {"high":0,"medium":1,"low":2}.get(t.get("priority","low"),3))
515
+
516
+ n_h = sum(1 for t in tasks if t.get("priority")=="high")
517
+ n_m = sum(1 for t in tasks if t.get("priority")=="medium")
518
+ n_l = sum(1 for t in tasks if t.get("priority")=="low")
519
+
520
+ st.markdown(
521
+ f'<div style="display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px;">'
522
+ f'<span style="{S["badge_high"]}">๐Ÿ”ด ๋†’์Œ {n_h}๊ฑด</span>'
523
+ f'<span style="{S["badge_med"]}">๐ŸŸก ๋ณดํ†ต {n_m}๊ฑด</span>'
524
+ f'<span style="{S["badge_low"]}">๐ŸŸข ๋‚ฎ์Œ {n_l}๊ฑด</span>'
525
+ f'<span style="{S["badge_gray"]}">์ „์ฒด {len(tasks)}๊ฑด</span>'
526
+ f'</div>',
527
+ unsafe_allow_html=True,
528
+ )
529
+
530
+ if tasks:
531
+ tasks_html = ""
532
+ for t in tasks:
533
+ p = t.get("priority","low")
534
+ border = PRIORITY_BORDER.get(p,"#E3000B")
535
+ bkey = PRIORITY_BADGE_KEY.get(p,"badge_gray")
536
+ dl = (f'<div style="font-size:0.72rem;color:#FFB800;white-space:nowrap;margin-top:2px;">โฐ {t["deadline"]}</div>'
537
+ if t.get("deadline") else "")
538
+ tasks_html += (
539
+ f'<div style="display:flex;align-items:flex-start;gap:14px;padding:12px 16px;'
540
+ f'background:rgba(15,52,96,0.45);border-left:3px solid {border};'
541
+ f'border-radius:0 8px 8px 0;margin-bottom:8px;">'
542
+ f'<div style="min-width:72px;">'
543
+ f'<div style="font-size:0.78rem;font-weight:700;color:#fff;margin-bottom:4px;">{t.get("person","โ€”")}</div>'
544
+ f'<span style="{S[bkey]}">{PRIORITY_LABEL.get(p,"โ€”")}</span>'
545
+ f'</div>'
546
+ f'<div style="font-size:0.875rem;color:#F0F4F8;flex:1;line-height:1.55;">{t.get("task","โ€”")}</div>'
547
+ f'{dl}'
548
+ f'</div>'
549
+ )
550
+ st.markdown(tasks_html, unsafe_allow_html=True)
551
+ else:
552
+ st.markdown(
553
+ '<div style="padding:24px;text-align:center;color:#8892A4;font-size:0.875rem;">ํ• ๋‹น๋œ ์—…๋ฌด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</div>',
554
+ unsafe_allow_html=True,
555
+ )
556
+
557
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
558
+ # ํƒญ3: ์›๋ฌธ & ํ‚ค์›Œ๋“œ
559
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
560
+ with tab3:
561
+ keywords = a.get("keywords", [])
562
+ if keywords:
563
+ kw_html = "".join(
564
+ f'<span style="{S["badge_gray"]}margin:3px 2px;">{k}</span>'
565
+ for k in keywords
566
+ )
567
+ st.markdown(
568
+ f'<div style="{S["card"]}">'
569
+ f'<div style="{S["card_title"]}">๐Ÿ”‘ ํ•ต์‹ฌ ํ‚ค์›Œ๋“œ</div>'
570
+ f'<div style="display:flex;flex-wrap:wrap;gap:2px;line-height:2.2;">{kw_html}</div>'
571
+ f'</div>',
572
+ unsafe_allow_html=True,
573
+ )
574
+
575
+ with st.expander("๐Ÿ“„ ์ „์‚ฌ ์›๋ฌธ ๋ณด๊ธฐ", expanded=False):
576
+ st.text_area("์›๋ฌธ", value=st.session_state.transcript,
577
+ height=300, disabled=True, label_visibility="collapsed")
578
+
579
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
580
+ # ํƒญ4: ๋ฆฌ๋งˆ์ธ๋“œ ๋ฉ”์ผ
581
+ # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
582
+ with tab4:
583
+ if not email_enabled:
584
+ st.markdown(
585
+ '<div style="padding:40px;text-align:center;color:#8892A4;">'
586
+ '<div style="font-size:3rem;margin-bottom:14px;">โœ‰๏ธ</div>'
587
+ '<div style="font-size:0.9rem;">์‚ฌ์ด๋“œ๋ฐ”์—์„œ <b style="color:#fff;">๋ฆฌ๋งˆ์ธ๋“œ ๋ฉ”์ผ ๋ฐœ์†ก</b>์„ ํ™œ์„ฑํ™”ํ•˜์„ธ์š”.</div>'
588
+ '</div>',
589
+ unsafe_allow_html=True,
590
+ )
591
+ else:
592
+ st.button("๐Ÿ“ง ๋ฉ”์ผ ์ดˆ์•ˆ ์ƒ์„ฑ", key="gen_mail_btn")
593
+ if st.session_state.get("gen_mail_btn"):
594
+ with st.spinner("๋ฉ”์ผ ์ดˆ์•ˆ ์ƒ์„ฑ ์ค‘..."):
595
+ st.session_state.mail_body = generate_email_body(a, email_name or "๋‹ด๋‹น์ž")
596
+
597
+ if st.session_state.mail_body:
598
+ edited_body = st.text_area("๋ฉ”์ผ ๋ณธ๋ฌธ (์ˆ˜์ • ๊ฐ€๋Šฅ)",
599
+ value=st.session_state.mail_body, height=280)
600
+ mail_subject = st.text_input("๋ฉ”์ผ ์ œ๋ชฉ",
601
+ value=f"[ํšŒ์˜ ๊ฒฐ๊ณผ ๊ณต์œ ] {a.get('meeting_title','ํšŒ์˜')}")
602
+ st.button("๐Ÿ“ค ๋ฉ”์ผ ๋ฐœ์†ก", key="send_mail_btn")
603
+ if st.session_state.get("send_mail_btn"):
604
+ if not email_recipient:
605
+ st.warning("์ˆ˜์‹ ์ž ์ด๋ฉ”์ผ์„ ์‚ฌ์ด๋“œ๋ฐ”์—์„œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
606
+ else:
607
+ with st.spinner("๋ฐœ์†ก ์ค‘..."):
608
+ result = send_email(email_recipient, mail_subject, edited_body)
609
+ if result["status"] == "success":
610
+ st.success(f"โœ… {email_recipient} ์œผ๋กœ ๋ฉ”์ผ์„ ๋ฐœ์†กํ–ˆ์Šต๋‹ˆ๋‹ค.")
611
+ elif result["status"] == "blocked":
612
+ st.error(f"โ›” ๋ฐœ์†ก ์ฐจ๋‹จ: {result.get('reason','๋ณด์•ˆ ์ •์ฑ…')}")
613
+ else:
614
+ st.error(f"๋ฐœ์†ก ์‹คํŒจ: {result.get('error','์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜')}")