Sangwon78 commited on
Commit
f579f56
ยท
verified ยท
1 Parent(s): d927e72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +100 -74
app.py CHANGED
@@ -32,6 +32,7 @@ def call_api(content, system_message, max_tokens, temperature, top_p):
32
  # 1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„
33
  ######################
34
  def analyze_texts(difficulties, goals):
 
35
  preview_difficulties = call_api(
36
  content=difficulties,
37
  system_message=(
@@ -43,6 +44,7 @@ def analyze_texts(difficulties, goals):
43
  temperature=0.7,
44
  top_p=0.9,
45
  )
 
46
  preview_goals = call_api(
47
  content=goals,
48
  system_message=(
@@ -57,19 +59,22 @@ def analyze_texts(difficulties, goals):
57
  return preview_difficulties, preview_goals
58
 
59
  ######################
60
- # 2) SWOT ๋ถ„์„ (4์นธ)
61
  ######################
62
  def analyze_swot(strengths, weaknesses, opportunities, threats):
63
  """
64
- ๊ธฐ์กด์—๋Š” 4์ค„๋งŒ ์š”์ฒญํ–ˆ์œผ๋‚˜,
65
- ์ง€๊ธˆ์€ ๊ฐ ํ•ญ๋ชฉ์„ 5์ค„ ์ •๋„๋กœ ์ž์„ธํžˆ ์ž‘์„ฑํ•˜๋„๋ก ์•ˆ๋‚ด.
66
- ๊ทธ๋ž˜๋„ ์ตœ์ข… ๊ฒฐ๊ณผ์—๋Š” '๊ฐ•์ :', '์•ฝ์ :', '๊ธฐํšŒ:', '์œ„ํ˜‘:' 4๊ฐœ ์ค„๋งŒ ๋ถ„๋ฆฌํ•ด์„œ ๋„ฃ์Œ.
67
  """
68
  system_message = (
69
  "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. "
70
- "์ž…๋ ฅ๋œ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์„ ๊ฐ๊ฐ ์•ฝ 5์ค„ ์ •๋„๋กœ ์ž์„ธํžˆ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. "
71
- "๊ฐ ํ•ญ๋ชฉ์€ '๊ฐ•์ :', '์•ฝ์ :', '๊ธฐํšŒ:', '์œ„ํ˜‘:'์œผ๋กœ ์‹œ์ž‘ํ•˜๊ณ , "
72
- "๋ถˆํ•„์š”ํ•œ ๋‚˜์—ด ์—†์ด '~์Šต๋‹ˆ๋‹ค.'๋กœ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋งˆ๋ฌด๋ฆฌํ•ด์ฃผ์„ธ์š”."
 
 
 
 
73
  )
74
  content = f"""
75
  ๊ฐ•์ : {strengths}
@@ -80,13 +85,13 @@ def analyze_swot(strengths, weaknesses, opportunities, threats):
80
  return call_api(
81
  content=content,
82
  system_message=system_message,
83
- max_tokens=800, # 5์ค„ ์ •๋„ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ์—ฌ์œ  ์ฆ๋Ÿ‰
84
  temperature=0.7,
85
  top_p=1.0
86
  )
87
 
88
  ######################
89
- # 3) ์žฌ๋ฌด ๋ถ„์„ (4์ค„)
90
  ######################
91
  def analyze_financials(
92
  avg_monthly_sales,
@@ -98,38 +103,54 @@ def analyze_financials(
98
  other_cost,
99
  cost_ratio
100
  ):
 
 
 
 
 
 
101
  system_message = (
102
- "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
103
- "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
104
- "์ถ”๊ฐ€ ์„ค๋ช… ์—†์ด ํ•ญ๋ชฉ๋ช…: ๊ฐ’ ํ˜•ํƒœ๋งŒ."
 
 
105
  )
106
  content = f"""
107
  ์ž…๋ ฅ:
108
- - ์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}
109
- - ์ž„์ฐจ๋ฃŒ: {rent}
110
- - ์ธ๊ฑด๋น„: {labor_cost}
111
- - ๊ด€๋ฆฌ๋น„: {management_cost}
112
- - ์ˆ˜๋„๊ด‘์—ด๋น„: {utilities}
113
- - ์ง€๊ธˆ์ด์ž: {current_interest}
114
- - ๊ธฐํƒ€๋น„์šฉ: {other_cost}
115
- - ์›๊ฐ€์œจ: {cost_ratio}
116
-
117
- ๊ฒฐ๊ณผ ํ•ญ๋ชฉ:
118
- 1) ๊ฐ๊ฐ€์ƒ๊ฐ๋น„
119
- 2) ์ˆœ์ด์ต์œจ
120
- 3) ์›”์ˆœ์ˆ˜์ต
121
- 4) ์†์ต๋ถ„๊ธฐ์ 
 
 
 
 
 
 
 
 
122
  """
123
  return call_api(
124
  content=content,
125
  system_message=system_message,
126
- max_tokens=500,
127
  temperature=0.7,
128
  top_p=1.0
129
  )
130
 
131
  ######################
132
- # 4) ์ƒ๊ถŒ ๋ถ„์„ (1์ค„)
133
  ######################
134
  def analyze_market(region, industry):
135
  system_message = (
@@ -149,7 +170,7 @@ def analyze_market(region, industry):
149
  )
150
 
151
  ######################
152
- # ์ตœ์ข…: ํ•œ ๋ฒˆ์— EXE.xlsx ์ž‘์„ฑ
153
  ######################
154
  def run_all_in_one(
155
  # (A) ์ƒ๋‹จ 8๊ฐœ
@@ -172,7 +193,7 @@ def run_all_in_one(
172
  opportunities_input,
173
  threats_input,
174
 
175
- # (D) ์žฌ๋ฌด๋ถ„์„(4์ค„)
176
  avg_monthly_sales,
177
  rent,
178
  labor_cost,
@@ -186,39 +207,41 @@ def run_all_in_one(
186
  region_input,
187
  industry_input,
188
 
189
- # (F) ์‚ฌ์ง„
190
  photo1,
191
  photo2
192
  ):
193
  """
