Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 187 |
############################
|
| 188 |
-
def
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
):
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
pass
|
| 222 |
|
| 223 |
############################
|
| 224 |
-
# (
|
| 225 |
############################
|
| 226 |
def run_export_market_excel(region, industry):
|
| 227 |
-
#
|
| 228 |
pass
|
| 229 |
|
| 230 |
############################
|
| 231 |
-
# Gradio ๋จ์ผ ํ์ด์ง
|
| 232 |
############################
|
| 233 |
def main():
|
| 234 |
with gr.Blocks() as demo:
|
| 235 |
-
gr.Markdown("## (๋จ์ผ ํ์ด์ง)
|
| 236 |
|
| 237 |
-
#
|
| 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 |
-
#
|
| 254 |
-
gr.Markdown("### ์ ๋ก์ฌํญ & ์ปจ์คํ
๋ชฉํ (
|
| 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 |
-
|
|
|
|
|
|
|
| 261 |
analyze_button.click(
|
| 262 |
fn=analyze_texts,
|
| 263 |
inputs=[difficulties_input, goals_input],
|
| 264 |
-
outputs=[]
|
| 265 |
)
|
| 266 |
|
| 267 |
gr.Markdown("---")
|
| 268 |
|
| 269 |
-
#
|
| 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 |
-
#
|
| 278 |
-
gr.Markdown("### SWOT ๋ถ์
|
| 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 |
-
|
| 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 |
-
#
|
| 304 |
-
gr.Markdown("### ์ฌ๋ฌด๋ถ์
|
| 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 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
|
|
|
| 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=
|
| 332 |
)
|
| 333 |
|
| 334 |
gr.Markdown("---")
|
| 335 |
|
| 336 |
-
#
|
| 337 |
-
gr.Markdown("### ์๊ถ๋ถ์
|
| 338 |
region_input = gr.Textbox(label="์ง์ญ")
|
| 339 |
industry_input = gr.Textbox(label="์
์ข
")
|
| 340 |
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
|
|
|
| 345 |
inputs=[region_input, industry_input],
|
| 346 |
-
outputs=
|
| 347 |
)
|
| 348 |
|
| 349 |
gr.Markdown("---")
|
| 350 |
|
| 351 |
-
#
|
| 352 |
gr.Markdown("### ์๋จ8๊ฐ + ์ ๋ก์ฌํญ/๋ชฉํ + ์ฌ์ง โ EXE.xlsx")
|
| 353 |
-
final_excel_button = gr.Button("์ต์ข
|
| 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 |
-
|
| 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 |
)
|