Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
import openai
|
| 3 |
import gradio as gr
|
| 4 |
-
from openpyxl import load_workbook
|
| 5 |
-
from io import BytesIO
|
| 6 |
-
import tempfile
|
| 7 |
|
| 8 |
-
##################################
|
| 9 |
-
# (ํ์) OpenAI API
|
| 10 |
-
##################################
|
| 11 |
-
|
| 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", #
|
| 20 |
messages=[
|
| 21 |
{"role": "system", "content": system_message},
|
| 22 |
{"role": "user", "content": content},
|
|
@@ -27,301 +23,79 @@ def call_api(content, system_message, max_tokens, temperature, top_p):
|
|
| 27 |
)
|
| 28 |
return response.choices[0].message['content']
|
| 29 |
|
| 30 |
-
##################################
|
| 31 |
-
#
|
| 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 |
-
|
| 45 |
-
|
| 46 |
-
๊ฐ ํญ๋ชฉ๋ณ '์ ๋ชฉ: ์์น' ํํ๋ก๋ง ๋ฐํํ๋ ํจ์
|
| 47 |
-
(์ถ๋ ฅ์์ ์๊ฐ์จ์ ์ ์ธ)
|
| 48 |
"""
|
| 49 |
system_message = (
|
| 50 |
-
"๋น์ ์
|
| 51 |
-
"์์์์ต, ์์ต๋ถ๊ธฐ์ ์
|
| 52 |
-
"์ถ๊ฐ ์ค๋ช
|
| 53 |
)
|
| 54 |
content = f"""
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 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=
|
| 98 |
temperature=0.7,
|
| 99 |
top_p=1.0
|
| 100 |
)
|
| 101 |
|
| 102 |
-
##################################
|
| 103 |
-
#
|
| 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("##
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 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()
|
|
|
|
| 1 |
import os
|
| 2 |
import openai
|
| 3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
###################################
|
| 6 |
+
# (ํ์) OpenAI API ํด๋ผ์ด์ธํธ ์ค์
|
| 7 |
+
###################################
|
| 8 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
| 9 |
|
| 10 |
+
###################################
|
| 11 |
# [api์๋ฃ]์์ ์ฃผ์ด์ง ํจ์ (์์ ๊ธ์ง)
|
| 12 |
+
###################################
|
| 13 |
def call_api(content, system_message, max_tokens, temperature, top_p):
|
| 14 |
response = openai.ChatCompletion.create(
|
| 15 |
+
model="gpt-4o-mini", # ๋๋ ๋ค๋ฅธ ๋ชจ๋ธ ID ์ฌ์ฉ
|
| 16 |
messages=[
|
| 17 |
{"role": "system", "content": system_message},
|
| 18 |
{"role": "user", "content": content},
|
|
|
|
| 23 |
)
|
| 24 |
return response.choices[0].message['content']
|
| 25 |
|
| 26 |
+
###################################
|
| 27 |
+
# ๋ถ์ ํจ์
|
| 28 |
+
###################################
|
| 29 |
def analyze_financials(
|
| 30 |
+
avg_monthly_sales, # ์ํ๊ท ๋งค์ถ์ก
|
| 31 |
+
rent, # ์์ฐจ๋ฃ
|
| 32 |
+
labor_cost, # ์ธ๊ฑด๋น
|
| 33 |
+
management_cost, # ๊ด๋ฆฌ๋น
|
| 34 |
+
utilities, # ์๋๊ด์ด๋น
|
| 35 |
+
current_interest, # ์ง๊ธ์ด์
|
| 36 |
+
other_cost # ๊ธฐํ๋น์ฉ
|
|
|
|
| 37 |
):
|
| 38 |
"""
|
| 39 |
+
7๊ฐ์ง ํญ๋ชฉ์ ์
๋ ฅ๋ฐ์ ๊ฐ๊ฐ์๊ฐ๋น, ์๊ฐ์จ, ์์ด์ต์จ, ์์์์ต, ์์ต๋ถ๊ธฐ์ ์
|
| 40 |
+
'์ ๋ชฉ: ์์น' ํํ๋ก 5์ค๋ง ๋ฐํํ๋ ํจ์.
|
|
|
|
|
|
|
| 41 |
"""
|
| 42 |
system_message = (
|
| 43 |
+
"๋น์ ์ ์ฌ๋ฌด๋ถ์๊ฐ์
๋๋ค. ์๋ ์
๋ ฅ๊ฐ์ ๋ฐํ์ผ๋ก "
|
| 44 |
+
"๊ฐ๊ฐ์๊ฐ๋น, ์๊ฐ์จ, ์์ด์ต์จ, ์์์์ต, ์์ต๋ถ๊ธฐ์ ์ "
|
| 45 |
+
"'์ ๋ชฉ: ์์น' ํํ๋ก 5์ค๋ง ์๋ ค์ฃผ์ธ์. ์ถ๊ฐ ์ค๋ช
์์ด ๊ฐ๊ฒฐํ๊ฒ ๋ต๋ณํด์ฃผ์ธ์."
|
| 46 |
)
|
| 47 |
content = f"""
|
| 48 |
+
์ํ๊ท ๋งค์ถ์ก: {avg_monthly_sales}
|
| 49 |
+
์์ฐจ๋ฃ: {rent}
|
| 50 |
+
์ธ๊ฑด๋น: {labor_cost}
|
| 51 |
+
๊ด๋ฆฌ๋น: {management_cost}
|
| 52 |
+
์๋๊ด์ด๋น: {utilities}
|
| 53 |
+
์ง๊ธ์ด์: {current_interest}
|
| 54 |
+
๊ธฐํ๋น์ฉ: {other_cost}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
return call_api(
|
| 57 |
content=content,
|
| 58 |
system_message=system_message,
|
| 59 |
+
max_tokens=500,
|
| 60 |
temperature=0.7,
|
| 61 |
top_p=1.0
|
| 62 |
)
|
| 63 |
|
| 64 |
+
###################################
|
| 65 |
+
# Gradio UI
|
| 66 |
+
###################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
def create_app():
|
| 68 |
with gr.Blocks() as demo:
|
| 69 |
+
gr.Markdown("## ์ฌ๋ฌด ๋ถ์ (7๊ฐ ์
๋ ฅ) -> ๊ฐ๊ฐ์๊ฐ๋น / ์๊ฐ์จ / ์์ด์ต์จ / ์์์์ต / ์์ต๋ถ๊ธฐ์ ๊ณ์ฐ")
|
| 70 |
+
|
| 71 |
+
avg_monthly_sales_input = gr.Textbox(label="์ํ๊ท ๋งค์ถ์ก")
|
| 72 |
+
rent_input = gr.Textbox(label="์์ฐจ๋ฃ")
|
| 73 |
+
labor_cost_input = gr.Textbox(label="์ธ๊ฑด๋น")
|
| 74 |
+
management_cost_input = gr.Textbox(label="๊ด๋ฆฌ๋น")
|
| 75 |
+
utilities_input = gr.Textbox(label="์๋๊ด์ด๋น")
|
| 76 |
+
current_interest_input = gr.Textbox(label="์ง๊ธ์ด์")
|
| 77 |
+
other_cost_input = gr.Textbox(label="๊ธฐํ๋น์ฉ")
|
| 78 |
+
|
| 79 |
+
result_output = gr.Textbox(label="๊ฒฐ๊ณผ (์ ๋ชฉ: ์์น)")
|
| 80 |
+
|
| 81 |
+
analyze_button = gr.Button("๊ณ์ฐํ๊ธฐ")
|
| 82 |
+
|
| 83 |
+
analyze_button.click(
|
| 84 |
+
fn=analyze_financials,
|
| 85 |
+
inputs=[
|
| 86 |
+
avg_monthly_sales_input,
|
| 87 |
+
rent_input,
|
| 88 |
+
labor_cost_input,
|
| 89 |
+
management_cost_input,
|
| 90 |
+
utilities_input,
|
| 91 |
+
current_interest_input,
|
| 92 |
+
other_cost_input
|
| 93 |
+
],
|
| 94 |
+
outputs=result_output
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
|
|
|
|
|
|
|
|
|
| 99 |
if __name__ == "__main__":
|
| 100 |
app = create_app()
|
| 101 |
app.launch()
|