194
- - D11, D22 => ์• ๋กœ์‚ฌํ•ญ, ์ปจ์„คํŒ…๋ชฉํ‘œ: ๋ชจ๋‘ ์ˆ˜ํ‰+์ˆ˜์ง ๊ฐ€์šด๋ฐ ์ •๋ ฌ
195
- - SWOT ๊ฒฐ๊ณผ: ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘ (4์ค„), ๋‚ด์šฉ์€ ๊ฐ ํ•ญ๋ชฉ 5์ค„ ์ •๋„
196
- - ์žฌ๋ฌด๋ถ„์„ 4์ค„(E87~E90)
197
- - ์ƒ๊ถŒ๋ถ„์„ 1์ค„(D101)
 
 
198
  """
199
 
200
- # 1) GPT: ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
201
  preview_difficulties, preview_goals = analyze_texts(difficulties_input, goals_input)
202
 
203
- # 2) GPT: SWOT
204
  swot_result = analyze_swot(strengths_input, weaknesses_input, opportunities_input, threats_input)
205
  swot_lines = swot_result.split("\n")
206
- strength_line = next((line for line in swot_lines if line.startswith("๊ฐ•์ :")), "")
207
- weakness_line = next((line for line in swot_lines if line.startswith("์•ฝ์ :")), "")
208
- opportunity_line = next((line for line in swot_lines if line.startswith("๊ธฐํšŒ:")), "")
209
- threat_line = next((line for line in swot_lines if line.startswith("์œ„ํ˜‘:")), "")
210
 
211
- # 3) GPT: ์žฌ๋ฌด(4์ค„)
212
  fin_result = analyze_financials(
213
  avg_monthly_sales, rent, labor_cost, management_cost,
214
  utilities, current_interest, other_cost, cost_ratio
215
  )
216
- fin_lines = fin_result.split("\n")
217
 
218
- # 4) GPT: ์ƒ๊ถŒ(1์ค„)
219
  market_result = analyze_market(region_input, industry_input)
220
 
221
- # ์—‘์…€
222
  wb = load_workbook("EXE.xlsx")
223
  ws = wb.active
224
 
@@ -255,22 +278,20 @@ def run_all_in_one(
255
  ws["G7"] = consulting_region
256
  ws["G7"].alignment = Alignment(horizontal="center", vertical="center")
257
 
258
- # (B) ์• ๋กœ์‚ฌํ•ญ(D11), ๋ชฉํ‘œ(D22)
259
  ws["D11"] = preview_difficulties
260
- # (โ˜…) ์• ๋กœ์‚ฌํ•ญ๋„ ์œ„์•„๋ž˜ ๊ฐ€์šด๋ฐ ์ •๋ ฌ
261
- ws["D11"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
262
-
263
  ws["D22"] = preview_goals
264
- ws["D22"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
265
 
266
- # (F) ์‚ฌ์ง„(์˜ˆ: 5ร—5cm)
267
  if photo1 is not None:
268
  img1_bytes = BytesIO()
269
  photo1.save(img1_bytes, format="PNG")
270
  img1_bytes.seek(0)
271
  img_for_excel_1 = ExcelImage(img1_bytes)
272
- img_for_excel_1.width = int(37.79 * 5)
273
- img_for_excel_1.height = int(37.79 * 5)
274
  ws.add_image(img_for_excel_1, "B117")
275
 
276
  if photo2 is not None:
@@ -278,8 +299,8 @@ def run_all_in_one(
278
  photo2.save(img2_bytes, format="PNG")
279
  img2_bytes.seek(0)
280
  img_for_excel_2 = ExcelImage(img2_bytes)
281
- img_for_excel_2.width = int(37.79 * 5)
282
- img_for_excel_2.height = int(37.79 * 5)
283
  ws.add_image(img_for_excel_2, "F117")
284
 
285
  # (C) SWOT ๊ฒฐ๊ณผ (4์นธ)
@@ -299,22 +320,27 @@ def run_all_in_one(
299
  ws["D72"] = threat_line
300
  ws["D72"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
301
 
302
- # (D) ์žฌ๋ฌด(4์ค„): E87~E90
303
- ws.merge_cells("E87:G87")
304
- ws["E87"] = fin_lines[0] if len(fin_lines) > 0 else ""
305
- ws["E87"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
 
306
 
307
- ws.merge_cells("E88:G88")
308
- ws["E88"] = fin_lines[1] if len(fin_lines) > 1 else ""
309
- ws["E88"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
 
 
 
 
310
 
311
- ws.merge_cells("E89:G89")
312
- ws["E89"] = fin_lines[2] if len(fin_lines) > 2 else ""
313
- ws["E89"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
314
 
315
- ws.merge_cells("E90:G90")
316
- ws["E90"] = fin_lines[3] if len(fin_lines) > 3 else ""
317
- ws["E90"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
318
 
319
  # (E) ์ƒ๊ถŒ๋ถ„์„(D101:H101)
320
  ws.merge_cells("D101:H101")
@@ -364,7 +390,7 @@ def main():
364
 
365
  gr.Markdown("---")
366
 
367
- # (C) SWOT
368
  strengths_input = gr.Textbox(label="๊ฐ•์ ")
369
  weaknesses_input = gr.Textbox(label="์•ฝ์ ")
370
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
@@ -372,7 +398,7 @@ def main():
372
 
373
  gr.Markdown("---")
374
 
375
- # (D) ์žฌ๋ฌด
376
  with gr.Row():
377
  avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
378
  rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
@@ -393,14 +419,14 @@ def main():
393
 
394
  gr.Markdown("---")
395
 
396
- # (F) ์‚ฌ์ง„
397
  with gr.Row():
398
  photo_input_1 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„1", type="pil")
399
  photo_input_2 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„2", type="pil")
400
 
401
  gr.Markdown("---")
402
 
403
- # ๋ฒ„ํŠผ
404
  all_in_one_button = gr.Button("๋ชจ๋‘ ์ž…๋ ฅ ํ›„, Excel ๋‹ค์šด๋กœ๋“œ")
405
  all_in_one_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
406
 
@@ -421,13 +447,13 @@ def main():
421
  difficulties_input,
422
  goals_input,
423
 
424
- # (C)
425
  strengths_input,
426
  weaknesses_input,
427
  opportunities_input,
428
  threats_input,
429
 
430
- # (D)
431
  avg_monthly_sales_input,
432
  rent_input,
433
  labor_cost_input,
 
32
  # 1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„
33
  ######################
34
  def analyze_texts(difficulties, goals):
35
+ # ์• ๋กœ์‚ฌํ•ญ
36
  preview_difficulties = call_api(
37
  content=difficulties,
38
  system_message=(
 
44
  temperature=0.7,
45
  top_p=0.9,
46
  )
47
+ # ์ปจ์„คํŒ…๋ชฉํ‘œ
48
  preview_goals = call_api(
49
  content=goals,
50
  system_message=(
 
59
  return preview_difficulties, preview_goals
60
 
61
  ######################
62
+ # 2) SWOT ๋ถ„์„(4์นธ)
63
  ######################
64
  def analyze_swot(strengths, weaknesses, opportunities, threats):
65
  """
