Update app.py
Browse files
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,9 +29,10 @@ 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 |
preview_difficulties = call_api(
|
| 36 |
content=difficulties,
|
| 37 |
system_message=(
|
|
@@ -59,7 +60,7 @@ def analyze_texts(difficulties, goals):
|
|
| 59 |
return preview_difficulties, preview_goals
|
| 60 |
|
| 61 |
############################
|
| 62 |
-
# (2) ์ฌ๋ฌด
|
| 63 |
############################
|
| 64 |
def analyze_financials(
|
| 65 |
avg_monthly_sales,
|
|
@@ -71,311 +72,62 @@ def analyze_financials(
|
|
| 71 |
other_cost,
|
| 72 |
cost_ratio
|
| 73 |
):
|
|
|
|
| 74 |
system_message = (
|
| 75 |
-
"๋น์ ์ ์ธ๋ฌด์ฌ(ํ๊ณ์ฌ)์
๋๋ค.
|
| 76 |
-
"์์์์ต, ์์ต๋ถ๊ธฐ์ ์ '์ ๋ชฉ: ์์น' ํ์์ผ๋ก๋ง ์๋ ค์ฃผ์ธ์. "
|
| 77 |
-
"์ถ๊ฐ ์ค๋ช
์ด๋ ๋ฌธ์ฅ ์์ด, ํญ๋ชฉ๋ช
๊ณผ ์์น๋ง ๋ฐํํด์ฃผ์ธ์."
|
| 78 |
-
)
|
| 79 |
-
content = f"""
|
| 80 |
-
์
๋ ฅ๋ ๋ฐ์ดํฐ:
|
| 81 |
-
- ์ํ๊ท ๋งค์ถ์ก: {avg_monthly_sales}
|
| 82 |
-
- ์์ฐจ๋ฃ: {rent}
|
| 83 |
-
- ์ธ๊ฑด๋น: {labor_cost}
|
| 84 |
-
- ๊ด๋ฆฌ๋น: {management_cost}
|
| 85 |
-
- ์๋๊ด์ด๋น: {utilities}
|
| 86 |
-
- ์ง๊ธ์ด์: {current_interest}
|
| 87 |
-
- ๊ธฐํ๋น์ฉ: {other_cost}
|
| 88 |
-
- ์๊ฐ์จ: {cost_ratio}
|
| 89 |
-
|
| 90 |
-
๊ฒฐ๊ณผ ํญ๋ชฉ:
|
| 91 |
-
1) ๊ฐ๊ฐ์๊ฐ๋น
|
| 92 |
-
2) ์์ด์ต์จ
|
| 93 |
-
3) ์์์์ต
|
| 94 |
-
4) ์์ต๋ถ๊ธฐ์
|
| 95 |
-
"""
|
| 96 |
-
return call_api(
|
| 97 |
-
content=content,
|
| 98 |
-
system_message=system_message,
|
| 99 |
-
max_tokens=1024,
|
| 100 |
-
temperature=0.7,
|
| 101 |
-
top_p=1.0
|
| 102 |
)
|
|
|
|
| 103 |
|
| 104 |
############################
|
| 105 |
-
# (3) SWOT ๋ถ์ ํจ์ (
|
| 106 |
############################
|
| 107 |
def analyze_swot(strengths, weaknesses, opportunities, threats):
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
์ฝ์ : {weaknesses}
|
| 112 |
-
๊ธฐํ: {opportunities}
|
| 113 |
-
์ํ: {threats}
|
| 114 |
-
"""
|
| 115 |
-
return call_api(
|
| 116 |
-
content=content,
|
| 117 |
-
system_message=system_message,
|
| 118 |
-
max_tokens=1024,
|
| 119 |
-
temperature=0.7,
|
| 120 |
-
top_p=1.0
|
| 121 |
-
)
|
| 122 |
|
| 123 |
############################
|
| 124 |
-
# (4) ์๊ถ
|
| 125 |
############################
|
| 126 |
def analyze_market(region, industry):
|
|
|
|
| 127 |
system_message = (
|
| 128 |
-
"๋น์ ์ ์๊ถ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
| 129 |
-
"์ฌ์ง(๋๋ ์๊ฐ์๋ฃ)์ ๋ํ ์ธ๊ธ ํฌํจ, ์๋ต์ 6์ค ์ด๋ด๋ก ์ ํํ์ธ์."
|
| 130 |
-
)
|
| 131 |
-
content = f"""
|
| 132 |
-
์ง์ญ: {region}
|
| 133 |
-
์
์ข
: {industry}
|
| 134 |
-
"""
|
| 135 |
-
return call_api(
|
| 136 |
-
content=content,
|
| 137 |
-
system_message=system_message,
|
| 138 |
-
max_tokens=300,
|
| 139 |
-
temperature=0.7,
|
| 140 |
-
top_p=1.0
|
| 141 |
)
|
|
|
|
| 142 |
|
| 143 |
############################
|
| 144 |
-
# (5)
|
| 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 |
-
|
| 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 |
-
|
| 294 |
-
|
| 295 |
-
|
| 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 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
|
| 306 |
############################
|
| 307 |
-
# (โ
) ์ต์ข
ํ๋์
|
| 308 |
############################
|
| 309 |
-
def run_all_in_one(
|
| 310 |
-
#
|
| 311 |
-
|
| 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("## (๋จ์ผ ํ์ด์ง) ๋ฒํผ
|
| 379 |
|
| 380 |
# [1] ์๋จ 8๊ฐ
|
| 381 |
with gr.Row():
|
|
@@ -392,18 +144,13 @@ def main():
|
|
| 392 |
|
| 393 |
gr.Markdown("---")
|
| 394 |
|
| 395 |
-
# [2] ์ ๋ก์ฌํญ/๋ชฉํ
|
| 396 |
difficulties_input = gr.Textbox(label="์ ๋ก์ฌํญ ์
๋ ฅ", lines=3)
|
| 397 |
goals_input = gr.Textbox(label="์ปจ์คํ
๋ชฉํ ์
๋ ฅ", lines=3)
|
| 398 |
-
|
| 399 |
-
# ํ๋ฉด ํ์
|
| 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("---")
|
| 409 |
|
|
@@ -414,24 +161,18 @@ def main():
|
|
| 414 |
|
| 415 |
gr.Markdown("---")
|
| 416 |
|
| 417 |
-
# [4] SWOT
|
| 418 |
strengths_input = gr.Textbox(label="๊ฐ์ ")
|
| 419 |
weaknesses_input = gr.Textbox(label="์ฝ์ ")
|
| 420 |
opportunities_input = gr.Textbox(label="๊ธฐํ")
|
| 421 |
threats_input = gr.Textbox(label="์ํ")
|
| 422 |
|
| 423 |
-
#
|
| 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("---")
|
| 433 |
|
| 434 |
-
# [5] ์ฌ๋ฌด๋ถ์
|
| 435 |
with gr.Row():
|
| 436 |
avg_monthly_sales_input = gr.Textbox(label="์ํ๊ท ๋งค์ถ์ก")
|
| 437 |
rent_input = gr.Textbox(label="์์ฐจ๋ฃ")
|
|
@@ -444,16 +185,11 @@ def main():
|
|
| 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,7 +197,6 @@ def main():
|
|
| 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=[
|
|
|
|
| 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 |
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=(
|
|
|
|
| 60 |
return preview_difficulties, preview_goals
|
| 61 |
|
| 62 |
############################
|
| 63 |
+
# (2) ์ฌ๋ฌด๋ถ์ ํจ์ (์ ์ง)
|
| 64 |
############################
|
| 65 |
def analyze_financials(
|
| 66 |
avg_monthly_sales,
|
|
|
|
| 72 |
other_cost,
|
| 73 |
cost_ratio
|
| 74 |
):
|
| 75 |
+
# (ํจ์ ๋ด์ฉ ๊ทธ๋๋ก)
|
| 76 |
system_message = (
|
| 77 |
+
"๋น์ ์ ์ธ๋ฌด์ฌ(ํ๊ณ์ฌ)์
๋๋ค. ... (์๋ต) ..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
)
|
| 79 |
+
# ...
|
| 80 |
|
| 81 |
############################
|
| 82 |
+
# (3) SWOT ๋ถ์ ํจ์ (์ ์ง)
|
| 83 |
############################
|
| 84 |
def analyze_swot(strengths, weaknesses, opportunities, threats):
|
| 85 |
+
# (ํจ์ ๋ด์ฉ ๊ทธ๋๋ก)
|
| 86 |
+
system_message = "๋น์ ์ swot ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค. ..."
|
| 87 |
+
# ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
############################
|
| 90 |
+
# (4) ์๊ถ๋ถ์ ํจ์ (์ ์ง)
|
| 91 |
############################
|
| 92 |
def analyze_market(region, industry):
|
| 93 |
+
# (ํจ์ ๋ด์ฉ ๊ทธ๋๋ก)
|
| 94 |
system_message = (
|
| 95 |
+
"๋น์ ์ ์๊ถ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค. ..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
)
|
| 97 |
+
# ...
|
| 98 |
|
| 99 |
############################
|
| 100 |
+
# (5) EXE ์ ์ฅ(์ ๋ก์ฌํญ,SWOT,์ฌ๋ฌด,์๊ถ ๋ฑ) (์ ์ง)
|
|
|
|
| 101 |
############################
|
|
|
|
| 102 |
def export_swot_excel(strengths, weaknesses, opportunities, threats):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
# ...
|
| 104 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
+
def generate_financial_excel(...):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
# ...
|
| 108 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
def export_market_excel(...):
|
| 111 |
+
# ...
|
| 112 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
+
def generate_excel_top8_and_consulting(...):
|
| 115 |
+
# ...
|
| 116 |
+
pass
|
| 117 |
|
| 118 |
############################
|
| 119 |
+
# (โ
) ์ต์ข
ํ๋์ run_all_in_one() (์ ์ง)
|
| 120 |
############################
|
| 121 |
+
def run_all_in_one(...):
|
| 122 |
+
# ...
|
| 123 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
############################
|
| 126 |
# Gradio UI
|
| 127 |
############################
|
| 128 |
def main():
|
| 129 |
with gr.Blocks() as demo:
|
| 130 |
+
gr.Markdown("## (๋จ์ผ ํ์ด์ง) ์ ๋ก์ฌํญ/๋ชฉํ, SWOT '๋ถ์ํ๊ธฐ' ๋ฒํผ ์์ด, ์ต์ข
๋ฒํผ๋ง")
|
| 131 |
|
| 132 |
# [1] ์๋จ 8๊ฐ
|
| 133 |
with gr.Row():
|
|
|
|
| 144 |
|
| 145 |
gr.Markdown("---")
|
| 146 |
|
| 147 |
+
# [2] ์ ๋ก์ฌํญ/๋ชฉํ ์
๋ ฅ (๋ฒํผ ์ญ์ , GPT ํธ์ถ ์ํจ - ๊ฐ๋ง ๋ฐ์)
|
| 148 |
difficulties_input = gr.Textbox(label="์ ๋ก์ฌํญ ์
๋ ฅ", lines=3)
|
| 149 |
goals_input = gr.Textbox(label="์ปจ์คํ
๋ชฉํ ์
๋ ฅ", lines=3)
|
| 150 |
+
|
| 151 |
+
# ํ๋ฉด์ ํ์๋ preview_difficulties_state, preview_goals_state ๋์ state
|
| 152 |
preview_difficulties_state = gr.State()
|
| 153 |
preview_goals_state = gr.State()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
gr.Markdown("---")
|
| 156 |
|
|
|
|
| 161 |
|
| 162 |
gr.Markdown("---")
|
| 163 |
|
| 164 |
+
# [4] SWOT ์
๋ ฅ (๋ฒํผ ์ญ์ , ๊ฐ๋ง ์
๋ ฅ ๊ฐ๋ฅ)
|
| 165 |
strengths_input = gr.Textbox(label="๊ฐ์ ")
|
| 166 |
weaknesses_input = gr.Textbox(label="์ฝ์ ")
|
| 167 |
opportunities_input = gr.Textbox(label="๊ธฐํ")
|
| 168 |
threats_input = gr.Textbox(label="์ํ")
|
| 169 |
|
| 170 |
+
# ํ๋ฉด state
|
|
|
|
| 171 |
swot_state = gr.State()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
gr.Markdown("---")
|
| 174 |
|
| 175 |
+
# [5] ์ฌ๋ฌด๋ถ์ (์
๋ ฅ๋ง, ๊ฒฐ๊ณผ๋ GPT๋ก) - ๋ฒํผ ์ญ์
|
| 176 |
with gr.Row():
|
| 177 |
avg_monthly_sales_input = gr.Textbox(label="์ํ๊ท ๋งค์ถ์ก")
|
| 178 |
rent_input = gr.Textbox(label="์์ฐจ๋ฃ")
|
|
|
|
| 185 |
other_cost_input = gr.Textbox(label="๊ธฐํ๋น์ฉ")
|
| 186 |
cost_ratio_input = gr.Textbox(label="์๊ฐ์จ")
|
| 187 |
|
|
|
|
|
|
|
|
|
|
| 188 |
gr.Markdown("---")
|
| 189 |
|
| 190 |
+
# [6] ์๊ถ๋ถ์ (์
๋ ฅ๋ง, ๋ฒํผ ์ญ์ )
|
| 191 |
region_input = gr.Textbox(label="์ง์ญ")
|
| 192 |
industry_input = gr.Textbox(label="์
์ข
")
|
|
|
|
|
|
|
| 193 |
|
| 194 |
gr.Markdown("---")
|
| 195 |
|
|
|
|
| 197 |
all_in_one_button = gr.Button("๋ชจ๋ ์
๋ ฅ ํ, Excel ๋ค์ด๋ก๋")
|
| 198 |
all_in_one_file = gr.File(label="๋ค์ด๋ก๋(ํด๋ฆญ ํ ์ ์ฅ)")
|
| 199 |
|
|
|
|
| 200 |
all_in_one_button.click(
|
| 201 |
fn=run_all_in_one,
|
| 202 |
inputs=[
|