Sangwon78 commited on
Commit
009ce32
ยท
verified ยท
1 Parent(s): 2a45a82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +327 -0
app.py CHANGED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import gradio as gr
4
+ from openpyxl import load_workbook
5
+ from io import BytesIO
6
+ import tempfile
7
+
8
+ ##################################
9
+ # (ํ•„์ˆ˜) OpenAI API ํ‚ค ์„ค์ •
10
+ ##################################
11
+ # ํ•„์š”ํ•˜๋‹ค๋ฉด .strip()์„ ์ œ๊ฑฐํ•˜๊ฑฐ๋‚˜ ์œ ์ง€ํ•ด๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.
12
+ openai.api_key = os.getenv("OPENAI_API_KEY").strip()
13
+
14
+ ##################################
15
+ # [api์ž๋ฃŒ]์—์„œ ์ฃผ์–ด์ง„ ํ•จ์ˆ˜ (์ˆ˜์ • ๊ธˆ์ง€)
16
+ ##################################
17
+ def call_api(content, system_message, max_tokens, temperature, top_p):
18
+ response = openai.ChatCompletion.create(
19
+ model="gpt-4o-mini", # ์š”์ฒญ์‚ฌํ•ญ๋Œ€๋กœ gpt-4o-mini ์‚ฌ์šฉ
20
+ messages=[
21
+ {"role": "system", "content": system_message},
22
+ {"role": "user", "content": content},
23
+ ],
24
+ max_tokens=max_tokens,
25
+ temperature=temperature,
26
+ top_p=top_p,
27
+ )
28
+ return response.choices[0].message['content']
29
+
30
+ ##################################
31
+ # 1. ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜ (์ž…๋ ฅ: 8๊ฐœ, ์ถœ๋ ฅ: 4๊ฐœ ์ˆ˜์น˜)
32
+ ##################################
33
+ def analyze_financials(
34
+ avg_monthly_sales, # ์›”ํ‰๊ท ๋งค์ถœ์•ก
35
+ rent, # ์ž„์ฐจ๋ฃŒ
36
+ labor_cost, # ์ธ๊ฑด๋น„
37
+ management_cost, # ๊ด€๋ฆฌ๋น„
38
+ utilities, # ์ˆ˜๋„๊ด‘์—ด๋น„
39
+ current_interest, # ์ง€๊ธˆ์ด์ž
40
+ other_cost, # ๊ธฐํƒ€๋น„์šฉ
41
+ cost_ratio # ์›๊ฐ€์œจ (์ถœ๋ ฅ์—๋Š” ํฌํ•จ ์•ˆ ํ•จ)
42
+ ):
43
+ """
44
+ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ 8๊ฐ€์ง€ ํ•ญ๋ชฉ(์›”ํ‰๊ท ๋งค์ถœ์•ก, ์ž„์ฐจ๋ฃŒ, ์ธ๊ฑด๋น„, ๊ด€๋ฆฌ๋น„, ์ˆ˜๋„๊ด‘์—ด๋น„, ์ง€๊ธˆ์ด์ž, ๊ธฐํƒ€๋น„์šฉ, ์›๊ฐ€์œจ)์„ ๋ฐ”ํƒ•์œผ๋กœ
45
+ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ ๊ณ„์‚ฐ(๋˜๋Š” ์ถ”์ •)ํ•˜์—ฌ,
46
+ ๊ฐ ํ•ญ๋ชฉ๋ณ„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
47
+ (์ถœ๋ ฅ์—์„œ ์›๊ฐ€์œจ์€ ์ œ์™ธ)
48
+ """
49
+ system_message = (
50
+ "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
51
+ "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
52
+ "์ถ”๊ฐ€ ์„ค๋ช…์ด๋‚˜ ๋ฌธ์žฅ ์—†์ด, ํ•ญ๋ชฉ๋ช…๊ณผ ์ˆ˜์น˜๋งŒ ๋ฐ˜ํ™˜ํ•ด์ฃผ์„ธ์š”."
53
+ )
54
+ content = f"""
55
+ ์ž…๋ ฅ๋œ ๋ฐ์ดํ„ฐ:
56
+ - ์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}
57
+ - ์ž„์ฐจ๋ฃŒ: {rent}
58
+ - ์ธ๊ฑด๋น„: {labor_cost}
59
+ - ๊ด€๋ฆฌ๋น„: {management_cost}
60
+ - ์ˆ˜๋„๊ด‘์—ด๋น„: {utilities}
61
+ - ์ง€๊ธˆ์ด์ž: {current_interest}
62
+ - ๊ธฐํƒ€๋น„์šฉ: {other_cost}
63
+ - ์›๊ฐ€์œจ: {cost_ratio}
64
+
65
+ ๋‹ค์Œ ํ•ญ๋ชฉ์˜ ๊ฒฐ๊ณผ๋ฅผ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜ํ•ด ์ฃผ์„ธ์š”:
66
+ 1) ๊ฐ๊ฐ€์ƒ๊ฐ๋น„
67
+ 2) ์ˆœ์ด์ต์œจ
68
+ 3) ์›”์ˆœ์ˆ˜์ต
69
+ 4) ์†์ต๋ถ„๊ธฐ์ 
70
+ """
71
+ return call_api(
72
+ content=content,
73
+ system_message=system_message,
74
+ max_tokens=1024,
75
+ temperature=0.7,
76
+ top_p=1.0
77
+ )
78
+
79
+ ##################################
80
+ # 2. SWOT ๋ถ„์„ ํ•จ์ˆ˜
81
+ ##################################
82
+ def analyze_swot(strengths, weaknesses, opportunities, threats):
83
+ """
84
+ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด
85
+ gpt-4o-mini ๋ชจ๋ธ์„ ํ™œ์šฉํ•ด ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
86
+ """
87
+ system_message = "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
88
+ content = f"""
89
+ ๊ฐ•์ : {strengths}
90
+ ์•ฝ์ : {weaknesses}
91
+ ๊ธฐํšŒ: {opportunities}
92
+ ์œ„ํ˜‘: {threats}
93
+ """
94
+ return call_api(
95
+ content=content,
96
+ system_message=system_message,
97
+ max_tokens=1024,
98
+ temperature=0.7,
99
+ top_p=1.0
100
+ )
101
+
102
+ ##################################
103
+ # 3. ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜ (6์ค„ ์ด๋‚ด)
104
+ ##################################
105
+ def analyze_market(region, industry):
106
+ """
107
+ ์ง€์—ญ, ์—…์ข…์„ ์ž…๋ ฅ๋ฐ›์•„ 1km ์ด๋‚ด ์ƒ๊ถŒ๋ถ„์„์„ '์‚ฌ์ง„ ์–ธ๊ธ‰'๊ณผ ํ•จ๊ป˜,
108
+ 6์ค„ ์ด๋‚ด ํ…์ŠคํŠธ๋กœ ์š”์•ฝํ•ด ์ฃผ๋Š” ํ•จ์ˆ˜
109
+ """
110
+ system_message = (
111
+ "๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
112
+ "์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
113
+ )
114
+ content = f"""
115
+ ์ง€์—ญ: {region}
116
+ ์—…์ข…: {industry}
117
+ """
118
+ return call_api(
119
+ content=content,
120
+ system_message=system_message,
121
+ max_tokens=300,
122
+ temperature=0.7,
123
+ top_p=1.0
124
+ )
125
+
126
+ ##################################
127
+ # 4. ์• ๋กœ์‚ฌํ•ญ & ์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ํ•จ์ˆ˜
128
+ ##################################
129
+ def analyze_texts(difficulties, goals):
130
+ """
131
+ ์‚ฌ์šฉ์ž ์ž…๋ ฅ(์• ๋กœ์‚ฌํ•ญ, ์ปจ์„คํŒ…๋ชฉํ‘œ)์„ gpt-4o-mini๋กœ ๋ถ„์„ ํ›„ ๊ฒฐ๊ณผ(๋ฏธ๋ฆฌ๋ณด๊ธฐ)๋ฅผ ๋ฆฌํ„ด
132
+ """
133
+ # ์• ๋กœ์‚ฌํ•ญ ๋ถ„์„
134
+ preview_difficulties = call_api(
135
+ content=difficulties,
136
+ system_message="์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์• ๋กœ์‚ฌํ•ญ์„ ๊ฐ„๋‹จํžˆ ๋ถ„์„ ๋ฐ ํ•ด๊ฒฐ๋ฐฉ์•ˆ ์ œ์‹œํ•ด์ค˜.",
137
+ max_tokens=50,
138
+ temperature=0.7,
139
+ top_p=0.9
140
+ )
141
+
142
+ # ์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„
143
+ preview_goals = call_api(
144
+ content=goals,
145
+ system_message="์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ปจ์„คํŒ… ๋ชฉํ‘œ์— ๋Œ€ํ•œ ์š”์•ฝ ๋ฐ ์‹คํ–‰๋ฐฉ์•ˆ์„ ์ œ์‹œํ•ด์ค˜.",
146
+ max_tokens=50,
147
+ temperature=0.7,
148
+ top_p=0.9
149
+ )
150
+
151
+ return preview_difficulties, preview_goals
152
+
153
+ ##################################
154
+ # Excel ์ƒ์„ฑ(๋‹ค์šด๋กœ๋“œ) ํ•จ์ˆ˜
155
+ ##################################
156
+ def generate_excel(preview_difficulties, preview_goals):
157
+ """
158
+ 1) 'suu.xlsx'๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ
159
+ 2) A4 = ์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ
160
+ A5 = ์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ
161
+ 3) NamedTemporaryFile๋กœ ์ €์žฅ ํ›„ ํ•ด๋‹น ํŒŒ์ผ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
162
+ """
163
+ wb = load_workbook("suu.xlsx")
164
+ ws = wb.active
165
+
166
+ # A4, A5 ์…€์— ๊ฒฐ๊ณผ ๊ธฐ์ž…
167
+ ws["A4"] = preview_difficulties
168
+ ws["A5"] = preview_goals
169
+
170
+ # ๋ฉ”๋ชจ๋ฆฌ ๋ฒ„ํผ์— ์ €์žฅ
171
+ output = BytesIO()
172
+ wb.save(output)
173
+ output.seek(0)
174
+
175
+ # ์ž„์‹œํŒŒ์ผ๋กœ ๊ธฐ๋ก ํ›„ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
176
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
177
+ tmp.write(output.getvalue())
178
+ tmp_path = tmp.name
179
+
180
+ return tmp_path
181
+
182
+ ##################################
183
+ # Gradio ์ด๋ฒคํŠธ ํ•จ์ˆ˜
184
+ ##################################
185
+ def run_analyze(difficulties, goals):
186
+ """
187
+ '๋ถ„์„ํ•˜๊ธฐ' ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰:
188
+ - gpt-4o-mini API๋กœ ๋ถ„์„ ํ›„ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ํ…์ŠคํŠธ๋ฅผ ๋ฐ˜ํ™˜
189
+ """
190
+ preview_difficulties, preview_goals = analyze_texts(difficulties, goals)
191
+ return preview_difficulties, preview_goals
192
+
193
+ def run_generate_excel(difficulties, goals, preview_difficulties, preview_goals):
194
+ """
195
+ '์—‘์…€๋กœ ๋‹ค์šด๋กœ๋“œ' ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰:
196
+ - generate_excel()๋กœ ์—‘์…€ ํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ ,
197
+ - Gradio File ์ปดํฌ๋„ŒํŠธ๋กœ ๋‹ค์šด๋กœ๋“œ
198
+ """
199
+ excel_path = generate_excel(preview_difficulties, preview_goals)
200
+ # gr.File() ์ปดํฌ๋„ŒํŠธ์— ๋ฐ˜ํ™˜ -> ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค์šด ๊ฐ€๋Šฅ
201
+ return excel_path
202
+
203
+ ##################################
204
+ # Gradio UI ๊ตฌ์„ฑ
205
+ ##################################
206
+ def create_app():
207
+ with gr.Blocks() as demo:
208
+ gr.Markdown("## ํ†ตํ•ฉ Demo - ์žฌ๋ฌด ๋ถ„์„ / SWOT / ์ƒ๊ถŒ / ์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ")
209
+
210
+ with gr.Tabs():
211
+ # =========================
212
+ # ํƒญ1) ์žฌ๋ฌด ๋ถ„์„
213
+ # =========================
214
+ with gr.Tab("์žฌ๋ฌด ๋ถ„์„"):
215
+ gr.Markdown("### (์ž…๋ ฅ์— ์›๊ฐ€์œจ ํฌํ•จ, ๊ฒฐ๊ณผ์—์„œ ์›๊ฐ€์œจ ์ œ์™ธ)")
216
+
217
+ avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
218
+ rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
219
+ labor_cost_input = gr.Textbox(label="์ธ๊ฑด๋น„")
220
+ management_cost_input = gr.Textbox(label="๊ด€๋ฆฌ๋น„")
221
+ utilities_input = gr.Textbox(label="์ˆ˜๋„๊ด‘์—ด๋น„")
222
+ current_interest_input = gr.Textbox(label="์ง€๊ธˆ์ด์ž")
223
+ other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
224
+ cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
225
+
226
+ result_output_fin = gr.Textbox(label="๊ฒฐ๊ณผ(์ œ๋ชฉ: ์ˆ˜์น˜)")
227
+
228
+ analyze_button_fin = gr.Button("๊ณ„์‚ฐํ•˜๊ธฐ")
229
+
230
+ analyze_button_fin.click(
231
+ fn=analyze_financials,
232
+ inputs=[
233
+ avg_monthly_sales_input,
234
+ rent_input,
235
+ labor_cost_input,
236
+ management_cost_input,
237
+ utilities_input,
238
+ current_interest_input,
239
+ other_cost_input,
240
+ cost_ratio_input
241
+ ],
242
+ outputs=result_output_fin
243
+ )
244
+
245
+ # =========================
246
+ # ํƒญ2) SWOT ๋ถ„์„
247
+ # =========================
248
+ with gr.Tab("SWOT ๋ถ„์„"):
249
+ gr.Markdown("### (๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘)")
250
+
251
+ strengths_input = gr.Textbox(label="๊ฐ•์ ")
252
+ weaknesses_input = gr.Textbox(label="์•ฝ์ ")
253
+ opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
254
+ threats_input = gr.Textbox(label="์œ„ํ˜‘")
255
+
256
+ result_output_swot = gr.Textbox(label="SWOT ๋ถ„์„ ๊ฒฐ๊ณผ")
257
+
258
+ analyze_button_swot = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
259
+
260
+ analyze_button_swot.click(
261
+ fn=analyze_swot,
262
+ inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
263
+ outputs=result_output_swot
264
+ )
265
+
266
+ # =========================
267
+ # ํƒญ3) ์ƒ๊ถŒ ๋ถ„์„
268
+ # =========================
269
+ with gr.Tab("์ƒ๊ถŒ ๋ถ„์„"):
270
+ gr.Markdown("### (์ง€์—ญ + ์—…์ข… โ†’ 1km ์ด๋‚ด ์ƒ๊ถŒ๋ถ„์„, 6์ค„ ์ด๋‚ด)")
271
+
272
+ region_input = gr.Textbox(label="์ง€์—ญ")
273
+ industry_input = gr.Textbox(label="์—…์ข…")
274
+
275
+ result_output_market = gr.Textbox(label="์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ (์ตœ๋Œ€ 6์ค„)")
276
+
277
+ analyze_button_market = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
278
+
279
+ analyze_button_market.click(
280
+ fn=analyze_market,
281
+ inputs=[region_input, industry_input],
282
+ outputs=result_output_market
283
+ )
284
+
285
+ # =========================
286
+ # ํƒญ4) ์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ + Excel
287
+ # =========================
288
+ with gr.Tab("์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ ๋ถ„์„"):
289
+ gr.Markdown("### (์• ๋กœ์‚ฌํ•ญ ๋ฐ ์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ -> gpt-4o-mini ๋ถ„์„ -> Excel ๋‹ค์šด๋กœ๋“œ)")
290
+
291
+ with gr.Row():
292
+ difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3)
293
+ goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3)
294
+
295
+ analyze_button = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
296
+
297
+ preview_difficulties_output = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
298
+ preview_goals_output = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
299
+
300
+ download_button = gr.Button("์—‘์…€๋กœ ๋‹ค์šด๋กœ๋“œ")
301
+ download_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
302
+
303
+ # ๋ถ„์„ ๋ฒ„ํŠผ -> ๋ฏธ๋ฆฌ๋ณด๊ธฐ
304
+ analyze_button.click(
305
+ fn=run_analyze,
306
+ inputs=[difficulties_input, goals_input],
307
+ outputs=[preview_difficulties_output, preview_goals_output]
308
+ )
309
+
310
+ # ๋‹ค์šด๋กœ๋“œ ๋ฒ„ํŠผ -> Excel ํŒŒ์ผ ์ƒ์„ฑ
311
+ download_button.click(
312
+ fn=run_generate_excel,
313
+ inputs=[
314
+ difficulties_input, goals_input,
315
+ preview_difficulties_output, preview_goals_output
316
+ ],
317
+ outputs=[download_file]
318
+ )
319
+
320
+ return demo
321
+
322
+ ##################################
323
+ # ์‹คํ–‰
324
+ ##################################
325
+ if __name__ == "__main__":
326
+ app = create_app()
327
+ app.launch()