66
+ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์„ ๊ฐ๊ฐ ์š”์•ฝ.
67
+ ์ตœ์ข…์€ '๊ฐ•์ :', '์•ฝ์ :', '๊ธฐํšŒ:', '์œ„ํ˜‘:' ๋„ค ์ค„๋กœ ์‘๋‹ต.
 
68
  """
69
  system_message = (
70
  "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. "
71
+ "์ž…๋ ฅ๋œ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์„ ๊ฐ๊ฐ ์š”์•ฝํ•ด ์ฃผ์„ธ์š”. "
72
+ "์ถœ๋ ฅ์€ ๋ฐ˜๋“œ์‹œ ์•„๋ž˜ ์˜ˆ์‹œ ํ˜•ํƒœ๋กœ 4์ค„๋งŒ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค:\n\n"
73
+ "๊ฐ•์ : ~~~\n"
74
+ "์•ฝ์ : ~~~\n"
75
+ "๊ธฐํšŒ: ~~~\n"
76
+ "์œ„ํ˜‘: ~~~\n\n"
77
+ "ํ•ญ์ƒ '๊ฐ•์ :', '์•ฝ์ :', '๊ธฐํšŒ:', '์œ„ํ˜‘:'์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” 4์ค„๋กœ๋งŒ ์‘๋‹ตํ•ด ์ฃผ์„ธ์š”."
78
  )
79
  content = f"""
