Sangwon78 commited on
Commit
cbaebc6
ยท
verified ยท
1 Parent(s): 43ae119

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +181 -67
app.py CHANGED
@@ -29,10 +29,14 @@ 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
- # GPT ํ˜ธ์ถœ๋งŒ ์ˆ˜ํ–‰ (๊ฒฐ๊ณผ๋Š” ํ™”๋ฉด์— ํ‘œ์‹œ X, ๋Œ€์‹  Excel ๋“ฑ ๋‹ค๋ฅธ ๊ณณ ์‚ฌ์šฉ ๊ฐ€๋Šฅ)
 
 
 
 
36
  preview_difficulties = call_api(
37
  content=difficulties,
38
  system_message=(
@@ -45,6 +49,8 @@ def analyze_texts(difficulties, goals):
45
  temperature=0.7,
46
  top_p=0.9,
47
  )
 
 
48
  preview_goals = call_api(
49
  content=goals,
50
  system_message=(
@@ -60,7 +66,7 @@ def analyze_texts(difficulties, goals):
60
  return preview_difficulties, preview_goals
61
 
62
  ############################
63
- # (2) ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
64
  ############################
65
  def analyze_financials(
66
  avg_monthly_sales,
@@ -72,6 +78,9 @@ def analyze_financials(
72
  other_cost,
73
  cost_ratio
74
  ):
 
 
 
75
  system_message = (
76
  "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
77
  "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
@@ -103,9 +112,12 @@ def analyze_financials(
103
  )
104
 
105
  ############################
106
- # (3) SWOT ๋ถ„์„ ํ•จ์ˆ˜ (๊ธฐ์กด)
107
  ############################
108
  def analyze_swot(strengths, weaknesses, opportunities, threats):
 
 
 
109
  system_message = "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
110
  content = f"""
111
  ๊ฐ•์ : {strengths}
@@ -122,9 +134,13 @@ def analyze_swot(strengths, weaknesses, opportunities, threats):
122
  )
123
 
124
  ############################
125
- # (4) ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜ (6์ค„ ์ด๋‚ด) (๊ธฐ์กด)
126
  ############################
127
  def analyze_market(region, industry):
 
 
 
 
128
  system_message = (
129
  "๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
130
  "์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
@@ -142,11 +158,9 @@ def analyze_market(region, industry):
142
  )
143
 
144
  ############################
145
- # (5) SWOT ๊ฒฐ๊ณผ๋ฅผ EXE.xlsx์— ์“ฐ๋Š” ํ•จ์ˆ˜ (๊ธฐ์กด)
146
  ############################
147
  def export_swot_excel(strengths, weaknesses, opportunities, threats):
148
- from openpyxl import load_workbook
149
- from openpyxl.styles import Alignment
150
  wb = load_workbook("EXE.xlsx")
151
  ws = wb.active
152
 
@@ -183,24 +197,99 @@ def run_export_swot_excel(strengths, weaknesses, opportunities, threats):
183
  return export_swot_excel(strengths, weaknesses, opportunities, threats)
184
 
185
  ############################
186
- # ์žฌ๋ฌด๋ถ„์„ -> EXE.xlsx (ํ™”๋ฉด ์ถœ๋ ฅX) (๊ธฐ์กด)
187
  ############################
188
- def run_generate_financial_excel(
189
- avg_monthly_sales,
190
- rent,
191
- labor_cost,
192
- management_cost,
193
- utilities,
194
- current_interest,
195
- other_cost,
196
- cost_ratio
 
 
 
 
197
  ):
198
- # (๊ธฐ์กด ์ฝ”๋“œ ๋‚ด์šฉ, ์žฌ๋ฌด๋ถ„์„ ๊ฒฐ๊ณผ๋งŒ Excel์— ๊ธฐ๋ก)
199
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
- ############################
202
- # (7) ์ƒ๋‹จ8๊ฐœ + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„ -> EXE.xlsx (๊ธฐ์กด)
203
- ############################
204
  def run_generate_excel(
205
  consulting_company_rep,
206
  consulting_address,
@@ -217,25 +306,53 @@ def run_generate_excel(
217
  preview_difficulties,
218
  preview_goals
219
  ):
220
- # (๊ธฐ์กด ์ฝ”๋“œ ๋‚ด์šฉ, ์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  pass
222
 
223
  ############################
224
- # (โ˜…) ์ƒ๊ถŒ๋ถ„์„ -> EXE.xlsx (๊ธฐ์กด)
225
  ############################
226
  def run_export_market_excel(region, industry):
227
- # (๊ธฐ์กด ์ฝ”๋“œ: ์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ Excel์—๋งŒ ๊ธฐ๋ก)
228
  pass
229
 
230
  ############################
231
- # Gradio ๋‹จ์ผ ํŽ˜์ด์ง€ UI
232
  ############################
233
  def main():
234
  with gr.Blocks() as demo:
235
- gr.Markdown("## (๋‹จ์ผ ํŽ˜์ด์ง€) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ & SWOT & ์ƒ๊ถŒ๋ถ„์„ ๋“ฑ -> ๊ฒฐ๊ณผ๋Š” ํ™”๋ฉด ํ‘œ์‹œ ์•ˆ ํ•จ")
236
 
237
- # [1] ์ƒ๋‹จ 8๊ฐœ
238
- gr.Markdown("### ์ƒ๋‹จ 8๊ฐœ ์ •๋ณด")
239
  with gr.Row():
240
  consulting_company_rep = gr.Textbox(label="์ปจ์„คํŒ…์—…์ฒด๋ช… ๋ฐ ๋Œ€ํ‘œ")
241
  consulting_address = gr.Textbox(label="์ปจ์„คํŒ… ์ฃผ์†Œ")
@@ -250,46 +367,47 @@ def main():
250
 
251
  gr.Markdown("---")
252
 
253
- # [2] ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ (GPT) -> ๊ฒฐ๊ณผ ํ™”๋ฉด ํ‘œ์‹œ X
254
- gr.Markdown("### ์• ๋กœ์‚ฌํ•ญ & ์ปจ์„คํŒ… ๋ชฉํ‘œ (GPT๊ฒฐ๊ณผ๋Š” ํ™”๋ฉด์— ํ‘œ์‹œX)")
255
  with gr.Row():
256
  difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3)
257
  goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3)
258
 
259
  analyze_button = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
260
- # ๋ฒ„ํŠผ ํด๋ฆญ -> analyze_texts, ๊ฒฐ๊ณผ๋Š” ๊ตณ์ด ์–ด๋””์—๋„ ํ‘œ์‹œ ์•ˆ ํ•จ
 
 
261
  analyze_button.click(
262
  fn=analyze_texts,
263
  inputs=[difficulties_input, goals_input],
264
- outputs=[]
265
  )
266
 
267
  gr.Markdown("---")
268
 
269
- # [3] ์‚ฌ์ง„
270
- gr.Markdown("### ์‚ฌ์ง„ (B117/F117, 5ร—5cm)")
271
  with gr.Row():
272
  photo_input_1 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„1", type="pil")
273
  photo_input_2 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„2", type="pil")
274
 
275
  gr.Markdown("---")
276
 
277
- # [4] SWOT ๋ถ„์„ -> ๊ฒฐ๊ณผ ํ™”๋ฉด ํ‘œ์‹œ X
278
- gr.Markdown("### SWOT ๋ถ„์„ (๊ฒฐ๊ณผ๋Š” Excel๋งŒ ๋‹ค์šด๋กœ๋“œ)")
279
  strengths_input = gr.Textbox(label="๊ฐ•์ ")
280
  weaknesses_input = gr.Textbox(label="์•ฝ์ ")
281
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
282
  threats_input = gr.Textbox(label="์œ„ํ˜‘")
283
 
284
  swot_button = gr.Button("SWOT ๋ถ„์„ํ•˜๊ธฐ")
285
- # ๊ฒฐ๊ณผ ํ™”๋ฉด์— ํ‘œ์‹œ X
286
  swot_button.click(
287
  fn=analyze_swot,
288
  inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
289
- outputs=[]
290
  )
291
 
292
- # SWOT -> Excel
293
  swot_excel_button = gr.Button("SWOT ๊ฒฐ๊ณผ EXE.xlsx")
294
  swot_excel_file = gr.File(label="SWOT_EXCEL ๋‹ค์šด๋กœ๋“œ")
295
  swot_excel_button.click(
@@ -300,8 +418,8 @@ def main():
300
 
301
  gr.Markdown("---")
302
 
303
- # [5] ์žฌ๋ฌด๋ถ„์„ -> Excel (๊ฒฐ๊ณผ ํ™”๋ฉด X)
304
- gr.Markdown("### ์žฌ๋ฌด๋ถ„์„ -> EXE.xlsx (ํ™”๋ฉด ์ถœ๋ ฅ ์—†์Œ)")
305
  with gr.Row():
306
  avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
307
  rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
@@ -314,10 +432,11 @@ def main():
314
  other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
315
  cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
316
 
317
- fin_excel_button = gr.Button("์žฌ๋ฌด๋ถ„์„ Excel ๋‹ค์šด๋กœ๋“œ")
318
- fin_excel_file = gr.File(label="์žฌ๋ฌด๋ถ„์„_EXCEL")
319
- fin_excel_button.click(
320
- fn=run_generate_financial_excel,
 
321
  inputs=[
322
  avg_monthly_sales_input,
323
  rent_input,
@@ -328,30 +447,32 @@ def main():
328
  other_cost_input,
329
  cost_ratio_input
330
  ],
331
- outputs=[fin_excel_file]
332
  )
333
 
334
  gr.Markdown("---")
335
 
336
- # [6] ์ƒ๊ถŒ๋ถ„์„ (๊ฒฐ๊ณผ ํ™”๋ฉดX -> Excel)
337
- gr.Markdown("### ์ƒ๊ถŒ๋ถ„์„ -> Excel (ํ™”๋ฉด ํ‘œ์‹œX)")
338
  region_input = gr.Textbox(label="์ง€์—ญ")
339
  industry_input = gr.Textbox(label="์—…์ข…")
340
 
341
- market_excel_button = gr.Button("์ƒ๊ถŒ๋ถ„์„ Excel ๋‹ค์šด๋กœ๋“œ")
342
- market_excel_file = gr.File(label="์ƒ๊ถŒ๋ถ„์„_EXCEL")
343
- market_excel_button.click(
344
- fn=run_export_market_excel,
 
345
  inputs=[region_input, industry_input],
346
- outputs=[market_excel_file]
347
  )
348
 
349
  gr.Markdown("---")
350
 
351
- # [7] ์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„ -> Excel
352
  gr.Markdown("### ์ƒ๋‹จ8๊ฐœ + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„ โ†’ EXE.xlsx")
353
- final_excel_button = gr.Button("์ตœ์ข… Excel ๋‹ค์šด๋กœ๋“œ")
354
- final_excel_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญํ›„์ €์žฅ)")
 
355
  final_excel_button.click(
356
  fn=run_generate_excel,
357
  inputs=[
@@ -367,15 +488,8 @@ def main():
367
  photo_input_2,
368
  difficulties_input,
369
  goals_input,
370
- # GPT ๋ถ„์„ ๊ฒฐ๊ณผ(์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ)๋„ ๊ธฐ์กด์ฒ˜๋Ÿผ ์ธ์ž๋กœ ์‚ฌ์šฉ,
371
- # ๋‹จ์ง€ ํ™”๋ฉด์—์„œ๋งŒ ํ‘œ์‹œํ•˜์ง€ ์•Š์„ ๋ฟ
372
- # preview_difficulties_output, preview_goals_output
373
- # => ํ™”๋ฉด Textbox๋ฅผ ์—†์•ด์œผ๋‹ˆ, ์ธ์ž ์ž๋ฆฌ์—” ๋นˆ ๊ฐ’ or None
374
- # ์—ฌ๊ธฐ์„œ๋Š” []๋งŒ ๋นผ๋ฉด ๋ฉ๋‹ˆ๋‹ค
375
- # ํ•˜์ง€๋งŒ "๊ธฐ์กด ๋กœ์ง"์„ ์œ ์ง€ํ•˜๋ ค๋ฉด ๋ณ€์ˆ˜๋ฅผ ๋‚จ๊ฒจ๋‘์–ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Œ
376
- # => ์ผ๋‹จ outputs ์—†์–ด์กŒ์œผ๋ฏ€๋กœ, None ๋Œ€์ฒด
377
- None,
378
- None
379
  ],
380
  outputs=[final_excel_file]
381
  )
 
29
  return response.choices[0].message["content"]
30
 
31
  ############################
32
+ # (1) ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ ๋ถ„์„ ํ•จ์ˆ˜
33
  ############################
34
  def analyze_texts(difficulties, goals):
35
+ """
36
+ ์‚ฌ์šฉ์ž ์ž…๋ ฅ(์• ๋กœ์‚ฌํ•ญ, ์ปจ์„คํŒ…๋ชฉํ‘œ)์— ๋Œ€ํ•ด gpt-4o-mini๋กœ ๋ถ„์„
37
+ (์ตœ์†Œ 4์ค„ ์ด์ƒ, ๊ธ€์ž ์ค‘๊ฐ„์— ๋Š์ง€ ์•Š๊ณ  '~์Šต๋‹ˆ๋‹ค.' ํ˜•ํƒœ๋กœ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋, ๋ถˆํ•„์š” ๋‚˜์—ดX)
38
+ """
39
+ # ์• ๋กœ์‚ฌํ•ญ
40
  preview_difficulties = call_api(
41
  content=difficulties,
42
  system_message=(
 
49
  temperature=0.7,
50
  top_p=0.9,
51
  )
52
+
53
+ # ์ปจ์„คํŒ…๋ชฉํ‘œ
54
  preview_goals = call_api(
55
  content=goals,
56
  system_message=(
 
66
  return preview_difficulties, preview_goals
67
 
68
  ############################
69
+ # (2) ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜
70
  ############################
71
  def analyze_financials(
72
  avg_monthly_sales,
 
78
  other_cost,
79
  cost_ratio
80
  ):
81
+ """
82
+ GPT๋ฅผ ํ†ตํ•ด ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์  โ†’ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜
83
+ """
84
  system_message = (
85
  "๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
86
  "์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
 
112
  )
113
 
114
  ############################
115
+ # (3) SWOT ๋ถ„์„ ํ•จ์ˆ˜
116
  ############################
117
  def analyze_swot(strengths, weaknesses, opportunities, threats):
118
+ """
119
+ ์ž…๋ ฅ๋œ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘ โ†’ ์š”์•ฝ
120
+ """
121
  system_message = "๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
122
  content = f"""
123
  ๊ฐ•์ : {strengths}
 
134
  )
135
 
136
  ############################
137
+ # (4) ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜ (6์ค„ ์ด๋‚ด)
138
  ############################
139
  def analyze_market(region, industry):
140
+ """
141
+ ์ง€์—ญ + ์—…์ข… โ†’ 1km ์ด๋‚ด ์ƒ๊ถŒ๋ถ„์„
142
+ (์‚ฌ์ง„(์‹œ๊ฐ์ž๋ฃŒ) ์–ธ๊ธ‰ ํฌํ•จ, 6์ค„ ์ด๋‚ด)
143
+ """
144
  system_message = (
145
  "๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
146
  "์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
 
158
  )
159
 
160
  ############################
161
+ # (5) SWOT ๊ฒฐ๊ณผ๋ฅผ EXE.xlsx์— ๊ธฐ์žฌํ•˜๋Š” ํ•จ์ˆ˜
162
  ############################
163
  def export_swot_excel(strengths, weaknesses, opportunities, threats):
 
 
164
  wb = load_workbook("EXE.xlsx")
165
  ws = wb.active
166
 
 
197
  return export_swot_excel(strengths, weaknesses, opportunities, threats)
198
 
199
  ############################
200
+ # (6) ์—‘์…€ ์ƒ์„ฑ ํ•จ์ˆ˜ (์ƒ๋‹จ 8๊ฐœ, ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ, ์‚ฌ์ง„)
201
  ############################
202
+ def generate_excel(
203
+ consulting_company_rep,
204
+ consulting_address,
205
+ consulting_field,
206
+ client_name,
207
+ consulting_contact,
208
+ consulting_date_time,
209
+ consulting_round,
210
+ consulting_region,
211
+ photo1,
212
+ photo2,
213
+ preview_difficulties,
214
+ preview_goals
215
  ):
216
+ wb = load_workbook("EXE.xlsx")
217
+ ws = wb.active
218
+
219
+ # ์ƒ๋‹จ 8๊ฐœ
220
+ ws.merge_cells("C4:E4")
221
+ ws["C4"] = consulting_company_rep
222
+ ws["C4"].alignment = Alignment(horizontal="center", vertical="center")
223
+
224
+ ws.merge_cells("C5:E5")
225
+ ws["C5"] = consulting_address
226
+ ws["C5"].alignment = Alignment(horizontal="center", vertical="center")
227
+
228
+ ws.merge_cells("C6:E6")
229
+ ws["C6"] = consulting_field
230
+ ws["C6"].alignment = Alignment(horizontal="center", vertical="center")
231
+
232
+ ws.merge_cells("C7:E7")
233
+ ws["C7"] = client_name
234
+ ws["C7"].alignment = Alignment(horizontal="center", vertical="center")
235
+
236
+ ws.merge_cells("G4:H4")
237
+ ws["G4"] = consulting_contact
238
+ ws["G4"].alignment = Alignment(horizontal="center", vertical="center")
239
+
240
+ ws.merge_cells("G5:H5")
241
+ ws["G5"] = consulting_date_time
242
+ ws["G5"].alignment = Alignment(horizontal="center", vertical="center")
243
+
244
+ ws.merge_cells("G6:H6")
245
+ ws["G6"] = consulting_round
246
+ ws["G6"].alignment = Alignment(horizontal="center", vertical="center")
247
+
248
+ ws.merge_cells("G7:H7")
249
+ ws["G7"] = consulting_region
250
+ ws["G7"].alignment = Alignment(horizontal="center", vertical="center")
251
+
252
+ # ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ
253
+ ws["D11"] = preview_difficulties
254
+ ws["D22"] = preview_goals
255
+ ws["D11"].alignment = Alignment(wrap_text=True)
256
+ ws["D22"].alignment = Alignment(wrap_text=True)
257
+
258
+ # ์‚ฌ์ง„
259
+ width_px = int(37.79 * 5)
260
+ height_px = int(37.79 * 5)
261
+
262
+ if photo1 is not None:
263
+ img1_bytes = BytesIO()
264
+ photo1.save(img1_bytes, format="PNG")
265
+ img1_bytes.seek(0)
266
+ img1_for_excel = ExcelImage(img1_bytes)
267
+ img1_for_excel.width = width_px
268
+ img1_for_excel.height = height_px
269
+ ws.add_image(img1_for_excel, "B117")
270
+
271
+ if photo2 is not None:
272
+ img2_bytes = BytesIO()
273
+ photo2.save(img2_bytes, format="PNG")
274
+ img2_bytes.seek(0)
275
+ img2_for_excel = ExcelImage(img2_bytes)
276
+ img2_for_excel.width = width_px
277
+ img2_for_excel.height = height_px
278
+ ws.add_image(img2_for_excel, "F117")
279
+
280
+ output = BytesIO()
281
+ wb.save(output)
282
+ output.seek(0)
283
+
284
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
285
+ tmp.write(output.getvalue())
286
+ tmp.flush()
287
+ temp_file_path = tmp.name
288
+
289
+ final_path = os.path.join(os.path.dirname(temp_file_path), "EXE.xlsx")
290
+ os.rename(temp_file_path, final_path)
291
+ return final_path
292
 
 
 
 
293
  def run_generate_excel(
294
  consulting_company_rep,
295
  consulting_address,
 
306
  preview_difficulties,
307
  preview_goals
308
  ):
309
+ return generate_excel(
310
+ consulting_company_rep,
311
+ consulting_address,
312
+ consulting_field,
313
+ client_name,
314
+ consulting_contact,
315
+ consulting_date_time,
316
+ consulting_round,
317
+ consulting_region,
318
+ photo1,
319
+ photo2,
320
+ preview_difficulties,
321
+ preview_goals
322
+ )
323
+
324
+ ############################
325
+ # (7) ์žฌ๋ฌด๋ถ„์„ -> EXE.xlsx (ํ™”๋ฉด ํ‘œ์‹œX)
326
+ ############################
327
+ def run_generate_financial_excel(
328
+ avg_monthly_sales,
329
+ rent,
330
+ labor_cost,
331
+ management_cost,
332
+ utilities,
333
+ current_interest,
334
+ other_cost,
335
+ cost_ratio
336
+ ):
337
+ # ์‚ฌ์šฉ์ž ์ž…๋ ฅ + GPT๊ฒฐ๊ณผ๋งŒ Excel์— ์ €์žฅํ•˜๋Š” ๋กœ์ง (ํ•„์š”ํ•˜๋‹ค๋ฉด ๊ตฌ์„ฑ)
338
  pass
339
 
340
  ############################
341
+ # (8) ์ƒ๊ถŒ๋ถ„์„ -> EXE.xlsx (ํ™”๋ฉด ํ‘œ์‹œX)
342
  ############################
343
  def run_export_market_excel(region, industry):
344
+ # ์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ๋งŒ Excel์— ๋„ฃ๊ณ  ๋‹ค์šด๋กœ๋“œ
345
  pass
346
 
347
  ############################
348
+ # Gradio UI (๋‹จ์ผ ํŽ˜์ด์ง€)
349
  ############################
350
  def main():
351
  with gr.Blocks() as demo:
352
+ gr.Markdown("## (๋‹จ์ผ ํŽ˜์ด์ง€) ์ด์ „ ์ƒํƒœ ๋ณต์›")
353
 
354
+ # ์ƒ๋‹จ 8๊ฐœ ์ •๋ณด
355
+ gr.Markdown("### ์ƒ๋‹จ 8๊ฐœ ์ •๋ณด (C4:E4.. G7:H7)")
356
  with gr.Row():
357
  consulting_company_rep = gr.Textbox(label="์ปจ์„คํŒ…์—…์ฒด๋ช… ๋ฐ ๋Œ€ํ‘œ")
358
  consulting_address = gr.Textbox(label="์ปจ์„คํŒ… ์ฃผ์†Œ")
 
367
 
368
  gr.Markdown("---")
369
 
370
+ # ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ -> GPT
371
+ gr.Markdown("### ์• ๋กœ์‚ฌํ•ญ & ์ปจ์„คํŒ… ๋ชฉํ‘œ (ํ™”๋ฉด์— ํ‘œ์‹œ)")
372
  with gr.Row():
373
  difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3)
374
  goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3)
375
 
376
  analyze_button = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
377
+ preview_difficulties_output = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ", lines=3)
378
+ preview_goals_output = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ", lines=3)
379
+
380
  analyze_button.click(
381
  fn=analyze_texts,
382
  inputs=[difficulties_input, goals_input],
383
+ outputs=[preview_difficulties_output, preview_goals_output]
384
  )
385
 
386
  gr.Markdown("---")
387
 
388
+ # ์‚ฌ์ง„
389
+ gr.Markdown("### ์‚ฌ์ง„ ์—…๋กœ๋“œ (B117/F117, 5ร—5cm)")
390
  with gr.Row():
391
  photo_input_1 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„1", type="pil")
392
  photo_input_2 = gr.Image(label="์ˆ˜์ง„์—…์ฒด์‚ฌ์ง„2", type="pil")
393
 
394
  gr.Markdown("---")
395
 
396
+ # SWOT
397
+ gr.Markdown("### SWOT ๋ถ„์„")
398
  strengths_input = gr.Textbox(label="๊ฐ•์ ")
399
  weaknesses_input = gr.Textbox(label="์•ฝ์ ")
400
  opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
401
  threats_input = gr.Textbox(label="์œ„ํ˜‘")
402
 
403
  swot_button = gr.Button("SWOT ๋ถ„์„ํ•˜๊ธฐ")
404
+ swot_result_output = gr.Textbox(label="SWOT ๊ฒฐ๊ณผ")
405
  swot_button.click(
406
  fn=analyze_swot,
407
  inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
408
+ outputs=swot_result_output
409
  )
410
 
 
411
  swot_excel_button = gr.Button("SWOT ๊ฒฐ๊ณผ EXE.xlsx")
412
  swot_excel_file = gr.File(label="SWOT_EXCEL ๋‹ค์šด๋กœ๋“œ")
413
  swot_excel_button.click(
 
418
 
419
  gr.Markdown("---")
420
 
421
+ # ์žฌ๋ฌด๋ถ„์„
422
+ gr.Markdown("### ์žฌ๋ฌด๋ถ„์„ (๊ฒฐ๊ณผ(์ œ๋ชฉ: ์ˆ˜์น˜) ํ™”๋ฉด ํ‘œ์‹œ)")
423
  with gr.Row():
424
  avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
425
  rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
 
432
  other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
433
  cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
434
 
435
+ result_output_fin = gr.Textbox(label="๊ฒฐ๊ณผ(์ œ๋ชฉ: ์ˆ˜์น˜)")
436
+ analyze_button_fin = gr.Button("๊ณ„์‚ฐํ•˜๊ธฐ")
437
+
438
+ analyze_button_fin.click(
439
+ fn=analyze_financials,
440
  inputs=[
441
  avg_monthly_sales_input,
442
  rent_input,
 
447
  other_cost_input,
448
  cost_ratio_input
449
  ],
450
+ outputs=result_output_fin
451
  )
452
 
453
  gr.Markdown("---")
454
 
455
+ # ์ƒ๊ถŒ๋ถ„์„
456
+ gr.Markdown("### ์ƒ๊ถŒ๋ถ„์„ (6์ค„ ์ด๋‚ด, ํ™”๋ฉด ํ‘œ์‹œ)")
457
  region_input = gr.Textbox(label="์ง€์—ญ")
458
  industry_input = gr.Textbox(label="์—…์ข…")
459
 
460
+ result_output_market = gr.Textbox(label="์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ (์ตœ๋Œ€ 6์ค„)")
461
+ analyze_button_market = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
462
+
463
+ analyze_button_market.click(
464
+ fn=analyze_market,
465
  inputs=[region_input, industry_input],
466
+ outputs=result_output_market
467
  )
468
 
469
  gr.Markdown("---")
470
 
471
+ # ์ตœ์ข… (์ƒ๋‹จ8 + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„) Excel
472
  gr.Markdown("### ์ƒ๋‹จ8๊ฐœ + ์• ๋กœ์‚ฌํ•ญ/๋ชฉํ‘œ + ์‚ฌ์ง„ โ†’ EXE.xlsx")
473
+ final_excel_button = gr.Button("์ตœ์ข… EXE.xlsx ๋‹ค์šด๋กœ๋“œ")
474
+ final_excel_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
475
+
476
  final_excel_button.click(
477
  fn=run_generate_excel,
478
  inputs=[
 
488
  photo_input_2,
489
  difficulties_input,
490
  goals_input,
491
+ preview_difficulties_output,
492
+ preview_goals_output
 
 
 
 
 
 
 
493
  ],
494
  outputs=[final_excel_file]
495
  )