Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
"""
|
2 |
-
Square Theory Generator
|
3 |
-
|
4 |
-
2025-05-28 |
|
5 |
-
|
6 |
|
7 |
-
Square Theory
|
8 |
-
์:
|
9 |
"""
|
10 |
|
11 |
import os
|
@@ -22,63 +22,82 @@ if not os.getenv("OPENAI_API_KEY"):
|
|
22 |
|
23 |
client = OpenAI()
|
24 |
|
25 |
-
# Square Theory ์ ์ฉ ํ๋กฌํํธ
|
26 |
-
|
27 |
-
๋น์ ์ Square Theory
|
28 |
-
๊ฐ ๋ณ์ด ์๋ฏธ์ ๊ด๊ณ(๋์์ด, ๊ตฌ๋ฌธ, ์ด์จ ๋ฑ)๋ก ์ฐ๊ฒฐ๋๋ ์ธ์ด ๊ตฌ์กฐ์
๋๋ค.
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
2. ์ธ์ ํ ๋จ์ด๋ค์ ํน์ ๊ด๊ณ๋ก ์ฐ๊ฒฐ (๋ณ)
|
33 |
-
3. ๋๋ณ์ ๋จ์ด๋ค์ ์ง์ ์ฐ๊ฒฐ๋์ง ์์ง๋ง, ๋ค๋ฅธ ๋ณ๋ค์ ํตํด ๋๋ผ์ด ์ผ์น๋ฅผ ์ด๋ฃธ
|
34 |
-
4. ์ ์ฒด ๊ตฌ์กฐ๊ฐ "์ํ!" ๋ชจ๋จผํธ๋ฅผ ๋ง๋ค์ด์ผ ํจ
|
35 |
|
36 |
-
์์:
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
{
|
|
|
|
|
45 |
"tl": "์ผ์ชฝ์๋จ ๋จ์ด",
|
46 |
"tr": "์ค๋ฅธ์ชฝ์๋จ ๋จ์ด",
|
47 |
"bl": "์ผ์ชฝํ๋จ ๋จ์ด",
|
48 |
"br": "์ค๋ฅธ์ชฝํ๋จ ๋จ์ด",
|
49 |
-
"top_edge": "์๋จ ๊ด๊ณ
|
50 |
-
"bottom_edge": "ํ๋จ ๊ด๊ณ
|
51 |
-
"left_edge": "์ผ์ชฝ ๊ด๊ณ
|
52 |
-
"right_edge": "์ค๋ฅธ์ชฝ ๊ด๊ณ
|
53 |
-
"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
๋๋ณ ์ฌ์ด์ ์จ๊ฒจ์ง ์ฐ๊ฒฐ์ด ๋๋ฌ๋ ๋์ "์ํ!" ๋ชจ๋จผํธ๋ฅผ ๋ชฉํ๋ก ํ์ธ์.
|
61 |
"""
|
62 |
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
72 |
|
73 |
try:
|
74 |
response = client.chat.completions.create(
|
75 |
model="gpt-4o",
|
76 |
messages=[
|
77 |
-
{"role": "system", "content":
|
78 |
{"role": "user", "content": user_prompt}
|
79 |
],
|
80 |
-
temperature=0.
|
81 |
-
max_tokens=
|
82 |
response_format={"type": "json_object"}
|
83 |
)
|
84 |
|
@@ -87,8 +106,8 @@ def call_square_theory_llm(seed: str, mode: str = "word") -> List[Dict]:
|
|
87 |
|
88 |
# ์๋ต ์ ๊ทํ
|
89 |
if isinstance(data, dict):
|
90 |
-
if "
|
91 |
-
results = data["
|
92 |
elif "results" in data:
|
93 |
results = data["results"]
|
94 |
else:
|
@@ -97,212 +116,316 @@ def call_square_theory_llm(seed: str, mode: str = "word") -> List[Dict]:
|
|
97 |
results = data
|
98 |
|
99 |
# ์ ์์ ์ ๋ ฌ
|
100 |
-
results.sort(key=lambda x: x.get("
|
101 |
|
102 |
-
return results[:
|
103 |
|
104 |
except Exception as e:
|
105 |
-
raise RuntimeError(f"
|
106 |
|
107 |
-
def
|
108 |
-
"""Square
|
109 |
|
110 |
-
|
111 |
-
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
return f"""
|
119 |
-
<div style="max-width:
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
-
<!-- ๊ผญ์ง์
|
123 |
-
<div style="position: absolute; top:
|
124 |
{tl}
|
125 |
</div>
|
126 |
-
<div style="position: absolute; top:
|
127 |
{tr}
|
128 |
</div>
|
129 |
-
<div style="position: absolute; bottom:
|
130 |
{bl}
|
131 |
</div>
|
132 |
-
<div style="position: absolute; bottom:
|
133 |
{br}
|
134 |
</div>
|
135 |
|
136 |
-
<!--
|
137 |
-
<div style="position: absolute; top:
|
138 |
-
{top_edge}
|
139 |
</div>
|
140 |
-
<div style="position: absolute; bottom:
|
141 |
-
{bottom_edge}
|
142 |
</div>
|
143 |
-
<div style="position: absolute; top: 50%; left:
|
144 |
-
{left_edge}
|
145 |
</div>
|
146 |
-
<div style="position: absolute; top: 50%; right:
|
147 |
-
{right_edge}
|
148 |
</div>
|
149 |
|
150 |
<!-- ์ฐ๊ฒฐ์ -->
|
151 |
<svg style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
<!-- ์๋จ -->
|
153 |
-
<line x1="
|
154 |
<!-- ํ๋จ -->
|
155 |
-
<line x1="
|
156 |
<!-- ์ผ์ชฝ -->
|
157 |
-
<line x1="50" y1="
|
158 |
<!-- ์ค๋ฅธ์ชฝ -->
|
159 |
-
<line x1="
|
160 |
</svg>
|
161 |
</div>
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
<
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
</div>
|
168 |
</div>
|
169 |
"""
|
170 |
|
171 |
-
def
|
172 |
-
"""
|
|
|
|
|
|
|
173 |
|
174 |
try:
|
175 |
-
|
176 |
-
|
177 |
-
if not squares:
|
178 |
-
return "Square๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.", ""
|
179 |
|
180 |
# ๋งํฌ๋ค์ด ๊ฒฐ๊ณผ
|
181 |
markdown_parts = [
|
182 |
-
f"#
|
183 |
-
f"
|
|
|
184 |
]
|
185 |
|
186 |
# HTML ์๊ฐํ
|
187 |
html_parts = []
|
188 |
|
189 |
-
for idx,
|
190 |
-
score =
|
191 |
|
192 |
markdown_parts.append(f"""
|
193 |
-
|
194 |
|
195 |
-
|
|
|
|
|
|
|
196 |
```
|
197 |
-
[{
|
198 |
-
โ
|
199 |
-
({
|
200 |
-
โ
|
201 |
-
[{
|
202 |
```
|
203 |
|
204 |
-
|
|
|
|
|
|
|
|
|
205 |
|
206 |
---
|
207 |
""")
|
208 |
|
209 |
-
#
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
return "\n".join(markdown_parts), "\n".join(html_parts)
|
214 |
|
215 |
except Exception as e:
|
216 |
-
return f"โ ์ค๋ฅ: {str(e)}", ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
# Gradio UI
|
219 |
-
with gr.Blocks(title="Square Theory Generator", theme=gr.themes.Soft()) as demo:
|
220 |
gr.Markdown("""
|
221 |
-
#
|
222 |
-
### ์๋ฏธ์
|
223 |
|
224 |
-
|
225 |
-
|
226 |
|
227 |
-
|
228 |
-
- PUB โ BAR (๋์์ด)
|
229 |
-
- QUIZ โ EXAM (๋์์ด)
|
230 |
-
- PUB QUIZ (๊ตฌ๋ฌธ)
|
231 |
-
- BAR EXAM (๊ตฌ๋ฌธ)
|
232 |
""")
|
233 |
|
234 |
with gr.Row():
|
235 |
with gr.Column(scale=2):
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
)
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
label="์์ฑ ๋ชจ๋",
|
249 |
-
value="word"
|
250 |
)
|
251 |
|
252 |
-
generate_btn = gr.Button("
|
253 |
|
254 |
with gr.Column(scale=1):
|
255 |
gr.Markdown("""
|
256 |
-
### ๐ก
|
257 |
-
|
258 |
-
**๋จ์ด ํฌํจ**: ํน์ ๋จ์ด๋ฅผ ํฌํจํ๋ Square
|
259 |
-
- ์: "BLACK" โ JET BLACK / JETBLUE
|
260 |
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
263 |
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
""")
|
267 |
|
|
|
|
|
|
|
268 |
with gr.Tabs():
|
269 |
-
with gr.Tab("
|
270 |
output_markdown = gr.Markdown()
|
271 |
|
272 |
-
with gr.Tab("๐จ ์๊ฐํ"):
|
273 |
output_visual = gr.HTML()
|
|
|
|
|
|
|
|
|
274 |
|
275 |
# ์์
|
276 |
gr.Examples(
|
277 |
examples=[
|
278 |
-
["
|
279 |
-
["
|
280 |
-
["
|
281 |
-
["
|
282 |
-
["
|
283 |
],
|
284 |
-
inputs=[
|
285 |
)
|
286 |
|
287 |
# ์ด๋ฒคํธ ์ฐ๏ฟฝ๏ฟฝ
|
|
|
|
|
|
|
|
|
288 |
generate_btn.click(
|
289 |
-
fn=
|
290 |
-
inputs=[
|
291 |
-
outputs=[output_markdown, output_visual]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
)
|
293 |
|
294 |
gr.Markdown("""
|
295 |
---
|
296 |
-
###
|
297 |
|
298 |
-
|
299 |
-
|
|
|
|
|
300 |
|
301 |
-
|
302 |
-
2. **๋๋ผ์**: ๋๋ณ ์ฐ๊ฒฐ์ด ์์์น ๋ชปํ ํต์ฐฐ ์ ๊ณต
|
303 |
-
3. **๊ท ํ**: ๋ชจ๋ ๊ด๊ณ๊ฐ ๋น์ทํ ๊ฐ๋
|
304 |
|
305 |
-
|
|
|
|
|
|
|
|
|
306 |
""")
|
307 |
|
308 |
if __name__ == "__main__":
|
|
|
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
|
|
|
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 |
|
|
|
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:
|
|
|
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__":
|