80
  ๊ฐ•์ : {strengths}
 
85
  return call_api(
86
  content=content,
87
  system_message=system_message,
88
+ max_tokens=700,
89
  temperature=0.7,
90
  top_p=1.0
91
  )
92
 
93
  ######################
94
+ # 3) ์žฌ๋ฌด ๋ถ„์„(12๊ฐœ ํ•ญ๋ชฉ ์ถœ๋ ฅ)
95
  ######################
96
  def analyze_financials(
97
  avg_monthly_sales,
 
103
  other_cost,
104
  cost_ratio
105
  ):
106
+ """
107
+ ์‚ฌ์šฉ์ž ์ž…๋ ฅ 8๊ฐœ(์›”ํ‰๊ท ๋งค์ถœ์•ก, ์ž„์ฐจ๋ฃŒ, ์ธ๊ฑด๋น„, ๊ด€๋ฆฌ๋น„, ์ˆ˜๋„๊ด‘์—ด๋น„, ์ง€๊ธˆ์ด์ž, ๊ธฐํƒ€๋น„์šฉ, ์›๊ฐ€์œจ)๋ฅผ
108
+ ๊ทธ๋Œ€๋กœ ํ‘œ์‹œํ•ด์ฃผ๊ณ , ์ถ”๊ฐ€๋กœ
109
+ (๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ) 4๊ฐœ๋ฅผ ๊ณ„์‚ฐ/์ถ”์ •ํ•˜์—ฌ ํ•ฉ์ณ ์ด 12์ค„๋กœ
110
+ 'ํ•ญ๋ชฉ๋ช…: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜.
111
+ """
112
  system_message = (
113
+ "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ชจ๋‘ ํ‘œ์‹œ(1~8)ํ•˜๊ณ , "
114
+ "์ถ”๊ฐ€๋กœ 9)๊ฐ๊ฐ€์ƒ๊ฐ๋น„, 10)์ˆœ์ด์ต์œจ, 11)์›”์ˆœ์ˆ˜์ต, 12)์†์ต๋ถ„๊ธฐ์ ์„ "
115
+ "'ํ•ญ๋ชฉ๋ช…: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜ํ•ด์ฃผ์„ธ์š”. "
116
+ "์ด 12์ค„, ๊ฐ ์ค„์— ํ•ญ๋ชฉ๋ช…: ๊ฐ’ ๋งŒ. "
117
+ "์ถ”๊ฐ€ ์„ค๋ช…์ด๋‚˜ ๋ฌธ์žฅ์€ ๋„ฃ์ง€ ๋ง์•„์ฃผ์„ธ์š”."
118
  )
