Test3 / app.py
Sangwon78's picture
Update app.py
b2603bb verified
Raw History Blame Contribute Delete
15 kB
import os
import openai
import gradio as gr
###################################
# (ํ•„์ˆ˜) OpenAI API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
###################################
openai.api_key = os.getenv("OPENAI_API_KEY")
###################################
# [api์ž๋ฃŒ]์—์„œ ์ฃผ์–ด์ง„ ํ•จ์ˆ˜ (์ˆ˜์ • ๊ธˆ์ง€)import os
import openai
import gradio as gr
from openpyxl import load_workbook
from io import BytesIO
import tempfile
###################################
# (ํ•„์ˆ˜) OpenAI API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
###################################
# ๊ณต๋ฐฑ/๊ฐœํ–‰์ด ์žˆ์œผ๋ฉด strip() ์ฒ˜๋ฆฌ
openai.api_key = os.getenv("OPENAI_API_KEY").strip()
###################################
# [api์ž๋ฃŒ]์—์„œ ์ฃผ์–ด์ง„ ํ•จ์ˆ˜ (์ˆ˜์ • ๊ธˆ์ง€)
###################################
def call_api(content, system_message, max_tokens, temperature, top_p):
response = openai.ChatCompletion.create(
model="gpt-4o-mini", # gpt-4o-mini ๋ชจ๋ธ ์‚ฌ์šฉ
messages=[
{"role": "system", "content": system_message},
{"role": "user", "content": content},
],
max_tokens=max_tokens,
temperature=temperature,
top_p=top_p,
)
return response.choices[0].message['content']
###################################
# (1) ์žฌ๋ฌด ๋ถ„์„ ํ•จ์ˆ˜
###################################
def analyze_financials(
avg_monthly_sales, # ์›”ํ‰๊ท ๋งค์ถœ์•ก
rent, # ์ž„์ฐจ๋ฃŒ
labor_cost, # ์ธ๊ฑด๋น„
management_cost, # ๊ด€๋ฆฌ๋น„
utilities, # ์ˆ˜๋„๊ด‘์—ด๋น„
current_interest, # ์ง€๊ธˆ์ด์ž
other_cost, # ๊ธฐํƒ€๋น„์šฉ
cost_ratio # ์›๊ฐ€์œจ (์ถœ๋ ฅ์—๋Š” ํฌํ•จ ์•ˆ ํ•จ)
):
"""
์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ 8๊ฐ€์ง€ ํ•ญ๋ชฉ(์›”ํ‰๊ท ๋งค์ถœ์•ก, ์ž„์ฐจ๋ฃŒ, ์ธ๊ฑด๋น„, ๊ด€๋ฆฌ๋น„, ์ˆ˜๋„๊ด‘์—ด๋น„, ์ง€๊ธˆ์ด์ž, ๊ธฐํƒ€๋น„์šฉ, ์›๊ฐ€์œจ)์„ ๋ฐ”ํƒ•์œผ๋กœ
๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ ๊ณ„์‚ฐ(๋˜๋Š” ์ถ”์ •)ํ•˜์—ฌ,
๊ฐ ํ•ญ๋ชฉ๋ณ„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
(์ถœ๋ ฅ์—์„œ ์›๊ฐ€์œจ์€ ์ œ์™ธ)
"""
system_message = (
"๋‹น์‹ ์€ ์„ธ๋ฌด์‚ฌ(ํšŒ๊ณ„์‚ฌ)์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์ˆœ์ด์ต์œจ, "
"์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•์‹์œผ๋กœ๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. "
"์ถ”๊ฐ€ ์„ค๋ช…์ด๋‚˜ ๋ฌธ์žฅ ์—†์ด, ํ•ญ๋ชฉ๋ช…๊ณผ ์ˆ˜์น˜๋งŒ ๋ฐ˜ํ™˜ํ•ด์ฃผ์„ธ์š”."
)
content = f"""
์ž…๋ ฅ๋œ ๋ฐ์ดํ„ฐ:
- ์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}
- ์ž„์ฐจ๋ฃŒ: {rent}
- ์ธ๊ฑด๋น„: {labor_cost}
- ๊ด€๋ฆฌ๋น„: {management_cost}
- ์ˆ˜๋„๊ด‘์—ด๋น„: {utilities}
- ์ง€๊ธˆ์ด์ž: {current_interest}
- ๊ธฐํƒ€๋น„์šฉ: {other_cost}
- ์›๊ฐ€์œจ: {cost_ratio}
๋‹ค์Œ ํ•ญ๋ชฉ์˜ ๊ฒฐ๊ณผ๋ฅผ '์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ๋งŒ ๋ฐ˜ํ™˜ํ•ด ์ฃผ์„ธ์š”:
1) ๊ฐ๊ฐ€์ƒ๊ฐ๋น„
2) ์ˆœ์ด์ต์œจ
3) ์›”์ˆœ์ˆ˜์ต
4) ์†์ต๋ถ„๊ธฐ์ 
"""
return call_api(
content=content,
system_message=system_message,
max_tokens=1024,
temperature=0.7,
top_p=1.0
)
###################################
# (2) SWOT ๋ถ„์„ ํ•จ์ˆ˜
###################################
def analyze_swot(strengths, weaknesses, opportunities, threats):
"""
์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด
gpt-4o-mini ๋ชจ๋ธ์„ ํ™œ์šฉํ•ด ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
"""
system_message = (
"๋‹น์‹ ์€ swot ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž์˜ ๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘์— ๋Œ€ํ•ด "
"๊ฒ€์ƒ‰ํ•œ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜์—ฌ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
)
content = f"""
๊ฐ•์ : {strengths}
์•ฝ์ : {weaknesses}
๊ธฐํšŒ: {opportunities}
์œ„ํ˜‘: {threats}
"""
return call_api(
content=content,
system_message=system_message,
max_tokens=1024,
temperature=0.7,
top_p=1.0
)
###################################
# (3) ์ƒ๊ถŒ ๋ถ„์„ ํ•จ์ˆ˜ (6์ค„ ์ด๋‚ด)
###################################
def analyze_market(region, industry):
"""
์ง€์—ญ, ์—…์ข…์„ ์ž…๋ ฅ๋ฐ›์•„ 1km ์ด๋‚ด ์ƒ๊ถŒ๋ถ„์„์„ '์‚ฌ์ง„ ์–ธ๊ธ‰'๊ณผ ํ•จ๊ป˜,
6์ค„ ์ด๋‚ด ํ…์ŠคํŠธ๋กœ ์š”์•ฝํ•ด ์ฃผ๋Š” ํ•จ์ˆ˜
"""
system_message = (
"๋‹น์‹ ์€ ์ƒ๊ถŒ๋ถ„์„ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ๋œ ์ง€์—ญ๊ณผ ์—…์ข…์— ๋Œ€ํ•ด 1km ์ด๋‚ด ์ƒ๊ถŒ์„ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”. "
"์‚ฌ์ง„(๋˜๋Š” ์‹œ๊ฐ์ž๋ฃŒ)์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ํฌํ•จ, ์‘๋‹ต์€ 6์ค„ ์ด๋‚ด๋กœ ์ œํ•œํ•˜์„ธ์š”."
)
content = f"""
์ง€์—ญ: {region}
์—…์ข…: {industry}
"""
return call_api(
content=content,
system_message=system_message,
max_tokens=300, # ๋‹ต๋ณ€ ๊ธธ์ด ์ œํ•œ
temperature=0.7,
top_p=1.0
)
###################################
# (4) ์• ๋กœ์‚ฌํ•ญ & ์ปจ์„คํŒ…๋ชฉํ‘œ ๋ถ„์„ ํ•จ์ˆ˜
###################################
def analyze_texts(difficulties, goals):
"""
์‚ฌ์šฉ์ž ์ž…๋ ฅ(์• ๋กœ์‚ฌํ•ญ, ์ปจ์„คํŒ…๋ชฉํ‘œ)์„ gpt-4o-mini๋กœ ๋ถ„์„ ํ›„ ๊ฒฐ๊ณผ(๋ฏธ๋ฆฌ๋ณด๊ธฐ)๋ฅผ ๋ฆฌํ„ด
"""
# ์• ๋กœ์‚ฌํ•ญ ๋ถ„์„
preview_difficulties = call_api(
content=difficulties,
system_message="์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์• ๋กœ์‚ฌํ•ญ์„ ๊ฐ„๋‹จํžˆ ๋ถ„์„ ๋ฐ ํ•ด๊ฒฐ๋ฐฉ์•ˆ ์ œ์‹œํ•ด์ค˜.",
max_tokens=50,
temperature=0.7,
top_p=0.9
)
# ์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„
preview_goals = call_api(
content=goals,
system_message="์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ปจ์„คํŒ… ๋ชฉํ‘œ์— ๋Œ€ํ•œ ์š”์•ฝ ๋ฐ ์‹คํ–‰๋ฐฉ์•ˆ์„ ์ œ์‹œํ•ด์ค˜.",
max_tokens=50,
temperature=0.7,
top_p=0.9
)
return preview_difficulties, preview_goals
###################################
# ์—‘์…€ ์ƒ์„ฑ(๋‹ค์šด๋กœ๋“œ) ํ•จ์ˆ˜
###################################
def generate_excel(preview_difficulties, preview_goals):
"""
1) 'suu.xlsx'๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ
2) A4 = ์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ
A5 = ์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ
3) NamedTemporaryFile๋กœ ์ €์žฅ ํ›„ ํ•ด๋‹น ํŒŒ์ผ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
"""
wb = load_workbook("suu.xlsx")
ws = wb.active
# A4, A5 ์…€์— ๊ฒฐ๊ณผ ๊ธฐ์ž…
ws["A4"] = preview_difficulties
ws["A5"] = preview_goals
# ๋ฉ”๋ชจ๋ฆฌ ๋ฒ„ํผ์— ์ €์žฅ ํ›„ ์ž„์‹œํŒŒ์ผ๋กœ ์ƒ์„ฑ
output = BytesIO()
wb.save(output)
output.seek(0)
with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp:
tmp.write(output.getvalue())
tmp_path = tmp.name
return tmp_path
###################################
# Gradio ์ด๋ฒคํŠธ ํ•จ์ˆ˜๋“ค (์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ)
###################################
def run_analyze(difficulties, goals):
"""
'๋ถ„์„ํ•˜๊ธฐ' ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰:
- gpt-4o-mini API๋กœ ๋ถ„์„ ํ›„ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ํ…์ŠคํŠธ๋ฅผ ๋ฐ˜ํ™˜
"""
preview_difficulties, preview_goals = analyze_texts(difficulties, goals)
return preview_difficulties, preview_goals
def run_generate_excel(difficulties, goals, preview_difficulties, preview_goals):
"""
'์—‘์…€๋กœ ๋‹ค์šด๋กœ๋“œ' ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰:
- generate_excel()๋กœ ์—‘์…€ ํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ ,
- Gradio File ์ปดํฌ๋„ŒํŠธ๋กœ ๋‹ค์šด๋กœ๋“œ
"""
excel_path = generate_excel(preview_difficulties, preview_goals)
return excel_path
###################################
# Gradio ์•ฑ ๊ตฌ์„ฑ (4๊ฐœ ํƒญ)
###################################
def create_app():
with gr.Blocks() as demo:
gr.Markdown("## ํ†ตํ•ฉ Demo")
with gr.Tabs():
# ========== ํƒญ1: ์žฌ๋ฌด ๋ถ„์„ ==========
with gr.Tab("์žฌ๋ฌด ๋ถ„์„"):
gr.Markdown("### (์ž…๋ ฅ์— ์›๊ฐ€์œจ ํฌํ•จ, ๊ฒฐ๊ณผ์—์„œ ์›๊ฐ€์œจ ์ œ์™ธ)")
avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
labor_cost_input = gr.Textbox(label="์ธ๊ฑด๋น„")
management_cost_input = gr.Textbox(label="๊ด€๋ฆฌ๋น„")
utilities_input = gr.Textbox(label="์ˆ˜๋„๊ด‘์—ด๋น„")
current_interest_input = gr.Textbox(label="์ง€๊ธˆ์ด์ž")
other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
cost_ratio_input = gr.Textbox(label="์›๊ฐ€์œจ")
result_output_fin = gr.Textbox(label="๊ฒฐ๊ณผ(์ œ๋ชฉ: ์ˆ˜์น˜)")
analyze_button_fin = gr.Button("๊ณ„์‚ฐํ•˜๊ธฐ")
analyze_button_fin.click(
fn=analyze_financials,
inputs=[
avg_monthly_sales_input,
rent_input,
labor_cost_input,
management_cost_input,
utilities_input,
current_interest_input,
other_cost_input,
cost_ratio_input
],
outputs=result_output_fin
)
# ========== ํƒญ2: SWOT ๋ถ„์„ ==========
with gr.Tab("SWOT ๋ถ„์„"):
gr.Markdown("### (๊ฐ•์ , ์•ฝ์ , ๊ธฐํšŒ, ์œ„ํ˜‘)")
strengths_input = gr.Textbox(label="๊ฐ•์ ")
weaknesses_input = gr.Textbox(label="์•ฝ์ ")
opportunities_input = gr.Textbox(label="๊ธฐํšŒ")
threats_input = gr.Textbox(label="์œ„ํ˜‘")
result_output_swot = gr.Textbox(label="๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ")
analyze_button_swot = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
analyze_button_swot.click(
fn=analyze_swot,
inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
outputs=result_output_swot
)
# ========== ํƒญ3: ์ƒ๊ถŒ ๋ถ„์„ ==========
with gr.Tab("์ƒ๊ถŒ ๋ถ„์„"):
gr.Markdown("### (์ง€์—ญ + ์—…์ข… โ†’ 1km ์ด๋‚ด ์ƒ๊ถŒ๋ถ„์„, 6์ค„ ์ด๋‚ด)")
region_input = gr.Textbox(label="์ง€์—ญ")
industry_input = gr.Textbox(label="์—…์ข…")
result_output_market = gr.Textbox(label="์ƒ๊ถŒ๋ถ„์„ ๊ฒฐ๊ณผ (์ตœ๋Œ€ 6์ค„)")
analyze_button_market = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
analyze_button_market.click(
fn=analyze_market,
inputs=[region_input, industry_input],
outputs=result_output_market
)
# ========== ํƒญ4: ์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ ๋ถ„์„ + Excel ==========
with gr.Tab("์• ๋กœ์‚ฌํ•ญ & ๋ชฉํ‘œ"):
gr.Markdown("### (์• ๋กœ์‚ฌํ•ญ ๋ฐ ์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ -> gpt-4o-mini ๋ถ„์„ -> Excel ๋‹ค์šด๋กœ๋“œ)")
with gr.Row():
difficulties_input = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ์ž…๋ ฅ", lines=3, value="")
goals_input = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ์ž…๋ ฅ", lines=3, value="")
analyze_button = gr.Button("๋ถ„์„ํ•˜๊ธฐ")
preview_difficulties_output = gr.Textbox(label="์• ๋กœ์‚ฌํ•ญ ๋ถ„์„ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
preview_goals_output = gr.Textbox(label="์ปจ์„คํŒ… ๋ชฉํ‘œ ๋ถ„์„ ๊ฒฐ๊ณผ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", lines=3)
download_button = gr.Button("์—‘์…€๋กœ ๋‹ค์šด๋กœ๋“œ")
download_file = gr.File(label="๋‹ค์šด๋กœ๋“œ(ํด๋ฆญ ํ›„ ์ €์žฅ)")
# ๋ถ„์„ ๋ฒ„ํŠผ ํด๋ฆญ -> ๋ฏธ๋ฆฌ๋ณด๊ธฐ
analyze_button.click(
fn=run_analyze,
inputs=[difficulties_input, goals_input],
outputs=[preview_difficulties_output, preview_goals_output]
)
# ๋‹ค์šด๋กœ๋“œ ๋ฒ„ํŠผ ํด๋ฆญ -> Excel ์ƒ์„ฑ
download_button.click(
fn=run_generate_excel,
inputs=[difficulties_input, goals_input, preview_difficulties_output, preview_goals_output],
outputs=[download_file]
)
demo.launch()
return demo
###################################
# ์‹คํ–‰
###################################
if __name__ == "__main__":
app = create_app()
app.launch()
###################################
def call_api(content, system_message, max_tokens, temperature, top_p):
response = openai.ChatCompletion.create(
model="gpt-4o-mini", # ๋˜๋Š” ๋‹ค๋ฅธ ๋ชจ๋ธ ID ์‚ฌ์šฉ
messages=[
{"role": "system", "content": system_message},
{"role": "user", "content": content},
],
max_tokens=max_tokens,
temperature=temperature,
top_p=top_p,
)
return response.choices[0].message['content']
###################################
# ๋ถ„์„ ํ•จ์ˆ˜
###################################
def analyze_financials(
avg_monthly_sales, # ์›”ํ‰๊ท ๋งค์ถœ์•ก
rent, # ์ž„์ฐจ๋ฃŒ
labor_cost, # ์ธ๊ฑด๋น„
management_cost, # ๊ด€๋ฆฌ๋น„
utilities, # ์ˆ˜๋„๊ด‘์—ด๋น„
current_interest, # ์ง€๊ธˆ์ด์ž
other_cost # ๊ธฐํƒ€๋น„์šฉ
):
"""
7๊ฐ€์ง€ ํ•ญ๋ชฉ์„ ์ž…๋ ฅ๋ฐ›์•„ ๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์›๊ฐ€์œจ, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„
'์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ 5์ค„๋งŒ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜.
"""
system_message = (
"๋‹น์‹ ์€ ์žฌ๋ฌด๋ถ„์„๊ฐ€์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ "
"๊ฐ๊ฐ€์ƒ๊ฐ๋น„, ์›๊ฐ€์œจ, ์ˆœ์ด์ต์œจ, ์›”์ˆœ์ˆ˜์ต, ์†์ต๋ถ„๊ธฐ์ ์„ "
"'์ œ๋ชฉ: ์ˆ˜์น˜' ํ˜•ํƒœ๋กœ 5์ค„๋งŒ ์•Œ๋ ค์ฃผ์„ธ์š”. ์ถ”๊ฐ€ ์„ค๋ช… ์—†์ด ๊ฐ„๊ฒฐํ•˜๊ฒŒ ๋‹ต๋ณ€ํ•ด์ฃผ์„ธ์š”."
)
content = f"""
์›”ํ‰๊ท ๋งค์ถœ์•ก: {avg_monthly_sales}
์ž„์ฐจ๋ฃŒ: {rent}
์ธ๊ฑด๋น„: {labor_cost}
๊ด€๋ฆฌ๋น„: {management_cost}
์ˆ˜๋„๊ด‘์—ด๋น„: {utilities}
์ง€๊ธˆ์ด์ž: {current_interest}
๊ธฐํƒ€๋น„์šฉ: {other_cost}
"""
return call_api(
content=content,
system_message=system_message,
max_tokens=500,
temperature=0.7,
top_p=1.0
)
###################################
# Gradio UI
###################################
def create_app():
with gr.Blocks() as demo:
gr.Markdown("## ์žฌ๋ฌด ๋ถ„์„ (7๊ฐœ ์ž…๋ ฅ) -> ๊ฐ๊ฐ€์ƒ๊ฐ๋น„ / ์›๊ฐ€์œจ / ์ˆœ์ด์ต์œจ / ์›”์ˆœ์ˆ˜์ต / ์†์ต๋ถ„๊ธฐ์  ๊ณ„์‚ฐ")
avg_monthly_sales_input = gr.Textbox(label="์›”ํ‰๊ท ๋งค์ถœ์•ก")
rent_input = gr.Textbox(label="์ž„์ฐจ๋ฃŒ")
labor_cost_input = gr.Textbox(label="์ธ๊ฑด๋น„")
management_cost_input = gr.Textbox(label="๊ด€๋ฆฌ๋น„")
utilities_input = gr.Textbox(label="์ˆ˜๋„๊ด‘์—ด๋น„")
current_interest_input = gr.Textbox(label="์ง€๊ธˆ์ด์ž")
other_cost_input = gr.Textbox(label="๊ธฐํƒ€๋น„์šฉ")
result_output = gr.Textbox(label="๊ฒฐ๊ณผ (์ œ๋ชฉ: ์ˆ˜์น˜)")
analyze_button = gr.Button("๊ณ„์‚ฐํ•˜๊ธฐ")
analyze_button.click(
fn=analyze_financials,
inputs=[
avg_monthly_sales_input,
rent_input,
labor_cost_input,
management_cost_input,
utilities_input,
current_interest_input,
other_cost_input
],
outputs=result_output
)
demo.launch()
if __name__ == "__main__":
app = create_app()
app.launch()