Sangwon78 commited on
Commit
296eb43
ยท
verified ยท
1 Parent(s): 575b61c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +240 -45
app.py CHANGED
@@ -17,7 +17,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY").strip()
17
  ############################
18
  def call_api(content, system_message, max_tokens, temperature, top_p):
19
  response = openai.ChatCompletion.create(
20
- model="gpt-4o-mini",
21
  messages=[
22
  {"role": "system", "content": system_message},
23
  {"role": "user", "content": content},
@@ -29,12 +29,9 @@ def call_api(content, system_message, max_tokens, temperature, top_p):
29
  return response.choices[0].message["content"]
30
 
31
  ############################
32
- # (1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„ ํ•จ์ˆ˜
33
  ############################
34
  def analyze_texts(difficulties, goals):
35
- """
36
- ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ -> gpt-4o-mini (์ตœ์†Œ 4์ค„ ์ด์ƒ, '~์Šต๋‹ˆ๋‹ค.')
37
- """
38
  preview_difficulties = call_api(
39
  content=difficulties,
40
  system_message=(
@@ -62,7 +59,7 @@ def analyze_texts(difficulties, goals):
62
  return preview_difficulties, preview_goals
63
 
64
  ############################
65
- # (2) ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜
66
  ############################
67
  def analyze_financials(
68
  avg_monthly_sales,
@@ -74,9 +71,6 @@ def analyze_financials(
74
  other_cost,
75
  cost_ratio
76
  ):
77
- """
78
- ์žฌ๋ฌด๋ถ„์„: GPT๋กœ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์  ๊ณ„์‚ฐ
79
- """
80
  system_message = (
81
  "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
82
  "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
@@ -108,12 +102,9 @@ def analyze_financials(
108
  )
109
 
110
  ############################
111
- # (3) SWOT ๋ถ„์„ ํ•จ์ˆ˜
112
  ############################
113
  def analyze_swot(strengths, weaknesses, opportunities, threats):
114
- """
115
- SWOT -> gpt-4o-mini
116
- """
117
  system_message = "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
118
  content = f"""
119
  ๊ฐ•์ : {strengths}
@@ -130,12 +121,9 @@ def analyze_swot(strengths, weaknesses, opportunities, threats):
130
  )
131
 
132
  ############################
133
- # (4) ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜
134
  ############################
135
  def analyze_market(region, industry):
136
- """
137
- ์ƒ๊ถŒ๋ถ„์„ -> gpt-4o-mini (6์ค„ ์ด๋‚ด)
138
- """
139
  system_message = (
140
  "๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
141
  "์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
@@ -153,34 +141,241 @@ def analyze_market(region, industry):
153
  )
154
 
155
  ############################
156
- # (5) ์—ฌ๋Ÿฌ ํ•จ์ˆ˜: SWOT->EXE, ์žฌ๋ฌด->EXE, ์ƒ๊ถŒ->EXE, ์• ๋กœ์‚ฌํ•ญ->EXE
157
- # (์ด์ „ ์ฝ”๋“œ ์œ ์ง€)
158
  ############################
159
 
160
  def export_swot_excel(strengths, weaknesses, opportunities, threats):
161
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
- def generate_financial_excel(...):
164
- pass
 
 
165
 
166
- def export_market_excel(...):
167
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
- def generate_excel_top8_and_consulting(...):
170
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  ############################
173
- # (โ˜…) ์ตœ์ข… ํ•˜๋‚˜์˜ run_all_in_one
174
  ############################
175
- def run_all_in_one(...):
176
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  ############################
179
  # Gradio UI
180
  ############################
181
  def main():
182
  with gr.Blocks() as demo:
183
- gr.Markdown("## (๋‹จ์ผ ํŽ˜์ด์ง€) ๋‹ค์‹œ ์ด์ „ ์ƒํƒœ ๋ณต์›")
184
 
185
  # [1] ์ƒ๋‹จ 8๊ฐœ
186
  with gr.Row():
@@ -200,16 +395,14 @@ def main():
200
  # [2] ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
201
  difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3)
202
  goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3)
203
-
204
- # โ˜… ๋ณต์›: '๋ถ„์„ํ•˜๊ธฐ' ๋ฒ„ํŠผ
205
- analyze_button = gr.Button("์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„ํ•˜๊ธฐ")
206
- preview_difficulties_output = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ", lines=3)
207
- preview_goals_output = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ", lines=3)
208
-
209
  analyze_button.click(
210
  fn=analyze_texts,
211
  inputs=[difficulties_input, goals_input],
212
- outputs=[preview_difficulties_output, preview_goals_output]
213
  )
214
 
215
  gr.Markdown("---")
@@ -227,13 +420,13 @@ def main():
227
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
228
  threats_input = gr.Textbox(label="์œ„ํ˜‘")
229
 
230
- # โ˜… ๋ณต์›: 'SWOT ๋ถ„์„ํ•˜๊ธฐ' ๋ฒ„ํŠผ
231
  swot_button = gr.Button("SWOT ๋ถ„์„ํ•˜๊ธฐ")
232
- swot_result_output = gr.Textbox(label="SWOT ๊ฒฐ๊ณผ")
233
  swot_button.click(
234
  fn=analyze_swot,
235
  inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
236
- outputs=swot_result_output
237
  )
238
 
239
  gr.Markdown("---")
@@ -251,15 +444,16 @@ def main():
251
  other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
252
  cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
253
 
254
- # (๋ถ„์„ํ•˜๊ธฐ ๋ฒ„ํŠผ ์—†์ด, run_all_in_one์—์„œ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ)
 
255
 
256
  gr.Markdown("---")
257
 
258
  # [6] ์ƒ๊ถŒ๋ถ„์„
259
  region_input = gr.Textbox(label="์ง€์—ญ")
260
  industry_input = gr.Textbox(label="์—…์ข…")
261
-
262
- # (๋ถ„์„ํ•˜๊ธฐ ๋ฒ„ํŠผ ์—†์ด, run_all_in_one์—์„œ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ)
263
 
264
  gr.Markdown("---")
265
 
@@ -267,6 +461,7 @@ def main():
267
  all_in_one_button = gr.Button("๋ชจ๋‘ ์ž…๋ ฅ ํ›„, Excel ๋‹ค์šด๋กœ๋“œ")
268
  all_in_one_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
269
 
 
270
  all_in_one_button.click(
271
  fn=run_all_in_one,
272
  inputs=[
@@ -303,8 +498,8 @@ def main():
303
  photo_input_2,
304
  difficulties_input,
305
  goals_input,
306
- preview_difficulties_output,
307
- preview_goals_output
308
  ],
309
  outputs=[all_in_one_file]
310
  )
 
17
  ############################
18
  def call_api(content, system_message, max_tokens, temperature, top_p):
19
  response = openai.ChatCompletion.create(
20
+ model="gpt-4o-mini", # gpt-4o-mini ๋ชจ๋ธ ์‚ฌ์šฉ
21
  messages=[
22
  {"role": "system", "content": system_message},
23
  {"role": "user", "content": content},
 
29
  return response.choices[0].message["content"]
30
 
31
  ############################
32
+ # (1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
33
  ############################
34
  def analyze_texts(difficulties, goals):
 
 
 
35
  preview_difficulties = call_api(
36
  content=difficulties,
37
  system_message=(
 
59
  return preview_difficulties, preview_goals
60
 
61
  ############################
62
+ # (2) ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
63
  ############################
64
  def analyze_financials(
65
  avg_monthly_sales,
 
71
  other_cost,
72
  cost_ratio
73
  ):
 
 
 
74
  system_message = (
75
  "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
76
  "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
 
102
  )
103
 
104
  ############################
105
+ # (3) SWOT ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
106
  ############################
107
  def analyze_swot(strengths, weaknesses, opportunities, threats):
 
 
 
108
  system_message = "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
109
  content = f"""
110
  ๊ฐ•์ : {strengths}
 
121
  )
122
 
123
  ############################
124
+ # (4) ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
125
  ############################
126
  def analyze_market(region, industry):
 
 
 
127
  system_message = (
128
  "๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
129
  "์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
 
141
  )
142
 
143
  ############################
144
+ # (5) ํ•จ์ˆ˜๋“ค: SWOT->EXE, ์žฌ๋ฌด->EXE, ์ƒ๊ถŒ->EXE, ์• ๋กœ์‚ฌํ•ญ->EXE
145
+ # (๊ธฐ์กด์— ๊ฐ๊ฐ ๋ฒ„ํŠผ์ด ์žˆ์—ˆ์œผ๋‚˜, ์—ฌ๊ธฐ์„œ๋Š” ํ•˜๋‚˜๋กœ ํ•ฉ์น  ์˜ˆ์ •)
146
  ############################
147
 
148
  def export_swot_excel(strengths, weaknesses, opportunities, threats):
149
+ """
150
+ ๊ธฐ์กด run_export_swot_excel() ๋‚ด์šฉ
151
+ """
152
+ wb = load_workbook("EXE.xlsx")
153
+ ws = wb.active
154
+
155
+ ws.merge_cells("D45:H45")
156
+ ws["D45"] = strengths
157
+ ws["D45"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
158
+
159
+ ws.merge_cells("D54:H54")
160
+ ws["D54"] = weaknesses
161
+ ws["D54"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
162
+
163
+ ws.merge_cells("D63:H63")
164
+ ws["D63"] = opportunities
165
+ ws["D63"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
166
+
167
+ ws.merge_cells("D72:H72")
168
+ ws["D72"] = threats
169
+ ws["D72"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
170
+
171
+ # ์ž„์‹œ ์ €์žฅ
172
+ output = BytesIO()
173
+ wb.save(output)
174
+ output.seek(0)
175
+
176
+ # overwrite EXE.xlsx
177
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
178
+ tmp.write(output.getvalue())
179
+ tmp.flush()
180
+ temp_file_path = tmp.name
181
+
182
+ final_path = os.path.join(os.path.dirname(temp_file_path), "EXE.xlsx")
183
+ os.rename(temp_file_path, final_path)
184
+ return final_path # ํŒŒ์ผ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
185
+
186
+
187
+ def generate_financial_excel(
188
+ avg_monthly_sales,
189
+ rent,
190
+ labor_cost,
191
+ management_cost,
192
+ utilities,
193
+ current_interest,
194
+ other_cost,
195
+ cost_ratio
196
+ ):
197
+ """
198
+ ๊ธฐ์กด run_generate_financial_excel() ๋‚ด์šฉ
199
+ (EX) 12๊ฐœ ํ•ญ๋ชฉ E87..G87 ~ E98..G98
200
+ """
201
+ # 1) GPT ํ˜ธ์ถœ
202
+ fin_result = analyze_financials(
203
+ avg_monthly_sales,
204
+ rent,
205
+ labor_cost,
206
+ management_cost,
207
+ utilities,
208
+ current_interest,
209
+ other_cost,
210
+ cost_ratio
211
+ )
212
+ # (์˜ˆ) ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ ๋“ฑ ํŒŒ์‹ฑ ๋กœ์ง
213
+ # ... (์ƒ๋žต)
214
+
215
+ # 2) ์—‘์…€์— ๊ธฐ๋ก (์˜ˆ์‹œ)
216
+ wb = load_workbook("EXE.xlsx")
217
+ ws = wb.active
218
+
219
+ # ws.merge_cells("E87:G87")
220
+ # ws["E87"] = f"์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}"
221
+ # ...
222
+ # (์ƒ๋žต)
223
+
224
+ output = BytesIO()
225
+ wb.save(output)
226
+ output.seek(0)
227
 
228
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
229
+ tmp.write(output.getvalue())
230
+ tmp.flush()
231
+ temp_file_path = tmp.name
232
 
233
+ final_path = os.path.join(os.path.dirname(temp_file_path), "EXE.xlsx")
234
+ os.rename(temp_file_path, final_path)
235
+ return final_path
236
+
237
+
238
+ def export_market_excel(region, industry):
239
+ """
240
+ ๊ธฐ์กด run_export_market_excel() ๋‚ด์šฉ
241
+ (์˜ˆ) ์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ D101:H101
242
+ """
243
+ # 1) GPT
244
+ market_result = analyze_market(region, industry)
245
+
246
+ # 2) ์—‘์…€ ๊ธฐ๋ก
247
+ wb = load_workbook("EXE.xlsx")
248
+ ws = wb.active
249
+
250
+ # ws.merge_cells("D101:H101")
251
+ # ws["D101"] = market_result
252
+ # ...
253
+ # (์ƒ๋žต)
254
+
255
+ output = BytesIO()
256
+ wb.save(output)
257
+ output.seek(0)
258
+
259
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
260
+ tmp.write(output.getvalue())
261
+ tmp.flush()
262
+ temp_file_path = tmp.name
263
+
264
+ final_path = os.path.join(os.path.dirname(temp_file_path), "EXE.xlsx")
265
+ os.rename(temp_file_path, final_path)
266
+ return final_path
267
+
268
+
269
+ def generate_excel_top8_and_consulting(
270
+ consulting_company_rep,
271
+ consulting_address,
272
+ consulting_field,
273
+ client_name,
274
+ consulting_contact,
275
+ consulting_date_time,
276
+ consulting_round,
277
+ consulting_region,
278
+ photo1,
279
+ photo2,
280
+ preview_difficulties,
281
+ preview_goals
282
+ ):
283
+ """
284
+ ๊ธฐ์กด run_generate_excel() ๋‚ด์šฉ
285
+ (์ƒ๋‹จ 8๊ฐœ + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„)
286
+ """
287
+ wb = load_workbook("EXE.xlsx")
288
+ ws = wb.active
289
 
290
+ # ... (์ƒ๋‹จ 8๊ฐœ, D11, D22, B117/F117)
291
+ # (์ƒ๋žต)
292
+
293
+ output = BytesIO()
294
+ wb.save(output)
295
+ output.seek(0)
296
+
297
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
298
+ tmp.write(output.getvalue())
299
+ tmp.flush()
300
+ temp_file_path = tmp.name
301
+
302
+ final_path = os.path.join(os.path.dirname(temp_file_path), "EXE.xlsx")
303
+ os.rename(temp_file_path, final_path)
304
+ return final_path
305
 
306
  ############################
307
+ # (โ˜…) ์ตœ์ข… ํ•˜๋‚˜์˜ ๋ฒ„ํŠผ -> ์œ„ ๊ธฐ๋Šฅ๋“ค ํ•œ๊บผ๋ฒˆ์— ํ˜ธ์ถœ
308
  ############################
309
+ def run_all_in_one(
310
+ # SWOT
311
+ strengths, weaknesses, opportunities, threats,
312
+ # ์žฌ๋ฌด๋ถ„์„
313
+ avg_monthly_sales, rent, labor_cost, management_cost, utilities, current_interest, other_cost, cost_ratio,
314
+ # ์ƒ๊ถŒ๋ถ„์„
315
+ region, industry,
316
+ # ์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„
317
+ consulting_company_rep,
318
+ consulting_address,
319
+ consulting_field,
320
+ client_name,
321
+ consulting_contact,
322
+ consulting_date_time,
323
+ consulting_round,
324
+ consulting_region,
325
+ photo1,
326
+ photo2,
327
+ difficulties_input,
328
+ goals_input,
329
+ preview_difficulties_state,
330
+ preview_goals_state
331
+ ):
332
+ """
333
+ 1) SWOT -> EXE.xlsx
334
+ 2) ์žฌ๋ฌด๋ถ„์„ -> EXE.xlsx
335
+ 3) ์ƒ๊ถŒ๋ถ„์„ -> EXE.xlsx
336
+ 4) ์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„ -> EXE.xlsx
337
+ => ์ตœ์ข… ์™„์„ฑ๋œ EXE.xlsx ๊ฒฝ๋กœ ๋ฆฌํ„ด
338
+ """
339
+ # 1) SWOT
340
+ export_swot_excel(strengths, weaknesses, opportunities, threats)
341
+ # 2) ์žฌ๋ฌด๋ถ„์„
342
+ generate_financial_excel(
343
+ avg_monthly_sales,
344
+ rent,
345
+ labor_cost,
346
+ management_cost,
347
+ utilities,
348
+ current_interest,
349
+ other_cost,
350
+ cost_ratio
351
+ )
352
+ # 3) ์ƒ๊ถŒ๋ถ„์„
353
+ export_market_excel(region, industry)
354
+ # 4) ์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„
355
+ final_path = generate_excel_top8_and_consulting(
356
+ consulting_company_rep,
357
+ consulting_address,
358
+ consulting_field,
359
+ client_name,
360
+ consulting_contact,
361
+ consulting_date_time,
362
+ consulting_round,
363
+ consulting_region,
364
+ photo1,
365
+ photo2,
366
+ preview_difficulties_state,
367
+ preview_goals_state
368
+ )
369
+
370
+ return final_path
371
+
372
 
373
  ############################
374
  # Gradio UI
375
  ############################
376
  def main():
377
  with gr.Blocks() as demo:
378
+ gr.Markdown("## (๋‹จ์ผ ํŽ˜์ด์ง€) ๋ฒ„ํŠผ ํ•˜๋‚˜๋กœ EXE.xlsx ๋‹ค์šด")
379
 
380
  # [1] ์ƒ๋‹จ 8๊ฐœ
381
  with gr.Row():
 
395
  # [2] ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
396
  difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3)
397
  goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3)
398
+ analyze_button = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
399
+ # ํ™”๋ฉด ํ‘œ์‹œ ์—†์ด state์—๋งŒ ์ €์žฅ
400
+ preview_difficulties_state = gr.State()
401
+ preview_goals_state = gr.State()
 
 
402
  analyze_button.click(
403
  fn=analyze_texts,
404
  inputs=[difficulties_input, goals_input],
405
+ outputs=[preview_difficulties_state, preview_goals_state]
406
  )
407
 
408
  gr.Markdown("---")
 
420
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
421
  threats_input = gr.Textbox(label="์œ„ํ˜‘")
422
 
423
+ # GPT๋งŒ ํ˜ธ์ถœ, ๊ฒฐ๊ณผ state
424
  swot_button = gr.Button("SWOT ๋ถ„์„ํ•˜๊ธฐ")
425
+ swot_state = gr.State()
426
  swot_button.click(
427
  fn=analyze_swot,
428
  inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
429
+ outputs=[swot_state]
430
  )
431
 
432
  gr.Markdown("---")
 
444
  other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
445
  cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
446
 
447
+ # ํ™”๋ฉด ํ‘œ์‹œ X. ๋‹จ์ง€ GPT ํ˜ธ์ถœ์‹œ ํ•„์š”ํ•˜๋‹ค๋ฉด ๋ฒ„ํŠผ ๋งŒ๋“ค์–ด๋„ ๋จ
448
+ # (์ƒ๋žต)
449
 
450
  gr.Markdown("---")
451
 
452
  # [6] ์ƒ๊ถŒ๋ถ„์„
453
  region_input = gr.Textbox(label="์ง€์—ญ")
454
  industry_input = gr.Textbox(label="์—…์ข…")
455
+ # ํ™”๋ฉด ํ‘œ์‹œ X. GPT ํ˜ธ์ถœ๋งŒ?
456
+ # (์ƒ๋žต)
457
 
458
  gr.Markdown("---")
459
 
 
461
  all_in_one_button = gr.Button("๋ชจ๋‘ ์ž…๋ ฅ ํ›„, Excel ๋‹ค์šด๋กœ๋“œ")
462
  all_in_one_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
463
 
464
+ # ์ด ๋ฒ„ํŠผ ํด๋ฆญ -> run_all_in_one
465
  all_in_one_button.click(
466
  fn=run_all_in_one,
467
  inputs=[
 
498
  photo_input_2,
499
  difficulties_input,
500
  goals_input,
501
+ preview_difficulties_state,
502
+ preview_goals_state
503
  ],
504
  outputs=[all_in_one_file]
505
  )