119
  content = f"""
120
  ์ž…๋ ฅ:
121
+ 1) ์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}
122
+ 2) ์ž„์ฐจ๋ฃŒ: {rent}
123
+ 3) ์ธ๊ฑด๋น„: {labor_cost}
124
+ 4) ๊ด€๋ฆฌ๋น„: {management_cost}
125
+ 5) ์ˆ˜๋„๊ด‘์—ด๋น„: {utilities}
126
+ 6) ์ง€๊ธˆ์ด์ž: {current_interest}
127
+ 7) ๊ธฐํƒ€๋น„์šฉ: {other_cost}
128
+ 8) ์›๊ฐ€์œจ: {cost_ratio}
129
+
130
+ ๊ฒฐ๊ณผ ํ•ญ๋ชฉ(12์ค„, ํ•ญ๋ชฉ๋ช…: ์ˆ˜์น˜):
131
+ 1) ์›”ํ‰๊ท ๋งค์ถœ์•ก
132
+ 2) ์ž„์ฐจ๋ฃŒ
133
+ 3) ์ธ๊ฑด๋น„
134
+ 4) ๊ด€๋ฆฌ๋น„
135
+ 5) ์ˆ˜๋„๊ด‘์—ด๋น„
136
+ 6) ์ง€๊ธˆ์ด์ž
137
+ 7) ๊ธฐํƒ€๋น„์šฉ
138
+ 8) ์›๊ฐ€์œจ
139
+ 9) ๊ฐ๊ฐ€์ƒ๊ฐ๋น„
140
+ 10) ์ˆœ์ด์ต์œจ
141
+ 11) ์›”์ˆœ์ˆ˜์ต
142
+ 12) ์†์ต๋ถ„๊ธฐ์ 
143
  """
144
  return call_api(
145
  content=content,
146
  system_message=system_message,
147
+ max_tokens=800,
148
  temperature=0.7,
149
  top_p=1.0
150
  )
151
 
152
  ######################
153
+ # 4) ์ƒ๊ถŒ ๋ถ„์„(1์ค„)
154
  ######################
155
  def analyze_market(region, industry):
156
  system_message = (
 
170
  )
171
 
172
  ######################
173
+ # run_all_in_one
174
  ######################
175
  def run_all_in_one(
176
  # (A) ์ƒ๋‹จ 8๊ฐœ
 
193
  opportunities_input,
194
  threats_input,
195
 
196
+ # (D) ์žฌ๋ฌด๋ถ„์„ (12๊ฐœ ํ•ญ๋ชฉ ์ถœ๋ ฅ)
197
  avg_monthly_sales,
198
  rent,
199
  labor_cost,
 
207
  region_input,
208
  industry_input,
209
 
210
+ # (F) ์‚ฌ์ง„ (๊ฐ€๋กœ7cm, ์„ธ๋กœ5cm)
211
  photo1,
212
  photo2
213
  ):
