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as gr
|
| 4 |
+
from openpyxl import load_workbook
|
| 5 |
+
from io import BytesIO
|
| 6 |
+
import tempfile
|
| 7 |
+
|
| 8 |
+
##################################
|
| 9 |
+
# (ํ์) OpenAI API ํค ์ค์
|
| 10 |
+
##################################
|
| 11 |
+
# ํ์ํ๋ค๋ฉด .strip()์ ์ ๊ฑฐํ๊ฑฐ๋ ์ ์งํด๋ ๋ฌด๋ฐฉํฉ๋๋ค.
|
| 12 |
+
openai.api_key = os.getenv("OPENAI_API_KEY").strip()
|
| 13 |
+
|
| 14 |
+
##################################
|
| 15 |
+
# [api์๋ฃ]์์ ์ฃผ์ด์ง ํจ์ (์์ ๊ธ์ง)
|
| 16 |
+
##################################
|
| 17 |
+
def call_api(content, system_message, max_tokens, temperature, top_p):
|
| 18 |
+
response = openai.ChatCompletion.create(
|
| 19 |
+
model="gpt-4o-mini", # ์์ฒญ์ฌํญ๋๋ก gpt-4o-mini ์ฌ์ฉ
|
| 20 |
+
messages=[
|
| 21 |
+
{"role": "system", "content": system_message},
|
| 22 |
+
{"role": "user", "content": content},
|
| 23 |
+
],
|
| 24 |
+
max_tokens=max_tokens,
|
| 25 |
+
temperature=temperature,
|
| 26 |
+
top_p=top_p,
|
| 27 |
+
)
|
| 28 |
+
return response.choices[0].message['content']
|
| 29 |
+
|
| 30 |
+
##################################
|
| 31 |
+
# 1. ์ฌ๋ฌด ๋ถ์ ํจ์ (์
๋ ฅ: 8๊ฐ, ์ถ๋ ฅ: 4๊ฐ ์์น)
|
| 32 |
+
##################################
|
| 33 |
+
def analyze_financials(
|
| 34 |
+
avg_monthly_sales, # ์ํ๊ท ๋งค์ถ์ก
|
| 35 |
+
rent, # ์์ฐจ๋ฃ
|
| 36 |
+
labor_cost, # ์ธ๊ฑด๋น
|
| 37 |
+
management_cost, # ๊ด๋ฆฌ๋น
|
| 38 |
+
utilities, # ์๋๊ด์ด๋น
|
| 39 |
+
current_interest, # ์ง๊ธ์ด์
|
| 40 |
+
other_cost, # ๊ธฐํ๋น์ฉ
|
| 41 |
+
cost_ratio # ์๊ฐ์จ (์ถ๋ ฅ์๋ ํฌํจ ์ ํจ)
|
| 42 |
+
):
|
| 43 |
+
"""
|
| 44 |
+
์ฌ์ฉ์๊ฐ ์
๋ ฅํ 8๊ฐ์ง ํญ๋ชฉ(์ํ๊ท ๋งค์ถ์ก, ์์ฐจ๋ฃ, ์ธ๊ฑด๋น, ๊ด๋ฆฌ๋น, ์๋๊ด์ด๋น, ์ง๊ธ์ด์, ๊ธฐํ๋น์ฉ, ์๊ฐ์จ)์ ๋ฐํ์ผ๋ก
|
| 45 |
+
๊ฐ๊ฐ์๊ฐ๋น, ์์ด์ต์จ, ์์์์ต, ์์ต๋ถ๊ธฐ์ ์ ๊ณ์ฐ(๋๋ ์ถ์ )ํ์ฌ,
|
| 46 |
+
๊ฐ ํญ๋ชฉ๋ณ '์ ๋ชฉ: ์์น' ํํ๋ก๋ง ๋ฐํํ๋ ํจ์
|
| 47 |
+
(์ถ๋ ฅ์์ ์๊ฐ์จ์ ์ ์ธ)
|
| 48 |
+
"""
|
| 49 |
+
system_message = (
|
| 50 |
+
"๋น์ ์ ์ธ๋ฌด์ฌ(ํ๊ณ์ฌ)์
๋๋ค. ์๋ ์
๋ ฅ๊ฐ์ ๋ฐํ์ผ๋ก ๊ณ์ฐํ ๊ฐ๊ฐ์๊ฐ๋น, ์์ด์ต์จ, "
|
| 51 |
+
"์์์์ต, ์์ต๋ถ๊ธฐ์ ์ '์ ๋ชฉ: ์์น' ํ์์ผ๋ก๋ง ์๋ ค์ฃผ์ธ์. "
|
| 52 |
+
"์ถ๊ฐ ์ค๋ช
์ด๋ ๋ฌธ์ฅ ์์ด, ํญ๋ชฉ๋ช
๊ณผ ์์น๋ง ๋ฐํํด์ฃผ์ธ์."
|
| 53 |
+
)
|
| 54 |
+
content = f"""
|
| 55 |
+
์
๋ ฅ๋ ๋ฐ์ดํฐ:
|
| 56 |
+
- ์ํ๊ท ๋งค์ถ์ก: {avg_monthly_sales}
|
| 57 |
+
- ์์ฐจ๋ฃ: {rent}
|
| 58 |
+
- ์ธ๊ฑด๋น: {labor_cost}
|
| 59 |
+
- ๊ด๋ฆฌ๋น: {management_cost}
|
| 60 |
+
- ์๋๊ด์ด๋น: {utilities}
|
| 61 |
+
- ์ง๊ธ์ด์: {current_interest}
|
| 62 |
+
- ๊ธฐํ๋น์ฉ: {other_cost}
|
| 63 |
+
- ์๊ฐ์จ: {cost_ratio}
|
| 64 |
+
|
| 65 |
+
๋ค์ ํญ๋ชฉ์ ๊ฒฐ๊ณผ๋ฅผ '์ ๋ชฉ: ์์น' ํํ๋ก๋ง ๋ฐํํด ์ฃผ์ธ์:
|
| 66 |
+
1) ๊ฐ๊ฐ์๊ฐ๋น
|
| 67 |
+
2) ์์ด์ต์จ
|
| 68 |
+
3) ์์์์ต
|
| 69 |
+
4) ์์ต๋ถ๊ธฐ์
|
| 70 |
+
"""
|
| 71 |
+
return call_api(
|
| 72 |
+
content=content,
|
| 73 |
+
system_message=system_message,
|
| 74 |
+
max_tokens=1024,
|
| 75 |
+
temperature=0.7,
|
| 76 |
+
top_p=1.0
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
##################################
|
| 80 |
+
# 2. SWOT ๋ถ์ ํจ์
|
| 81 |
+
##################################
|
| 82 |
+
def analyze_swot(strengths, weaknesses, opportunities, threats):
|
| 83 |
+
"""
|
| 84 |
+
์ฌ์ฉ์๊ฐ ์
๋ ฅํ ๊ฐ์ , ์ฝ์ , ๊ธฐํ, ์ํ์ ๋ํด
|
| 85 |
+
gpt-4o-mini ๋ชจ๋ธ์ ํ์ฉํด ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ํจ์
|
| 86 |
+
"""
|
| 87 |
+
system_message = "๋น์ ์ swot ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค. ์ฌ์ฉ์์ ๊ฐ์ , ์ฝ์ , ๊ธฐํ, ์ํ์ ๋ํด ๊ฒ์ํ ๋ด์ฉ์ ์์ฝํ์ฌ ์ ๊ณตํฉ๋๋ค."
|
| 88 |
+
content = f"""
|
| 89 |
+
๊ฐ์ : {strengths}
|
| 90 |
+
์ฝ์ : {weaknesses}
|
| 91 |
+
๊ธฐํ: {opportunities}
|
| 92 |
+
์ํ: {threats}
|
| 93 |
+
"""
|
| 94 |
+
return call_api(
|
| 95 |
+
content=content,
|
| 96 |
+
system_message=system_message,
|
| 97 |
+
max_tokens=1024,
|
| 98 |
+
temperature=0.7,
|
| 99 |
+
top_p=1.0
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
##################################
|
| 103 |
+
# 3. ์๊ถ ๋ถ์ ํจ์ (6์ค ์ด๋ด)
|
| 104 |
+
##################################
|
| 105 |
+
def analyze_market(region, industry):
|
| 106 |
+
"""
|
| 107 |
+
์ง์ญ, ์
์ข
์ ์
๋ ฅ๋ฐ์ 1km ์ด๋ด ์๊ถ๋ถ์์ '์ฌ์ง ์ธ๊ธ'๊ณผ ํจ๊ป,
|
| 108 |
+
6์ค ์ด๋ด ํ
์คํธ๋ก ์์ฝํด ์ฃผ๋ ํจ์
|
| 109 |
+
"""
|
| 110 |
+
system_message = (
|
| 111 |
+
"๋น์ ์ ์๊ถ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค. ์
๋ ฅ๋ ์ง์ญ๊ณผ ์
์ข
์ ๋ํด 1km ์ด๋ด ์๊ถ์ ๋ถ์ํด ์ฃผ์ธ์. "
|
| 112 |
+
"์ฌ์ง(๋๋ ์๊ฐ์๋ฃ)์ ๋ํ ์ธ๊ธ ํฌํจ, ์๋ต์ 6์ค ์ด๋ด๋ก ์ ํํ์ธ์."
|
| 113 |
+
)
|
| 114 |
+
content = f"""
|
| 115 |
+
์ง์ญ: {region}
|
| 116 |
+
์
์ข
: {industry}
|
| 117 |
+
"""
|
| 118 |
+
return call_api(
|
| 119 |
+
content=content,
|
| 120 |
+
system_message=system_message,
|
| 121 |
+
max_tokens=300,
|
| 122 |
+
temperature=0.7,
|
| 123 |
+
top_p=1.0
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
##################################
|
| 127 |
+
# 4. ์ ๋ก์ฌํญ & ์ปจ์คํ
๋ชฉํ ๋ถ์ ํจ์
|
| 128 |
+
##################################
|
| 129 |
+
def analyze_texts(difficulties, goals):
|
| 130 |
+
"""
|
| 131 |
+
์ฌ์ฉ์ ์
๋ ฅ(์ ๋ก์ฌํญ, ์ปจ์คํ
๋ชฉํ)์ gpt-4o-mini๋ก ๋ถ์ ํ ๊ฒฐ๊ณผ(๋ฏธ๋ฆฌ๋ณด๊ธฐ)๋ฅผ ๋ฆฌํด
|
| 132 |
+
"""
|
| 133 |
+
# ์ ๋ก์ฌํญ ๋ถ์
|
| 134 |
+
preview_difficulties = call_api(
|
| 135 |
+
content=difficulties,
|
| 136 |
+
system_message="์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ ๋ก์ฌํญ์ ๊ฐ๋จํ ๋ถ์ ๋ฐ ํด๊ฒฐ๋ฐฉ์ ์ ์ํด์ค.",
|
| 137 |
+
max_tokens=50,
|
| 138 |
+
temperature=0.7,
|
| 139 |
+
top_p=0.9
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
# ์ปจ์คํ
๋ชฉํ ๋ถ์
|
| 143 |
+
preview_goals = call_api(
|
| 144 |
+
content=goals,
|
| 145 |
+
system_message="์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ปจ์คํ
๋ชฉํ์ ๋ํ ์์ฝ ๋ฐ ์คํ๋ฐฉ์์ ์ ์ํด์ค.",
|
| 146 |
+
max_tokens=50,
|
| 147 |
+
temperature=0.7,
|
| 148 |
+
top_p=0.9
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
return preview_difficulties, preview_goals
|
| 152 |
+
|
| 153 |
+
##################################
|
| 154 |
+
# Excel ์์ฑ(๋ค์ด๋ก๋) ํจ์
|
| 155 |
+
##################################
|
| 156 |
+
def generate_excel(preview_difficulties, preview_goals):
|
| 157 |
+
"""
|
| 158 |
+
1) 'suu.xlsx'๋ฅผ ๋ถ๋ฌ์์
|
| 159 |
+
2) A4 = ์ ๋ก์ฌํญ ๋ถ์ ๊ฒฐ๊ณผ
|
| 160 |
+
A5 = ์ปจ์คํ
๋ชฉํ ๋ถ์ ๊ฒฐ๊ณผ
|
| 161 |
+
3) NamedTemporaryFile๋ก ์ ์ฅ ํ ํด๋น ํ์ผ ๊ฒฝ๋ก ๋ฐํ
|
| 162 |
+
"""
|
| 163 |
+
wb = load_workbook("suu.xlsx")
|
| 164 |
+
ws = wb.active
|
| 165 |
+
|
| 166 |
+
# A4, A5 ์
์ ๊ฒฐ๊ณผ ๊ธฐ์
|
| 167 |
+
ws["A4"] = preview_difficulties
|
| 168 |
+
ws["A5"] = preview_goals
|
| 169 |
+
|
| 170 |
+
# ๋ฉ๋ชจ๋ฆฌ ๋ฒํผ์ ์ ์ฅ
|
| 171 |
+
output = BytesIO()
|
| 172 |
+
wb.save(output)
|
| 173 |
+
output.seek(0)
|
| 174 |
+
|
| 175 |
+
# ์์ํ์ผ๋ก ๊ธฐ๋ก ํ ๊ฒฝ๋ก ๋ฐํ
|
| 176 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
|
| 177 |
+
tmp.write(output.getvalue())
|
| 178 |
+
tmp_path = tmp.name
|
| 179 |
+
|
| 180 |
+
return tmp_path
|
| 181 |
+
|
| 182 |
+
##################################
|
| 183 |
+
# Gradio ์ด๋ฒคํธ ํจ์
|
| 184 |
+
##################################
|
| 185 |
+
def run_analyze(difficulties, goals):
|
| 186 |
+
"""
|
| 187 |
+
'๋ถ์ํ๊ธฐ' ๋ฒํผ ๋๋ฅด๋ฉด ์คํ:
|
| 188 |
+
- gpt-4o-mini API๋ก ๋ถ์ ํ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ํ
์คํธ๋ฅผ ๋ฐํ
|
| 189 |
+
"""
|
| 190 |
+
preview_difficulties, preview_goals = analyze_texts(difficulties, goals)
|
| 191 |
+
return preview_difficulties, preview_goals
|
| 192 |
+
|
| 193 |
+
def run_generate_excel(difficulties, goals, preview_difficulties, preview_goals):
|
| 194 |
+
"""
|
| 195 |
+
'์์
๋ก ๋ค์ด๋ก๋' ๋ฒํผ ๋๋ฅด๋ฉด ์คํ:
|
| 196 |
+
- generate_excel()๋ก ์์
ํ์ผ์ ๋ง๋ค๊ณ ,
|
| 197 |
+
- Gradio File ์ปดํฌ๋ํธ๋ก ๋ค์ด๋ก๋
|
| 198 |
+
"""
|
| 199 |
+
excel_path = generate_excel(preview_difficulties, preview_goals)
|
| 200 |
+
# gr.File() ์ปดํฌ๋ํธ์ ๋ฐํ -> ์ฌ์ฉ์๊ฐ ๋ค์ด ๊ฐ๋ฅ
|
| 201 |
+
return excel_path
|
| 202 |
+
|
| 203 |
+
##################################
|
| 204 |
+
# Gradio UI ๊ตฌ์ฑ
|
| 205 |
+
##################################
|
| 206 |
+
def create_app():
|
| 207 |
+
with gr.Blocks() as demo:
|
| 208 |
+
gr.Markdown("## ํตํฉ Demo - ์ฌ๋ฌด ๋ถ์ / SWOT / ์๊ถ / ์ ๋ก์ฌํญ & ๋ชฉํ")
|
| 209 |
+
|
| 210 |
+
with gr.Tabs():
|
| 211 |
+
# =========================
|
| 212 |
+
# ํญ1) ์ฌ๋ฌด ๋ถ์
|
| 213 |
+
# =========================
|
| 214 |
+
with gr.Tab("์ฌ๋ฌด ๋ถ์"):
|
| 215 |
+
gr.Markdown("### (์
๋ ฅ์ ์๊ฐ์จ ํฌํจ, ๊ฒฐ๊ณผ์์ ์๊ฐ์จ ์ ์ธ)")
|
| 216 |
+
|
| 217 |
+
avg_monthly_sales_input = gr.Textbox(label="์ํ๊ท ๋งค์ถ์ก")
|
| 218 |
+
rent_input = gr.Textbox(label="์์ฐจ๋ฃ")
|
| 219 |
+
labor_cost_input = gr.Textbox(label="์ธ๊ฑด๋น")
|
| 220 |
+
management_cost_input = gr.Textbox(label="๊ด๋ฆฌ๋น")
|
| 221 |
+
utilities_input = gr.Textbox(label="์๋๊ด์ด๋น")
|
| 222 |
+
current_interest_input = gr.Textbox(label="์ง๊ธ์ด์")
|
| 223 |
+
other_cost_input = gr.Textbox(label="๊ธฐํ๋น์ฉ")
|
| 224 |
+
cost_ratio_input = gr.Textbox(label="์๊ฐ์จ")
|
| 225 |
+
|
| 226 |
+
result_output_fin = gr.Textbox(label="๊ฒฐ๊ณผ(์ ๋ชฉ: ์์น)")
|
| 227 |
+
|
| 228 |
+
analyze_button_fin = gr.Button("๊ณ์ฐํ๊ธฐ")
|
| 229 |
+
|
| 230 |
+
analyze_button_fin.click(
|
| 231 |
+
fn=analyze_financials,
|
| 232 |
+
inputs=[
|
| 233 |
+
avg_monthly_sales_input,
|
| 234 |
+
rent_input,
|
| 235 |
+
labor_cost_input,
|
| 236 |
+
management_cost_input,
|
| 237 |
+
utilities_input,
|
| 238 |
+
current_interest_input,
|
| 239 |
+
other_cost_input,
|
| 240 |
+
cost_ratio_input
|
| 241 |
+
],
|
| 242 |
+
outputs=result_output_fin
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
+
# =========================
|
| 246 |
+
# ํญ2) SWOT ๋ถ์
|
| 247 |
+
# =========================
|
| 248 |
+
with gr.Tab("SWOT ๋ถ์"):
|
| 249 |
+
gr.Markdown("### (๊ฐ์ , ์ฝ์ , ๊ธฐํ, ์ํ)")
|
| 250 |
+
|
| 251 |
+
strengths_input = gr.Textbox(label="๊ฐ์ ")
|
| 252 |
+
weaknesses_input = gr.Textbox(label="์ฝ์ ")
|
| 253 |
+
opportunities_input = gr.Textbox(label="๊ธฐํ")
|
| 254 |
+
threats_input = gr.Textbox(label="์ํ")
|
| 255 |
+
|
| 256 |
+
result_output_swot = gr.Textbox(label="SWOT ๋ถ์ ๊ฒฐ๊ณผ")
|
| 257 |
+
|
| 258 |
+
analyze_button_swot = gr.Button("๋ถ์ํ๊ธฐ")
|
| 259 |
+
|
| 260 |
+
analyze_button_swot.click(
|
| 261 |
+
fn=analyze_swot,
|
| 262 |
+
inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
|
| 263 |
+
outputs=result_output_swot
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
# =========================
|
| 267 |
+
# ํญ3) ์๊ถ ๋ถ์
|
| 268 |
+
# =========================
|
| 269 |
+
with gr.Tab("์๊ถ ๋ถ์"):
|
| 270 |
+
gr.Markdown("### (์ง์ญ + ์
์ข
โ 1km ์ด๋ด ์๊ถ๋ถ์, 6์ค ์ด๋ด)")
|
| 271 |
+
|
| 272 |
+
region_input = gr.Textbox(label="์ง์ญ")
|
| 273 |
+
industry_input = gr.Textbox(label="์
์ข
")
|
| 274 |
+
|
| 275 |
+
result_output_market = gr.Textbox(label="์๊ถ๋ถ์ ๊ฒฐ๊ณผ (์ต๋ 6์ค)")
|
| 276 |
+
|
| 277 |
+
analyze_button_market = gr.Button("๋ถ์ํ๊ธฐ")
|
| 278 |
+
|
| 279 |
+
analyze_button_market.click(
|
| 280 |
+
fn=analyze_market,
|
| 281 |
+
inputs=[region_input, industry_input],
|
| 282 |
+
outputs=result_output_market
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
# =========================
|
| 286 |
+
# ํญ4) ์ ๋ก์ฌํญ & ๋ชฉํ + Excel
|
| 287 |
+
# =========================
|
| 288 |
+
with gr.Tab("์ ๋ก์ฌํญ & ๋ชฉํ ๋ถ์"):
|
| 289 |
+
gr.Markdown("### (์ ๋ก์ฌํญ ๋ฐ ์ปจ์คํ
๋ชฉํ ์
๋ ฅ -> gpt-4o-mini ๋ถ์ -> Excel ๋ค์ด๋ก๋)")
|
| 290 |
+
|
| 291 |
+
with gr.Row():
|
| 292 |
+
difficulties_input = gr.Textbox(label="์ ๋ก์ฌํญ ์
๋ ฅ", lines=3)
|
| 293 |
+
goals_input = gr.Textbox(label="์ปจ์คํ
๋ชฉํ ์
๋ ฅ", lines=3)
|
| 294 |
+
|
| 295 |
+
analyze_button = gr.Button("๋ถ์ํ๊ธฐ")
|
| 296 |
+
|
| 297 |
+
preview_difficulties_output = gr.Textbox(label="์ ๋ก์ฌํญ ๋ถ์ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
|
| 298 |
+
preview_goals_output = gr.Textbox(label="์ปจ์คํ
๋ชฉํ ๋ถ์ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
|
| 299 |
+
|
| 300 |
+
download_button = gr.Button("์์
๋ก ๋ค์ด๋ก๋")
|
| 301 |
+
download_file = gr.File(label="๋ค์ด๋ก๋(ํด๋ฆญ ํ ์ ์ฅ)")
|
| 302 |
+
|
| 303 |
+
# ๋ถ์ ๋ฒํผ -> ๋ฏธ๋ฆฌ๋ณด๊ธฐ
|
| 304 |
+
analyze_button.click(
|
| 305 |
+
fn=run_analyze,
|
| 306 |
+
inputs=[difficulties_input, goals_input],
|
| 307 |
+
outputs=[preview_difficulties_output, preview_goals_output]
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
# ๋ค์ด๋ก๋ ๋ฒํผ -> Excel ํ์ผ ์์ฑ
|
| 311 |
+
download_button.click(
|
| 312 |
+
fn=run_generate_excel,
|
| 313 |
+
inputs=[
|
| 314 |
+
difficulties_input, goals_input,
|
| 315 |
+
preview_difficulties_output, preview_goals_output
|
| 316 |
+
],
|
| 317 |
+
outputs=[download_file]
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
return demo
|
| 321 |
+
|
| 322 |
+
##################################
|
| 323 |
+
# ์คํ
|
| 324 |
+
##################################
|
| 325 |
+
if __name__ == "__main__":
|
| 326 |
+
app = create_app()
|
| 327 |
+
app.launch()
|