Delete app-backup.py
Browse files- app-backup.py +0 -436
app-backup.py
DELETED
|
@@ -1,436 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Square Theory Brand Generator
|
| 3 |
-
=============================
|
| 4 |
-
2025-05-28 | Square Theory๋ฅผ ํ์ฉํ ๋ธ๋๋ ๋ค์ด๋ฐ & ์ฌ๋ก๊ฑด ์์ฑ๊ธฐ
|
| 5 |
-
----------------------------------------------------------
|
| 6 |
-
|
| 7 |
-
Square Theory๋ฅผ ๋ธ๋๋ฉ์ ์ ์ฉ: ๋ธ๋๋๋ช
์ด Square๋ฅผ ์์ฑํ๋ ๊ตฌ์กฐ
|
| 8 |
-
์: GRUBHUB = GRUB(์์) + HUB(์ค์ฌ) โ ์์ ๋ฐฐ๋ฌ์ ์ค์ฌ
|
| 9 |
-
"""
|
| 10 |
-
|
| 11 |
-
import os
|
| 12 |
-
import json
|
| 13 |
-
import gradio as gr
|
| 14 |
-
import openai
|
| 15 |
-
from openai import OpenAI
|
| 16 |
-
from datetime import datetime
|
| 17 |
-
from typing import List, Dict, Tuple, Optional
|
| 18 |
-
|
| 19 |
-
# OpenAI ํด๋ผ์ด์ธํธ
|
| 20 |
-
if not os.getenv("OPENAI_API_KEY"):
|
| 21 |
-
raise EnvironmentError("OPENAI_API_KEY ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ์ธ์.")
|
| 22 |
-
|
| 23 |
-
client = OpenAI()
|
| 24 |
-
|
| 25 |
-
# Square Theory ๋ธ๋๋ฉ ์ ์ฉ ํ๋กฌํํธ
|
| 26 |
-
BRANDING_SQUARE_PROMPT = """
|
| 27 |
-
๋น์ ์ Square Theory๋ฅผ ํ์ฉํ ๋ธ๋๋ ๋ค์ด๋ฐ ์ ๋ฌธ๊ฐ์
๋๋ค.
|
| 28 |
-
|
| 29 |
-
Square Theory๋ 4๊ฐ์ ๋จ์ด๊ฐ ์๋ฏธ์ ๊ด๊ณ๋ก ์ฐ๊ฒฐ๋์ด ์ฌ๊ฐํ์ ์ด๋ฃจ๋ ๊ตฌ์กฐ์
๋๋ค.
|
| 30 |
-
์ด๋ฅผ ๋ธ๋๋ฉ์ ์ ์ฉํ๋ฉด, ๋ธ๋๋๋ช
์ด Square๋ฅผ ์์ฑํ๋ฉฐ "์ํ!" ๋ชจ๋จผํธ๋ฅผ ๋ง๋ญ๋๋ค.
|
| 31 |
-
|
| 32 |
-
์ฑ๊ณต์ ์ธ ๋ธ๋๋ Square ์์:
|
| 33 |
-
1. GRUBHUB: GRUB(์์) + HUB(์ค์ฌ) = ์์ ๋ฐฐ๋ฌ์ ์ค์ฌ์ง
|
| 34 |
-
2. Brand New (๋ฆฌ๋ธ๋๋ฉ ๋ธ๋ก๊ทธ): BRAND + NEW = ์๋ก์ด ๋ธ๋๋ = ์
๋ฐ์ดํธ๋ ๋ธ๋๋
|
| 35 |
-
3. Crosscord: CROSSWORD + DISCORD = ํฌ๋ก์ค์๋ ์ปค๋ฎค๋ํฐ ์๋ฒ
|
| 36 |
-
|
| 37 |
-
๋ธ๋๋ Square ์์ฑ ์์น:
|
| 38 |
-
1. ๋ธ๋๋๋ช
์ ๋ ๋จ์ด์ ์กฐํฉ (ํฉ์ฑ์ด, ํฌํธ๋งจํ , ๋๋ ๊ตฌ๋ฌธ)
|
| 39 |
-
2. ๊ฐ ๋จ์ด๋ ๋น์ฆ๋์ค์ ํต์ฌ ์์ฑ๊ณผ ์ฐ๊ฒฐ
|
| 40 |
-
3. ์ ์ฒด Square๊ฐ ๋ธ๋๋์ ์ ์ฒด์ฑ์ ๊ฐํ
|
| 41 |
-
4. ์ฌ๋ก๊ฑด์ Square์ ์๋ฏธ๋ฅผ ํ์ฅ
|
| 42 |
-
|
| 43 |
-
์ฌ์ฉ์ ์
๋ ฅ(์
์ข
/ํค์๋)์ ๋ฐ์ ๋ค์ ํ์์ JSON ๋ฐฐ์ด์ ์์ฑํ์ธ์:
|
| 44 |
-
{
|
| 45 |
-
"brand_name": "๋ธ๋๋๋ช
",
|
| 46 |
-
"brand_type": "compound/portmanteau/phrase",
|
| 47 |
-
"tl": "์ผ์ชฝ์๋จ ๋จ์ด",
|
| 48 |
-
"tr": "์ค๋ฅธ์ชฝ์๋จ ๋จ์ด",
|
| 49 |
-
"bl": "์ผ์ชฝํ๋จ ๋จ์ด",
|
| 50 |
-
"br": "์ค๋ฅธ์ชฝํ๋จ ๋จ์ด",
|
| 51 |
-
"top_edge": "์๋จ ๊ด๊ณ",
|
| 52 |
-
"bottom_edge": "ํ๋จ ๊ด๊ณ",
|
| 53 |
-
"left_edge": "์ผ์ชฝ ๊ด๊ณ",
|
| 54 |
-
"right_edge": "์ค๋ฅธ์ชฝ ๊ด๊ณ",
|
| 55 |
-
"slogan": "๋ธ๋๋ ์ฌ๋ก๊ฑด",
|
| 56 |
-
"tagline": "์งง์ ํ๊ทธ๋ผ์ธ",
|
| 57 |
-
"business_description": "๋น์ฆ๋์ค ์ค๋ช
",
|
| 58 |
-
"why_it_works": "์ ์ด Square๊ฐ ํจ๊ณผ์ ์ธ์ง",
|
| 59 |
-
"target_audience": "ํ๊ฒ ๊ณ ๊ฐ",
|
| 60 |
-
"brand_personality": "๋ธ๋๋ ๊ฐ์ฑ",
|
| 61 |
-
"impact_score": 1-10
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
์ฐฝ์์ ์ด๋ฉด์๋ ๊ธฐ์ตํ๊ธฐ ์ฝ๊ณ , ๋น์ฆ๋์ค ๋ณธ์ง์ ๋ด์ ๋ธ๋๋๋ฅผ ๋ง๋์ธ์.
|
| 65 |
-
"""
|
| 66 |
-
|
| 67 |
-
# ์
์ข
๋ณ ์์
|
| 68 |
-
INDUSTRY_EXAMPLES = [
|
| 69 |
-
"์นดํ/์ปคํผ์",
|
| 70 |
-
"ํผํธ๋์ค/ํฌ์ค์ฅ",
|
| 71 |
-
"๊ต์ก/์๋ํ
ํฌ",
|
| 72 |
-
"๋ทฐํฐ/ํ์ฅํ",
|
| 73 |
-
"์์ ๋ฐฐ๋ฌ",
|
| 74 |
-
"์ฌํ/๊ด๊ด",
|
| 75 |
-
"๊ธ์ต/ํํ
ํฌ",
|
| 76 |
-
"ํจ์
/์๋ฅ",
|
| 77 |
-
"๋ฐ๋ ค๋๋ฌผ",
|
| 78 |
-
"์นํ๊ฒฝ/์ง์๊ฐ๋ฅ"
|
| 79 |
-
]
|
| 80 |
-
|
| 81 |
-
def generate_brand_squares(industry: str, keywords: str, count: int = 5) -> List[Dict]:
|
| 82 |
-
"""Square Theory ๊ธฐ๋ฐ ๋ธ๋๋ ์์ฑ"""
|
| 83 |
-
|
| 84 |
-
user_prompt = f"""
|
| 85 |
-
์
์ข
: {industry}
|
| 86 |
-
ํค์๋: {keywords}
|
| 87 |
-
|
| 88 |
-
์ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก Square Theory๋ฅผ ํ์ฉํ ๋ธ๋๋ {count}๊ฐ๋ฅผ ์์ฑํ์ธ์.
|
| 89 |
-
๊ฐ ๋ธ๋๋๋ ์์ ํ Square๋ฅผ ํ์ฑํด์ผ ํ๋ฉฐ, ๋ธ๋๋๋ช
์ด Square์ ํต์ฌ์ด ๋์ด์ผ ํฉ๋๋ค.
|
| 90 |
-
"""
|
| 91 |
-
|
| 92 |
-
try:
|
| 93 |
-
response = client.chat.completions.create(
|
| 94 |
-
model="gpt-4o",
|
| 95 |
-
messages=[
|
| 96 |
-
{"role": "system", "content": BRANDING_SQUARE_PROMPT},
|
| 97 |
-
{"role": "user", "content": user_prompt}
|
| 98 |
-
],
|
| 99 |
-
temperature=0.85,
|
| 100 |
-
max_tokens=4000,
|
| 101 |
-
response_format={"type": "json_object"}
|
| 102 |
-
)
|
| 103 |
-
|
| 104 |
-
content = response.choices[0].message.content
|
| 105 |
-
data = json.loads(content)
|
| 106 |
-
|
| 107 |
-
# ์๋ต ์ ๊ทํ
|
| 108 |
-
if isinstance(data, dict):
|
| 109 |
-
if "brands" in data:
|
| 110 |
-
results = data["brands"]
|
| 111 |
-
elif "results" in data:
|
| 112 |
-
results = data["results"]
|
| 113 |
-
else:
|
| 114 |
-
results = [data]
|
| 115 |
-
else:
|
| 116 |
-
results = data
|
| 117 |
-
|
| 118 |
-
# ์ ์์ ์ ๋ ฌ
|
| 119 |
-
results.sort(key=lambda x: x.get("impact_score", 0), reverse=True)
|
| 120 |
-
|
| 121 |
-
return results[:count]
|
| 122 |
-
|
| 123 |
-
except Exception as e:
|
| 124 |
-
raise RuntimeError(f"๋ธ๋๋ ์์ฑ ์คํจ: {e}")
|
| 125 |
-
|
| 126 |
-
def visualize_brand_square(brand: Dict) -> str:
|
| 127 |
-
"""๋ธ๋๋ Square ์๊ฐํ"""
|
| 128 |
-
|
| 129 |
-
brand_name = brand.get('brand_name', 'BRAND')
|
| 130 |
-
tl, tr = brand.get('tl', '?'), brand.get('tr', '?')
|
| 131 |
-
bl, br = brand.get('bl', '?'), brand.get('br', '?')
|
| 132 |
-
|
| 133 |
-
# ๋ธ๋๋๋ช
๋ถํด (compound/portmanteau์ธ ๊ฒฝ์ฐ)
|
| 134 |
-
if brand.get('brand_type') == 'compound':
|
| 135 |
-
parts = brand_name.split()
|
| 136 |
-
brand_part1 = parts[0] if len(parts) > 0 else brand_name[:len(brand_name)//2]
|
| 137 |
-
brand_part2 = parts[1] if len(parts) > 1 else brand_name[len(brand_name)//2:]
|
| 138 |
-
else:
|
| 139 |
-
# ํฌํธ๋งจํ ์ ๊ฒฝ์ฐ ๋๋ต์ ์ผ๋ก ๋ถํ
|
| 140 |
-
mid = len(brand_name) // 2
|
| 141 |
-
brand_part1 = brand_name[:mid+1]
|
| 142 |
-
brand_part2 = brand_name[mid-1:]
|
| 143 |
-
|
| 144 |
-
return f"""
|
| 145 |
-
<div style="max-width: 700px; margin: 20px auto; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
|
| 146 |
-
|
| 147 |
-
<!-- ๋ธ๋๋๋ช
ํค๋ -->
|
| 148 |
-
<div style="text-align: center; margin-bottom: 30px;">
|
| 149 |
-
<h2 style="font-size: 2.5em; margin: 0; color: #2c3e50; letter-spacing: -1px;">{brand_name}</h2>
|
| 150 |
-
<p style="font-size: 1.2em; color: #7f8c8d; margin: 10px 0; font-style: italic;">"{brand.get('slogan', '')}"</p>
|
| 151 |
-
<p style="font-size: 0.9em; color: #95a5a6; margin: 5px 0;">{brand.get('tagline', '')}</p>
|
| 152 |
-
</div>
|
| 153 |
-
|
| 154 |
-
<!-- Square ๋ค์ด์ด๊ทธ๋จ -->
|
| 155 |
-
<div style="position: relative; width: 100%; height: 350px; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); border-radius: 12px; padding: 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);">
|
| 156 |
-
|
| 157 |
-
<!-- ์ค์ ๋ธ๋๋๋ช
-->
|
| 158 |
-
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 20px 40px; border-radius: 12px; box-shadow: 0 5px 20px rgba(0,0,0,0.15); z-index: 10;">
|
| 159 |
-
<div style="font-size: 1.8em; font-weight: bold; color: #2c3e50; text-align: center;">{brand_name}</div>
|
| 160 |
-
<div style="font-size: 0.9em; color: #7f8c8d; text-align: center; margin-top: 5px;">{brand.get('brand_type', 'compound')}</div>
|
| 161 |
-
</div>
|
| 162 |
-
|
| 163 |
-
<!-- ๊ผญ์ง์ -->
|
| 164 |
-
<div style="position: absolute; top: 30px; left: 30px; background: #3498db; color: white; padding: 12px 20px; border-radius: 8px; font-weight: 600; box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);">
|
| 165 |
-
{tl}
|
| 166 |
-
</div>
|
| 167 |
-
<div style="position: absolute; top: 30px; right: 30px; background: #e74c3c; color: white; padding: 12px 20px; border-radius: 8px; font-weight: 600; box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);">
|
| 168 |
-
{tr}
|
| 169 |
-
</div>
|
| 170 |
-
<div style="position: absolute; bottom: 30px; left: 30px; background: #f39c12; color: white; padding: 12px 20px; border-radius: 8px; font-weight: 600; box-shadow: 0 3px 10px rgba(243, 156, 18, 0.3);">
|
| 171 |
-
{bl}
|
| 172 |
-
</div>
|
| 173 |
-
<div style="position: absolute; bottom: 30px; right: 30px; background: #27ae60; color: white; padding: 12px 20px; border-radius: 8px; font-weight: 600; box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);">
|
| 174 |
-
{br}
|
| 175 |
-
</div>
|
| 176 |
-
|
| 177 |
-
<!-- ๊ด๊ณ ๋ ์ด๋ธ -->
|
| 178 |
-
<div style="position: absolute; top: 45px; left: 50%; transform: translateX(-50%); background: rgba(44, 62, 80, 0.9); color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.8em;">
|
| 179 |
-
{brand.get('top_edge', '๊ด๊ณ')}
|
| 180 |
-
</div>
|
| 181 |
-
<div style="position: absolute; bottom: 45px; left: 50%; transform: translateX(-50%); background: rgba(44, 62, 80, 0.9); color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.8em;">
|
| 182 |
-
{brand.get('bottom_edge', '๊ด๊ณ')}
|
| 183 |
-
</div>
|
| 184 |
-
<div style="position: absolute; top: 50%; left: 45px; transform: translateY(-50%) rotate(-90deg); background: rgba(44, 62, 80, 0.9); color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.8em;">
|
| 185 |
-
{brand.get('left_edge', '๊ด๊ณ')}
|
| 186 |
-
</div>
|
| 187 |
-
<div style="position: absolute; top: 50%; right: 45px; transform: translateY(-50%) rotate(90deg); background: rgba(44, 62, 80, 0.9); color: white; padding: 4px 12px; border-radius: 4px; font-size: 0.8em;">
|
| 188 |
-
{brand.get('right_edge', '๊ด๊ณ')}
|
| 189 |
-
</div>
|
| 190 |
-
|
| 191 |
-
<!-- ์ฐ๊ฒฐ์ -->
|
| 192 |
-
<svg style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none;">
|
| 193 |
-
<defs>
|
| 194 |
-
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 195 |
-
<stop offset="0%" style="stop-color:#3498db;stop-opacity:0.5" />
|
| 196 |
-
<stop offset="100%" style="stop-color:#e74c3c;stop-opacity:0.5" />
|
| 197 |
-
</linearGradient>
|
| 198 |
-
<linearGradient id="grad2" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 199 |
-
<stop offset="0%" style="stop-color:#f39c12;stop-opacity:0.5" />
|
| 200 |
-
<stop offset="100%" style="stop-color:#27ae60;stop-opacity:0.5" />
|
| 201 |
-
</linearGradient>
|
| 202 |
-
</defs>
|
| 203 |
-
<!-- ์๋จ -->
|
| 204 |
-
<line x1="100" y1="45" x2="600" y2="45" stroke="url(#grad1)" stroke-width="3"/>
|
| 205 |
-
<!-- ํ๋จ -->
|
| 206 |
-
<line x1="100" y1="305" x2="600" y2="305" stroke="url(#grad2)" stroke-width="3"/>
|
| 207 |
-
<!-- ์ผ์ชฝ -->
|
| 208 |
-
<line x1="50" y1="80" x2="50" y2="270" stroke="#7f8c8d" stroke-width="3" opacity="0.5"/>
|
| 209 |
-
<!-- ์ค๋ฅธ์ชฝ -->
|
| 210 |
-
<line x1="650" y1="80" x2="650" y2="270" stroke="#7f8c8d" stroke-width="3" opacity="0.5"/>
|
| 211 |
-
</svg>
|
| 212 |
-
</div>
|
| 213 |
-
|
| 214 |
-
<!-- ๋ธ๋๋ ์ ๋ณด -->
|
| 215 |
-
<div style="margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
|
| 216 |
-
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);">
|
| 217 |
-
<h4 style="margin: 0 0 10px 0; color: #2c3e50;">๐ฏ ๏ฟฝ๏ฟฝ๏ฟฝ๊ฒ ๊ณ ๊ฐ</h4>
|
| 218 |
-
<p style="margin: 0; color: #7f8c8d;">{brand.get('target_audience', 'N/A')}</p>
|
| 219 |
-
</div>
|
| 220 |
-
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);">
|
| 221 |
-
<h4 style="margin: 0 0 10px 0; color: #2c3e50;">โจ ๋ธ๋๋ ๊ฐ์ฑ</h4>
|
| 222 |
-
<p style="margin: 0; color: #7f8c8d;">{brand.get('brand_personality', 'N/A')}</p>
|
| 223 |
-
</div>
|
| 224 |
-
</div>
|
| 225 |
-
|
| 226 |
-
<div style="margin-top: 20px; background: #ecf0f1; padding: 20px; border-radius: 8px;">
|
| 227 |
-
<h4 style="margin: 0 0 10px 0; color: #2c3e50;">๐ก ์ ํจ๊ณผ์ ์ธ๊ฐ?</h4>
|
| 228 |
-
<p style="margin: 0; color: #34495e;">{brand.get('why_it_works', '')}</p>
|
| 229 |
-
</div>
|
| 230 |
-
</div>
|
| 231 |
-
"""
|
| 232 |
-
|
| 233 |
-
def generate_brands(industry: str, keywords: str, count: int) -> Tuple[str, str, List[Dict]]:
|
| 234 |
-
"""๋ธ๋๋ ์์ฑ ๋ฐ ํ์"""
|
| 235 |
-
|
| 236 |
-
if not industry or not keywords:
|
| 237 |
-
return "โ ๏ธ ์
์ข
๊ณผ ํค์๋๋ฅผ ๋ชจ๋ ์
๋ ฅํด์ฃผ์ธ์.", "", []
|
| 238 |
-
|
| 239 |
-
try:
|
| 240 |
-
brands = generate_brand_squares(industry, keywords, count)
|
| 241 |
-
|
| 242 |
-
# ๋งํฌ๋ค์ด ๊ฒฐ๊ณผ
|
| 243 |
-
markdown_parts = [
|
| 244 |
-
f"# ๐ข Square Theory ๋ธ๋๋ ์ ์",
|
| 245 |
-
f"**์
์ข
**: {industry} | **ํค์๋**: {keywords}",
|
| 246 |
-
f"*์์ฑ ์๊ฐ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n"
|
| 247 |
-
]
|
| 248 |
-
|
| 249 |
-
# HTML ์๊ฐํ
|
| 250 |
-
html_parts = []
|
| 251 |
-
|
| 252 |
-
for idx, brand in enumerate(brands, 1):
|
| 253 |
-
score = brand.get('impact_score', 0)
|
| 254 |
-
|
| 255 |
-
markdown_parts.append(f"""
|
| 256 |
-
## {idx}. {brand.get('brand_name', 'N/A')} {'โญ' * min(score, 5)}
|
| 257 |
-
|
| 258 |
-
**์ฌ๋ก๊ฑด**: *"{brand.get('slogan', 'N/A')}"*
|
| 259 |
-
**ํ๊ทธ๋ผ์ธ**: {brand.get('tagline', 'N/A')}
|
| 260 |
-
|
| 261 |
-
### ๐ Square ๊ตฌ์กฐ
|
| 262 |
-
```
|
| 263 |
-
[{brand.get('tl', '?')}] โ({brand.get('top_edge', '?')})โ [{brand.get('tr', '?')}]
|
| 264 |
-
โ โ
|
| 265 |
-
({brand.get('left_edge', '?')}) ({brand.get('right_edge', '?')})
|
| 266 |
-
โ โ
|
| 267 |
-
[{brand.get('bl', '?')}] โ({brand.get('bottom_edge', '?')})โ [{brand.get('br', '?')}]
|
| 268 |
-
```
|
| 269 |
-
|
| 270 |
-
**๋น์ฆ๋์ค**: {brand.get('business_description', 'N/A')}
|
| 271 |
-
**ํ๊ฒ**: {brand.get('target_audience', 'N/A')}
|
| 272 |
-
**๊ฐ์ฑ**: {brand.get('brand_personality', 'N/A')}
|
| 273 |
-
|
| 274 |
-
๐ก **ํจ๊ณผ**: {brand.get('why_it_works', 'N/A')}
|
| 275 |
-
|
| 276 |
-
---
|
| 277 |
-
""")
|
| 278 |
-
|
| 279 |
-
# ๋ชจ๋ ๋ธ๋๋ ์๊ฐํ
|
| 280 |
-
html_parts.append(f"<h3 style='text-align: center; color: #7f8c8d; margin: 40px 0 20px 0;'>#{idx}</h3>")
|
| 281 |
-
html_parts.append(visualize_brand_square(brand))
|
| 282 |
-
|
| 283 |
-
return "\n".join(markdown_parts), "\n".join(html_parts), brands
|
| 284 |
-
|
| 285 |
-
except Exception as e:
|
| 286 |
-
return f"โ ์ค๋ฅ: {str(e)}", "", []
|
| 287 |
-
|
| 288 |
-
def export_brands(brands: List[Dict]) -> str:
|
| 289 |
-
"""๋ธ๋๋ ์ ๋ณด JSON ๋ด๋ณด๋ด๊ธฐ"""
|
| 290 |
-
if not brands:
|
| 291 |
-
return None
|
| 292 |
-
|
| 293 |
-
export_data = {
|
| 294 |
-
"generated_at": datetime.now().isoformat(),
|
| 295 |
-
"total_brands": len(brands),
|
| 296 |
-
"brands": brands
|
| 297 |
-
}
|
| 298 |
-
|
| 299 |
-
return json.dumps(export_data, ensure_ascii=False, indent=2)
|
| 300 |
-
|
| 301 |
-
# Gradio UI
|
| 302 |
-
with gr.Blocks(title="Square Theory Brand Generator", theme=gr.themes.Soft()) as demo:
|
| 303 |
-
gr.Markdown("""
|
| 304 |
-
# ๐ข Square Theory Brand Generator
|
| 305 |
-
### ์๋ฏธ์ Square๋ฅผ ์์ฑํ๋ ๋ธ๋๋ ๋ค์ด๋ฐ & ์ฌ๋ก๊ฑด ์์ฑ๊ธฐ
|
| 306 |
-
|
| 307 |
-
Square Theory๋ฅผ ํ์ฉํด ๋ธ๋๋๋ช
์ด ์๋ฏธ์ ์ฌ๊ฐํ์ ์์ฑํ๋ ๊ฐ๋ ฅํ ๋ธ๋๋๋ฅผ ๋ง๋ค์ด๋ณด์ธ์.
|
| 308 |
-
์ข์ ๋ธ๋๋๋ช
์ ๋จ์ํ ์ด๋ฆ์ด ์๋, ๋น์ฆ๋์ค์ ๋ณธ์ง์ ๋ด์ Square๋ฅผ ํ์ฑํฉ๋๋ค.
|
| 309 |
-
|
| 310 |
-
**์ฑ๊ณต ์ฌ๋ก**: GRUBHUB (GRUB+HUB), Brand New, Crosscord
|
| 311 |
-
""")
|
| 312 |
-
|
| 313 |
-
with gr.Row():
|
| 314 |
-
with gr.Column(scale=2):
|
| 315 |
-
industry_input = gr.Dropdown(
|
| 316 |
-
choices=INDUSTRY_EXAMPLES,
|
| 317 |
-
label="๐ญ ์
์ข
",
|
| 318 |
-
allow_custom_value=True,
|
| 319 |
-
value="์นดํ/์ปคํผ์"
|
| 320 |
-
)
|
| 321 |
-
|
| 322 |
-
keywords_input = gr.Textbox(
|
| 323 |
-
label="๐ ํต์ฌ ํค์๋",
|
| 324 |
-
placeholder="ํ๋ฆฌ๋ฏธ์, ํธ์ํ, ๋์์ ์ธ, ์นํ๊ฒฝ...",
|
| 325 |
-
info="๋ธ๋๋๊ฐ ๋ด์์ผ ํ ํต์ฌ ๊ฐ์น๋ ํน์ง๋ค"
|
| 326 |
-
)
|
| 327 |
-
|
| 328 |
-
count_slider = gr.Slider(
|
| 329 |
-
minimum=3,
|
| 330 |
-
maximum=10,
|
| 331 |
-
value=5,
|
| 332 |
-
step=1,
|
| 333 |
-
label="์์ฑ ๊ฐ์"
|
| 334 |
-
)
|
| 335 |
-
|
| 336 |
-
generate_btn = gr.Button("๐ ๋ธ๋๋ Square ์์ฑ", variant="primary", size="lg")
|
| 337 |
-
|
| 338 |
-
with gr.Column(scale=1):
|
| 339 |
-
gr.Markdown("""
|
| 340 |
-
### ๐ก Square Theory ๋ธ๋๋ฉ
|
| 341 |
-
|
| 342 |
-
**์ข์ ๋ธ๋๋ Square์ ์กฐ๊ฑด:**
|
| 343 |
-
1. ๋ธ๋๋๋ช
์ ๊ฐ ๋ถ๋ถ์ด ์๋ฏธ๋ฅผ ๊ฐ์ง
|
| 344 |
-
2. ๋น์ฆ๋์ค ๋ณธ์ง๊ณผ ์ฐ๊ฒฐ
|
| 345 |
-
3. ๊ธฐ์ตํ๊ธฐ ์ฝ๊ณ ๋ฐ์ ๊ฐ๋ฅ
|
| 346 |
-
4. Square๊ฐ "์ํ!" ๋ชจ๋จผํธ ์์ฑ
|
| 347 |
-
|
| 348 |
-
**Square ๊ตฌ๏ฟฝ๏ฟฝ ์์:**
|
| 349 |
-
```
|
| 350 |
-
GRUB โ(์์)โ FOOD
|
| 351 |
-
โ โ
|
| 352 |
-
(์ค์ฌ) (๋ฐฐ๋ฌ)
|
| 353 |
-
โ โ
|
| 354 |
-
HUB โ(์๋น์ค)โ DELIVERY
|
| 355 |
-
```
|
| 356 |
-
""")
|
| 357 |
-
|
| 358 |
-
# ์ ์ญ ๋ณ์
|
| 359 |
-
current_brands = gr.State([])
|
| 360 |
-
|
| 361 |
-
with gr.Tabs():
|
| 362 |
-
with gr.Tab("๐ ๊ฒฐ๊ณผ ๋ฆฌ์คํธ"):
|
| 363 |
-
output_markdown = gr.Markdown()
|
| 364 |
-
|
| 365 |
-
with gr.Tab("๐จ ๋ธ๋๋ ์๊ฐํ"):
|
| 366 |
-
output_visual = gr.HTML()
|
| 367 |
-
|
| 368 |
-
with gr.Tab("๐พ ๋ด๋ณด๋ด๊ธฐ"):
|
| 369 |
-
export_btn = gr.Button("JSON ํ์ผ ์์ฑ")
|
| 370 |
-
download_file = gr.File(label="๋ค์ด๋ก๋", visible=False)
|
| 371 |
-
|
| 372 |
-
# ์์
|
| 373 |
-
gr.Examples(
|
| 374 |
-
examples=[
|
| 375 |
-
["์นดํ/์ปคํผ์", "ํ๋ฆฌ๋ฏธ์, ์๋ํ, ๋์"],
|
| 376 |
-
["ํผํธ๋์ค/ํฌ์ค์ฅ", "๊ฐ๋ ฅํ, ์ปค๋ฎค๋ํฐ, ๋ณํ"],
|
| 377 |
-
["๊ต์ก/์๋ํ
ํฌ", "์ค๋งํธ, ์ฌ๋ฏธ์๋, ์ฑ์ฅ"],
|
| 378 |
-
["์์ ๋ฐฐ๋ฌ", "๋น ๋ฅธ, ์ ์ ํ, ๋ค์ํ"],
|
| 379 |
-
["์นํ๊ฒฝ/์ง์๊ฐ๋ฅ", "์์ฐ, ๋ฏธ๋, ์ํ"]
|
| 380 |
-
],
|
| 381 |
-
inputs=[industry_input, keywords_input]
|
| 382 |
-
)
|
| 383 |
-
|
| 384 |
-
# ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
| 385 |
-
def generate_and_store(industry, keywords, count):
|
| 386 |
-
markdown, html, brands = generate_brands(industry, keywords, count)
|
| 387 |
-
return markdown, html, brands
|
| 388 |
-
|
| 389 |
-
generate_btn.click(
|
| 390 |
-
fn=generate_and_store,
|
| 391 |
-
inputs=[industry_input, keywords_input, count_slider],
|
| 392 |
-
outputs=[output_markdown, output_visual, current_brands]
|
| 393 |
-
)
|
| 394 |
-
|
| 395 |
-
def create_export_file(brands):
|
| 396 |
-
if not brands:
|
| 397 |
-
return None
|
| 398 |
-
|
| 399 |
-
content = export_brands(brands)
|
| 400 |
-
filename = f"square_theory_brands_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 401 |
-
|
| 402 |
-
with open(filename, 'w', encoding='utf-8') as f:
|
| 403 |
-
f.write(content)
|
| 404 |
-
|
| 405 |
-
return gr.File(value=filename, visible=True)
|
| 406 |
-
|
| 407 |
-
export_btn.click(
|
| 408 |
-
fn=create_export_file,
|
| 409 |
-
inputs=[current_brands],
|
| 410 |
-
outputs=[download_file]
|
| 411 |
-
)
|
| 412 |
-
|
| 413 |
-
gr.Markdown("""
|
| 414 |
-
---
|
| 415 |
-
### ๐ฏ ํ์ฉ ๋ฐฉ๋ฒ
|
| 416 |
-
|
| 417 |
-
1. **๋ธ๋๋ ๊ฐ๋ฐ**: ์์ฑ๋ Square ์ค ๊ฐ์ฅ ๊ฐ๋ ฅํ ๊ฒ ์ ํ
|
| 418 |
-
2. **๋ง์ผํ
์ ๋ต**: Square์ ๊ฐ ์์๋ฅผ ์บ ํ์ธ์ ํ์ฉ
|
| 419 |
-
3. **์คํ ๋ฆฌํ
๋ง**: Square๊ฐ ๋ง๋๋ ๋ด๋ฌํฐ๋ธ ํ์ฉ
|
| 420 |
-
4. **ํ์ฅ ๊ฐ๋ฅ์ฑ**: Square์ ๊ฐ ๋ชจ์๋ฆฌ์์ ์๋ธ๋ธ๋๋ ํ์
|
| 421 |
-
|
| 422 |
-
### ๐ Square Theory ๋ธ๋๋ฉ์ ํ
|
| 423 |
-
|
| 424 |
-
Square๋ฅผ ์์ฑํ๋ ๋ธ๋๋๋:
|
| 425 |
-
- **๊ธฐ์ตํ๊ธฐ ์ฌ์**: ์๋ฏธ์ ์ฐ๊ฒฐ์ด ๊ธฐ์ต์ ๊ฐํ
|
| 426 |
-
- **์คํ ๋ฆฌ๊ฐ ์์**: Square ์์ฒด๊ฐ ๋ธ๋๋ ์คํ ๋ฆฌ
|
| 427 |
-
- **ํ์ฅ ๊ฐ๋ฅ**: ๊ฐ ์์์์ ์๋ก์ด ์๋ฏธ ํ์
|
| 428 |
-
- **์ฐจ๋ณํ๋จ**: ๋
ํนํ ์๋ฏธ ๊ตฌ์กฐ๋ก ๊ฒฝ์์ฌ์ ๊ตฌ๋ณ
|
| 429 |
-
""")
|
| 430 |
-
|
| 431 |
-
if __name__ == "__main__":
|
| 432 |
-
demo.launch(
|
| 433 |
-
server_name="0.0.0.0",
|
| 434 |
-
server_port=7860,
|
| 435 |
-
share=False
|
| 436 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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