214
  """
215
+ - 1) GPT: ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
216
+ - 2) GPT: SWOT(4์นธ)
217
+ - 3) GPT: ์žฌ๋ฌด(12์ค„)
218
+ - 4) GPT: ์ƒ๊ถŒ(1์ค„)
219
+ - => EXE.xlsx์— ๊ธฐ๋ก
220
+ - => ์‚ฌ์ง„ ๊ฐ€๋กœ=7cm, ์„ธ๋กœ=5cm
221
  """
222
 
223
+ # 1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
224
  preview_difficulties, preview_goals = analyze_texts(difficulties_input, goals_input)
225
 
226
+ # 2) SWOT
227
  swot_result = analyze_swot(strengths_input, weaknesses_input, opportunities_input, threats_input)
228
  swot_lines = swot_result.split("\n")
229
+ strength_line = next((x for x in swot_lines if x.startswith("๊ฐ•์ :")), "")
230
+ weakness_line = next((x for x in swot_lines if x.startswith("์•ฝ์ :")), "")
231
+ opportunity_line = next((x for x in swot_lines if x.startswith("๊ธฐํšŒ:")), "")
232
+ threat_line = next((x for x in swot_lines if x.startswith("์œ„ํ˜‘:")), "")
233
 
234
+ # 3) ์žฌ๋ฌด(12์ค„)
235
  fin_result = analyze_financials(
236
  avg_monthly_sales, rent, labor_cost, management_cost,
237
  utilities, current_interest, other_cost, cost_ratio
238
  )
239
+ fin_lines = fin_result.split("\n") # ์ด 12์ค„ (ํ•ญ๋ชฉ๋ช…: ๊ฐ’)
240
 
241
+ # 4) ์ƒ๊ถŒ
242
  market_result = analyze_market(region_input, industry_input)
243
 
244
+ # ์ด์ œ EXE.xlsx
245
  wb = load_workbook("EXE.xlsx")
246
  ws = wb.active
247
 
 
278
  ws["G7"] = consulting_region
279
  ws["G7"].alignment = Alignment(horizontal="center", vertical="center")
280
 
281
+ # (B) ์• ๋กœ์‚ฌํ•ญ(D11), ์ปจ์„คํŒ…๋ชฉํ‘œ(D22)
282
  ws["D11"] = preview_difficulties
283
+ ws["D11"].alignment = Alignment(wrap_text=True)
 
 
284
  ws["D22"] = preview_goals
285
+ ws["D22"].alignment = Alignment(wrap_text=True)
286
 
287
+ # (F) ์‚ฌ์ง„(๊ฐ€๋กœ 7cm, ์„ธ๋กœ 5cm)
288
  if photo1 is not None:
289
  img1_bytes = BytesIO()
290
  photo1.save(img1_bytes, format="PNG")
291
  img1_bytes.seek(0)
292
  img_for_excel_1 = ExcelImage(img1_bytes)
293
+ img_for_excel_1.width = int(37.79 * 7) # ๊ฐ€๋กœ 7cm
294
+ img_for_excel_1.height = int(37.79 * 5) # ์„ธ๋กœ 5cm
295
  ws.add_image(img_for_excel_1, "B117")
296
 
297
  if photo2 is not None:
 
299
  photo2.save(img2_bytes, format="PNG")
300
  img2_bytes.seek(0)
301
  img_for_excel_2 = ExcelImage(img2_bytes)
302
+ img_for_excel_2.width = int(37.79 * 7) # ๊ฐ€๋กœ 7cm
303
+ img_for_excel_2.height = int(37.79 * 5) # ์„ธ๋กœ 5cm
304
  ws.add_image(img_for_excel_2, "F117")
305
 
306
  # (C) SWOT ๊ฒฐ๊ณผ (4์นธ)
 
