Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from llm_functions import classify_industry | |
| # ์์ ๋ฐ์ดํฐ | |
| example_companies = ["์ผ์ฑ์ ์", "์ ํ์ํ", "์ฟ ํก", "์๋ชจ๋ ํผ์ํฝ", "ํ๋๊ฑด์ค", "ํ์ด๋ธ", "ํ ์ค", "๋ฅ์จ", "์ผ์ฑ๋ฐ์ด์ค๋ก์ง์ค", "HMM"] | |
| example_jobs = ["๊ฒฝ์๊ธฐํ", "์จ๋ผ์ธ๋ง์ผํ ", "HRM(์ธ์ฌ์ด์)", "๋ฐฑ์๋ ๊ฐ๋ฐ", "ํด์ธ์์ ", "๋ฐ์ดํฐ ๋ถ์", "์์ ", "๋ง์ผํ ", "๊ธฐํ", "๊ฐ๋ฐ"] | |
| def create_tag_cards(tags): | |
| """ | |
| ๋ถ๋ฅ๋ ํ๊ทธ๋ค์ ์นด๋ ํํ๋ก ํ์ํ๋ HTML ์์ฑ | |
| """ | |
| if not tags: | |
| return "<div style='text-align: center; color: #6B7280; padding: 20px;'>๋ถ๋ฅ๋ฅผ ์คํํด์ฃผ์ธ์</div>" | |
| # ํ๊ทธ๋ช ๋งคํ | |
| tag_mapping = { | |
| "platform-portal": "ํ๋ซํผ/ํฌํธ", | |
| "e-commerce": "์ด์ปค๋จธ์ค", | |
| "game": "๊ฒ์", | |
| "it-solution-si": "IT์๋ฃจ์ /SI", | |
| "o2o-vertical": "O2O/๋ฒํฐ์ปฌ", | |
| "ai-data": "AI/๋ฐ์ดํฐ", | |
| "cloud-saas": "ํด๋ผ์ฐ๋/SaaS", | |
| "fintech": "ํํ ํฌ", | |
| "semiconductor": "๋ฐ๋์ฒด", | |
| "electronics-home": "๊ฐ์ /์ ์์ ํ", | |
| "automotive-mobility": "์๋์ฐจ/๋ชจ๋น๋ฆฌํฐ", | |
| "battery": "2์ฐจ์ ์ง", | |
| "display": "๋์คํ๋ ์ด", | |
| "heavy-industry-shipbuilding": "์ค๊ณต์ /์กฐ์ ", | |
| "steel-metal": "์ฒ ๊ฐ/๊ธ์", | |
| "bank": "์ํ", | |
| "securities": "์ฆ๊ถ", | |
| "insurance": "๋ณดํ", | |
| "card": "์นด๋", | |
| "asset-management": "์์ฐ์ด์ฉ", | |
| "dept-store-mart": "๋ฐฑํ์ /๋งํธ", | |
| "convenience-store": "ํธ์์ ", | |
| "fmcg-beverage": "FMCG/์์๋ฃ", | |
| "fashion-beauty": "ํจ์ /๋ทฐํฐ", | |
| "duty-free": "๋ฉด์ธ์ ", | |
| "pharma-new-drug": "์ ์ฝ/์ ์ฝ๊ฐ๋ฐ", | |
| "bio-cmo": "๋ฐ์ด์ค/CMO", | |
| "medical-device": "์๋ฃ๊ธฐ๊ธฐ", | |
| "digital-healthcare": "๋์งํธํฌ์ค์ผ์ด", | |
| "entertainment": "์ํฐํ ์ธ๋จผํธ", | |
| "contents-video": "์ฝํ ์ธ /์์์ ์", | |
| "ad-agency": "๊ด๊ณ ๋ํ์ฌ", | |
| "webtoon-webnovel": "์นํฐ/์น์์ค", | |
| "broadcasting-press": "๋ฐฉ์ก/์ธ๋ก ", | |
| "construction-engineering": "๊ฑด์ค/์์ง๋์ด๋ง", | |
| "realestate-development": "๋ถ๋์ฐ๊ฐ๋ฐ", | |
| "plant": "ํ๋ํธ", | |
| "interior": "์ธํ ๋ฆฌ์ด", | |
| "public-soc": "SOC (๊ณตํญ,๋๋ก,์ฒ ๋)", | |
| "public-energy": "์๋์ง ๊ณต๊ธฐ์ ", | |
| "public-finance": "๊ธ์ต ๊ณต๊ธฐ์ ", | |
| "public-admin": "์ผ๋ฐํ์ ", | |
| "mpe-semiconductor": "๋ฐ๋์ฒด ์๋ถ์ฅ", | |
| "mpe-display": "๋์คํ๋ ์ด ์๋ถ์ฅ", | |
| "mpe-battery": "2์ฐจ์ ์ง ์๋ถ์ฅ", | |
| "auto-parts": "์๋์ฐจ ๋ถํ", | |
| "chemical-materials": "ํํ/์์ฌ", | |
| "hotel": "ํธํ ", | |
| "travel-agency": "์ฌํ์ฌ", | |
| "airline": "ํญ๊ณต์ฌ", | |
| "leisure-resort": "๋ ์ /๋ฆฌ์กฐํธ", | |
| "consulting": "์ปจ์คํ ", | |
| "accounting-tax": "ํ๊ณ/์ธ๋ฌด", | |
| "law-firm": "๋ฒ๋ฅ (๋กํ)", | |
| "market-research": "๋ฆฌ์์น", | |
| "logistics-delivery": "๋ฌผ๋ฅ/ํ๋ฐฐ", | |
| "shipping": "ํด์ด", | |
| "forwarding": "ํฌ์๋ฉ", | |
| "land-transport": "์ก์์ด์ก", | |
| "edutech": "์๋ํ ํฌ", | |
| "private-academy": "์ ์/๋ณด์ตํ์", | |
| "edu-publishing": "๊ต์ก์ถํ", | |
| "language-edu": "์ธ๊ตญ์ด๊ต์ก", | |
| "ngo-npo": "NGO/NPO", | |
| "social-enterprise": "์ฌํ์ ๊ธฐ์ ", | |
| "foundation": "์ฌ๋จ" | |
| } | |
| cards_html = "<div style='display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;'>" | |
| colors = ["#EBF8FF", "#ECFDF5", "#FEF2F2", "#F5F3FF", "#FFF7ED", "#F0FDFA", "#FDF2F8"] | |
| border_colors = ["#1E40AF", "#059669", "#DC2626", "#7C3AED", "#EA580C", "#0F766E", "#BE185D"] | |
| for i, tag in enumerate(tags): | |
| color = colors[i % len(colors)] | |
| border_color = border_colors[i % len(border_colors)] | |
| tag_name = tag_mapping.get(tag, tag) | |
| cards_html += f""" | |
| <div style=" | |
| background-color: {color}; | |
| border: 2px solid {border_color}; | |
| border-radius: 12px; | |
| padding: 15px; | |
| margin: 5px; | |
| min-width: 150px; | |
| text-align: center; | |
| box-shadow: 0 2px 8px rgba(0,0,0,0.1); | |
| "> | |
| <div style=" | |
| font-weight: bold; | |
| color: {border_color}; | |
| font-size: 14px; | |
| margin-bottom: 5px; | |
| ">#{tag_name}</div> | |
| <div style=" | |
| color: #6B7280; | |
| font-size: 12px; | |
| font-family: monospace; | |
| ">{tag}</div> | |
| </div> | |
| """ | |
| cards_html += "</div>" | |
| return cards_html | |
| def process_classification(job_title, company_name): | |
| """ | |
| ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ฒ๋ฆฌํ๊ณ UI์ ํ์ํ ํํ๋ก ๋ณํํ๋ ํจ์ | |
| """ | |
| try: | |
| content, tags = classify_industry(job_title, company_name) | |
| tag_cards = create_tag_cards(tags) | |
| return content, tag_cards | |
| except Exception as e: | |
| error_content = f"""## โ ์ค๋ฅ ๋ฐ์ | |
| ์ฐ์ ๋ถ๋ฅ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. | |
| **์ค๋ฅ ๋ด์ฉ:** {str(e)} | |
| ๋ค์ ์๋ํด์ฃผ์ธ์. | |
| """ | |
| error_cards = create_tag_cards([]) | |
| return error_content, error_cards | |
| def create_interface(): | |
| """ | |
| Gradio ์ธํฐํ์ด์ค ์์ฑ | |
| """ | |
| with gr.Blocks( | |
| title="๐ท๏ธ AI ์ฐ์ ๋ถ๋ฅ๊ธฐ", | |
| theme=gr.themes.Soft(), | |
| css=""" | |
| .main-header { | |
| text-align: center; | |
| padding: 20px; | |
| background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| border-radius: 10px; | |
| margin-bottom: 20px; | |
| } | |
| .input-section { | |
| background-color: #f8f9fa; | |
| padding: 20px; | |
| border-radius: 8px; | |
| margin: 10px 0; | |
| } | |
| .example-section { | |
| background-color: #f0f9ff; | |
| padding: 15px; | |
| border-radius: 8px; | |
| margin: 10px 0; | |
| } | |
| """ | |
| ) as demo: | |
| # ํค๋ | |
| gr.HTML(""" | |
| <div class="main-header"> | |
| <h1>๐ท๏ธ AI ์ฐ์ ๋ถ๋ฅ๊ธฐ</h1> | |
| <p>์ง๋ฌด์ ํ์ฌ๋ช ์ ๋ฐํ์ผ๋ก ์ ํํ ์ฐ์ ๋ถ์ผ๋ฅผ ๋ถ๋ฅํฉ๋๋ค</p> | |
| </div> | |
| """) | |
| # ์ค๋ช | |
| gr.Markdown(""" | |
| ### ๐ **์ฌ์ฉ ๋ฐฉ๋ฒ** | |
| 1. **์ง๋ฌด**: ๋ถ๋ฅํ๊ณ ์ถ์ ์ง๋ฌด๋ฅผ ์ ๋ ฅํ์ธ์ | |
| 2. **ํ์ฌ๋ช **: ํด๋น ํ์ฌ๋ช ์ ์ ๋ ฅํ์ธ์ | |
| 3. **๋ถ๋ฅ**: '์ฐ์ ๋ถ๋ฅ' ๋ฒํผ์ ํด๋ฆญํ์ฌ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํ์ธ์ | |
| โจ **ํน์ง**: ํ์ฌ์ ์ฌ์ ์์ญ๊ณผ ์ง๋ฌด ํน์ฑ์ ์ข ํฉ์ ์ผ๋ก ๊ณ ๋ คํ์ฌ ์ ํํ ์ฐ์ ํ๊ทธ๋ฅผ ์ ๊ณตํฉ๋๋ค. | |
| """) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| # ์ ๋ ฅ ์น์ | |
| gr.HTML('<div class="input-section">') | |
| gr.Markdown("### ๐ **๊ธฐ๋ณธ ์ ๋ณด ์ ๋ ฅ**") | |
| with gr.Row(): | |
| job_input = gr.Textbox( | |
| label="๐ผ ์ง๋ฌด", | |
| placeholder="์: ๊ฒฝ์๊ธฐํ, ๋ฐฑ์๋ ๊ฐ๋ฐ, ์จ๋ผ์ธ๋ง์ผํ ๋ฑ", | |
| value="", | |
| scale=1 | |
| ) | |
| company_input = gr.Textbox( | |
| label="๐ข ํ์ฌ๋ช ", | |
| placeholder="์: ์ผ์ฑ์ ์, ํ ์ค, ์นด์นด์ค ๋ฑ", | |
| value="", | |
| scale=1 | |
| ) | |
| classify_btn = gr.Button( | |
| "๐ท๏ธ ์ฐ์ ๋ถ๋ฅ", | |
| variant="primary", | |
| size="lg" | |
| ) | |
| gr.HTML('</div>') | |
| with gr.Column(scale=1): | |
| # ์์ ๋ฐ ๊ฐ์ด๋ | |
| gr.HTML('<div class="example-section">') | |
| gr.Markdown("### ๐ก **์์ ํ์ฌ**") | |
| company_rows = [example_companies[i:i+2] for i in range(0, len(example_companies), 2)] | |
| for row in company_rows: | |
| with gr.Row(): | |
| for company in row: | |
| example_btn = gr.Button( | |
| company, | |
| size="sm", | |
| variant="secondary", | |
| scale=1 | |
| ) | |
| example_btn.click( | |
| fn=lambda x=company: x, | |
| outputs=company_input | |
| ) | |
| gr.Markdown("### ๐ผ **์์ ์ง๋ฌด**") | |
| job_rows = [example_jobs[i:i+2] for i in range(0, len(example_jobs), 2)] | |
| for row in job_rows: | |
| with gr.Row(): | |
| for job in row: | |
| job_btn = gr.Button( | |
| job, | |
| size="sm", | |
| variant="secondary", | |
| scale=1 | |
| ) | |
| job_btn.click( | |
| fn=lambda x=job: x, | |
| outputs=job_input | |
| ) | |
| gr.HTML('</div>') | |
| # ๊ฒฐ๊ณผ ์ถ๋ ฅ ์น์ | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| gr.Markdown("### ๐ **๋ถ๋ฅ ๊ฒฐ๊ณผ**") | |
| result_output = gr.Markdown( | |
| value="์ง๋ฌด์ ํ์ฌ๋ช ์ ์ ๋ ฅํ๊ณ '์ฐ์ ๋ถ๋ฅ' ๋ฒํผ์ ํด๋ฆญํ์ธ์.", | |
| elem_classes=["result-output"] | |
| ) | |
| with gr.Column(scale=1): | |
| gr.Markdown("### ๐ท๏ธ **์ฐ์ ํ๊ทธ**") | |
| tag_cards = gr.HTML( | |
| value="<div style='text-align: center; color: #6B7280; padding: 20px;'>๋ถ๋ฅ๋ฅผ ์คํํด์ฃผ์ธ์</div>", | |
| elem_classes=["tag-cards"] | |
| ) | |
| # ๋ถ๋ฅ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ | |
| classify_btn.click( | |
| fn=process_classification, | |
| inputs=[job_input, company_input], | |
| outputs=[result_output, tag_cards], | |
| api_name="classify_industry" | |
| ) | |
| # ํธํฐ | |
| gr.Markdown(""" | |
| --- | |
| **๐ก ๋ถ๋ฅ ๊ธฐ์ค**: | |
| - **ITยทํ๋ซํผยท๊ฒ์**: ํ๋ซํผ, ์ด์ปค๋จธ์ค, ๊ฒ์, IT์๋ฃจ์ , ํํ ํฌ ๋ฑ | |
| - **์ ์กฐยทํ๋์จ์ด**: ๋ฐ๋์ฒด, ๊ฐ์ , ์๋์ฐจ, 2์ฐจ์ ์ง, ๋์คํ๋ ์ด ๋ฑ | |
| - **๊ธ์ต**: ์ํ, ์ฆ๊ถ, ๋ณดํ, ์นด๋, ์์ฐ์ด์ฉ ๋ฑ | |
| - **์ ํตยท์๋น์ฌ**: ๋ฐฑํ์ , ํธ์์ , FMCG, ํจ์ ๋ทฐํฐ ๋ฑ | |
| - **๊ธฐํ**: ๋ฐ์ด์ค์ ์ฝ, ๋ฏธ๋์ด์ฝํ ์ธ , ๊ฑด์ค๋ถ๋์ฐ, ๊ณต๊ธฐ์ ๋ฑ | |
| ๐ค **Powered by**: OpenAI GPT-4o-mini with Web Search | |
| """) | |
| return demo | |
| if __name__ == "__main__": | |
| # Gradio ์ฑ ์คํ | |
| demo = create_interface() | |
| demo.launch( | |
| server_name="0.0.0.0", | |
| # server_port=7862, | |
| share=True, | |
| show_error=True | |
| ) |