320
  ws["D72"] = threat_line
321
  ws["D72"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
322
 
323
+ # (D) ์žฌ๋ฌด(12ํ•ญ๋ชฉ) => E87:F87:G87 ~ E98:F98:G98
324
+ # ๋งŒ์•ฝ E87:F87:G87 ๋“ฑ์ด ๋ณ‘ํ•ฉ๋˜์–ด ์žˆ๋‹ค๋ฉด, ๊ฐœ๋ณ„ ์…€ ์“ฐ๊ธฐ ์‹œ 'MergedCell' ์—๋Ÿฌ๊ฐ€ ๋‚  ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ฃผ์˜.
325
+ # ์‚ฌ์šฉ์ž ์š”์ฒญ๋Œ€๋กœ "์˜› ๋ฐฉ์‹"์œผ๋กœ 3์…€ ๊ฐ๊ฐ ๊ฐ’ ๋ฐฐ์น˜ ์˜ˆ์‹œ
326
+ # (1~8 = ์ž…๋ ฅ, 9~12 = ๊ณ„์‚ฐ)
327
+ # fin_lines[i] = "ํ•ญ๋ชฉ๋ช…: ๊ฐ’"
328
 
329
+ lines_count = len(fin_lines) # ์ตœ๋Œ€ 12์ค„
330
+ for i in range(lines_count):
331
+ row_idx = 87 + i # E87..E98
332
+ # 1) E=ํ•ญ๋ชฉ๋ช…, 2) F=๊ฐ’, 3) G=๋นˆ์นธ
333
+ parts = fin_lines[i].split(":")
334
+ label = parts[0].strip() if len(parts) > 0 else ""
335
+ val = parts[1].strip() if len(parts) > 1 else ""
336
 
337
+ ws[f"E{row_idx}"] = label
338
+ ws[f"F{row_idx}"] = val
339
+ ws[f"G{row_idx}"] = ""
340
 
341
+ # ์ •๋ ฌ
342
+ for c_ in ["E", "F", "G"]:
343
+ ws[f"{c_}{row_idx}"].alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
344
 
345
  # (E) ์ƒ๊ถŒ๋ถ„์„(D101:H101)
346
  ws.merge_cells("D101:H101")
 
390
 
391
  gr.Markdown("---")
392
 
393
+ # (C) SWOT(4์นธ)
394
  strengths_input = gr.Textbox(label="๊ฐ•์ ")
395
  weaknesses_input = gr.Textbox(label="์•ฝ์ ")
396
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
 
398
 
399
  gr.Markdown("---")
400
 
401
+ # (D) ์žฌ๋ฌด(12๊ฐœ ํ•ญ๋ชฉ - 8๊ฐœ ์ž…๋ ฅ + GPT 4๊ฐœ)
402
  with gr.Row():
403
  avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
404
  rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
 
419
 
420
  gr.Markdown("---")
421
 
422
+ # (F) ์‚ฌ์ง„ (๊ฐ€๋กœ 7cm, ์„ธ๋กœ 5cm)
423
  with gr.Row():
424
  photo_input_1 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„1", type="pil")
425
  photo_input_2 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„2", type="pil")
426
 
427
  gr.Markdown("---")
428
 
429
+ # ํ•˜๋‚˜์˜ ๋ฒ„ํŠผ
430
  all_in_one_button = gr.Button("๋ชจ๋‘ ์ž…๋ ฅ ํ›„, Excel ๋‹ค์šด๋กœ๋“œ")
431
  all_in_one_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
432
 
 
447
  difficulties_input,
448
  goals_input,
449
 
450
+ # (C) SWOT(4์นธ)
451
  strengths_input,
452
  weaknesses_input,
453
  opportunities_input,
454
  threats_input,
455
 
456
+ # (D) ์žฌ๋ฌด(8์ž…๋ ฅ+4๊ณ„์‚ฐ=12ํ•ญ๋ชฉ)
457
  avg_monthly_sales_input,
458
  rent_input,
459
  labor_cost_input,