File size: 29,433 Bytes
7ebe30e
2bb1715
 
 
 
 
 
 
 
7ebe30e
c8b9002
7ebe30e
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ebe30e
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8b9002
 
2bb1715
8b72279
c8b9002
8b72279
 
 
 
 
c8b9002
 
2bb1715
 
 
8b72279
c8b9002
2bb1715
8b72279
 
 
 
 
c8b9002
 
2bb1715
 
 
8b72279
c8b9002
2bb1715
8b72279
 
 
 
 
c8b9002
 
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b72279
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b72279
2bb1715
 
8b72279
2bb1715
 
 
 
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
 
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
 
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
 
 
43b41a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
c8b9002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
002f297
c8b9002
 
 
 
 
002f297
 
c8b9002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bb1715
 
c8b9002
2bb1715
 
 
c8b9002
 
adbe0a9
2bb1715
 
 
 
 
 
 
c8b9002
 
 
 
 
 
 
 
2bb1715
c8b9002
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b72279
2bb1715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b72279
2bb1715
7ebe30e
74c61e9
c8b9002
 
 
 
 
002f297
 
7ebe30e
2bb1715
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
import gradio as gr
import requests
from bs4 import BeautifulSoup
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
import re
import time
import random
import os
from huggingface_hub import InferenceClient
from fpdf import FPDF

def setup_session():
    try:
        session = requests.Session()
        retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504])
        session.mount('https://', HTTPAdapter(max_retries=retries))
        return session
    except Exception as e:
        return None

def generate_naver_search_url(query):
    base_url = "https://search.naver.com/search.naver?"
    params = {"ssc": "tab.blog.all", "sm": "tab_jum", "query": query}
    url = base_url + "&".join(f"{key}={value}" for key, value in params.items())
    return url

def crawl_blog_content(url, session):
    try:
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
            "Accept-Encoding": "gzip, deflate, br",
            "Connection": "keep-alive",
            "Referer": "https://search.naver.com/search.naver",
        }
        
        # ๋žœ๋ค ๋”œ๋ ˆ์ด ์ถ”๊ฐ€
        delay = random.uniform(1, 2)
        time.sleep(delay)

        response = session.get(url, headers=headers)
        if response.status_code != 200:
            return ""
        
        soup = BeautifulSoup(response.content, "html.parser")
        content = soup.find("div", attrs={'class': 'se-main-container'})
        
        if content:
            return clean_text(content.get_text())
        else:
            return ""
    except Exception as e:
        return ""

def crawl_naver_search_results(url, session):
    try:
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
            "Accept-Encoding": "gzip, deflate, br",
            "Connection": "keep-alive",
            "Referer": "https://search.naver.com/search.naver",
        }
        response = session.get(url, headers=headers)
        if response.status_code != 200:
            return []

        soup = BeautifulSoup(response.content, "html.parser")
        results = []
        count = 0
        for li in soup.find_all("li", class_=re.compile("bx.*")):
            if count >= 10:
                break
            for div in li.find_all("div", class_="detail_box"):
                for div2 in div.find_all("div", class_="title_area"):
                    title = div2.text.strip()
                    for a in div2.find_all("a", href=True):
                        link = a["href"]
                        if "blog.naver" in link:
                            link = link.replace("https://", "https://m.")
                            results.append({"์ œ๋ชฉ": title, "๋งํฌ": link})
                            count += 1
                            if count >= 10:
                                break
                if count >= 10:
                    break
            if count >= 10:
                break
        
        return results
    except Exception as e:
        return []

def clean_text(text):
    text = re.sub(r'\s+', ' ', text).strip()
    return text

def create_client(model_name):
    return InferenceClient(model_name, token=os.getenv("HF_TOKEN"))

client = create_client("CohereForAI/c4ai-command-r-plus")

def call_api(content, system_message, max_tokens, temperature, top_p):
    messages = [{"role": "system", "content": system_message}, {"role": "user", "content": content}]
    random_seed = random.randint(0, 1000000)
    response = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=temperature, top_p=top_p, seed=random_seed)
    modified_text = response.choices[0].message.content
    input_tokens = response.usage.prompt_tokens
    output_tokens = response.usage.completion_tokens
    total_tokens = response.usage.total_tokens
    return modified_text, input_tokens, output_tokens, total_tokens

def analyze_info(category, style, topic, references1, references2, references3):
    return f"์„ ํƒํ•œ ์นดํ…Œ๊ณ ๋ฆฌ: {category}\n์„ ํƒํ•œ ํฌ์ŠคํŒ… ์Šคํƒ€์ผ: {style}\n๋ธ”๋กœ๊ทธ ์ฃผ์ œ: {topic}\n์ฐธ๊ณ  ๊ธ€1: {references1}\n์ฐธ๊ณ  ๊ธ€2: {references2}\n์ฐธ๊ณ  ๊ธ€3: {references3}"

def suggest_title(category, style, topic, references1, references2, references3):
    full_content = analyze_info(category, style, topic, references1, references2, references3)
    category_prompt = get_title_prompt(category)
    style_prompt = get_style_prompt(style)
    max_tokens = 5000
    temperature = 0.8
    top_p = 0.95
    combined_prompt = f"{category_prompt}\n\n{style_prompt}"
    modified_text, input_tokens, output_tokens, total_tokens = call_api(full_content, combined_prompt, max_tokens, temperature, top_p)
    token_usage_message = f"[์ž…๋ ฅ ํ† ํฐ์ˆ˜: {input_tokens}]\n[์ถœ๋ ฅ ํ† ํฐ์ˆ˜: {output_tokens}]\n[์ด ํ† ํฐ์ˆ˜: {total_tokens}]"
    return modified_text, token_usage_message

def generate_outline(category, style, topic, references1, references2, references3, title):
    full_content = analyze_info(category, style, topic, references1, references2, references3)
    content = f"{full_content}\nTitle: {title}"
    category_prompt = get_outline_prompt(category)
    style_prompt = get_style_prompt(style)
    max_tokens = 6000
    temperature = 0.8
    top_p = 0.95
    combined_prompt = f"{category_prompt}\n\n{style_prompt}"
    modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
    token_usage_message = f"[์ž…๋ ฅ ํ† ํฐ์ˆ˜: {input_tokens}]\n[์ถœ๋ ฅ ํ† ํฐ์ˆ˜: {output_tokens}]\n[์ด ํ† ํฐ์ˆ˜: {total_tokens}]"
    return modified_text, token_usage_message

def generate_blog_post(category, style, topic, references1, references2, references3, title, outline):
    full_content = analyze_info(category, style, topic, references1, references2, references3)
    content = f"{full_content}\nTitle: {title}\nOutline: {outline}"
    category_prompt = get_blog_post_prompt(category)
    style_prompt = get_style_prompt(style)
    max_tokens = 8000
    temperature = 0.8
    top_p = 0.95
    combined_prompt = f"{category_prompt}\n\n{style_prompt}"
    modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
    formatted_text = modified_text.replace('\n', '\n\n')
    token_usage_message = f"[์ž…๋ ฅ ํ† ํฐ์ˆ˜: {input_tokens}]\n[์ถœ๋ ฅ ํ† ํฐ์ˆ˜: {output_tokens}]\n[์ด ํ† ํฐ์ˆ˜: {total_tokens}]"
    return formatted_text, token_usage_message

def fetch_references(topic):
    search_url = generate_naver_search_url(topic)
    session = setup_session()
    if session is None:
        return "Failed to set up session.", "", "", ""
    results = crawl_naver_search_results(search_url, session)
    if not results:
        return "No results found.", "", "", ""
    
    selected_results = random.sample(results, 3)
    references1_content = f"์ œ๋ชฉ: {selected_results[0]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[0]['๋งํฌ'], session)}"
    references2_content = f"์ œ๋ชฉ: {selected_results[1]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[1]['๋งํฌ'], session)}"
    references3_content = f"์ œ๋ชฉ: {selected_results[2]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[2]['๋งํฌ'], session)}"
    
    return "์ฐธ๊ณ ๊ธ€ ์ƒ์„ฑ ์™„๋ฃŒ", references1_content, references2_content, references3_content

def fetch_references_and_generate_all_steps(category, style, topic, blog_title):
    search_url = generate_naver_search_url(topic)
    session = setup_session()
    if session is None:
        return "", "", "", "", "", "", "", "", "", ""
    
    results = crawl_naver_search_results(search_url, session)
    if not results:
        return "", "", "", "", "", "", "", "", "", ""
    
    selected_results = random.sample(results, 3)
    references1_content = f"์ œ๋ชฉ: {selected_results[0]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[0]['๋งํฌ'], session)}"
    references2_content = f"์ œ๋ชฉ: {selected_results[1]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[1]['๋งํฌ'], session)}"
    references3_content = f"์ œ๋ชฉ: {selected_results[2]['์ œ๋ชฉ']}\n๋‚ด์šฉ: {crawl_blog_content(selected_results[2]['๋งํฌ'], session)}"
    
    # ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ
    outline_result, outline_token_usage = generate_outline(category, style, topic, references1_content, references2_content, references3_content, blog_title)
    
    # ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ
    blog_post_result, blog_post_token_usage = generate_blog_post(category, style, topic, references1_content, references2_content, references3_content, blog_title, outline_result)
    
    return references1_content, references2_content, references3_content, outline_result, outline_token_usage, blog_post_result, blog_post_token_usage

def get_title_prompt(category):
    if (category == "์ผ๋ฐ˜"):
        return """
# ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ ์ƒ์„ฑ ๊ทœ์น™(์ผ๋ฐ˜)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '์ •๋ณด์„ฑ(Informative)' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
4. ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค. 

##[๋ธ”๋กœ๊ทธ ์ œ๋ชฉ ์ž‘์„ฑ ๊ทœ์น™]
1. ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ 10๊ฐœ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์ œ๋ชฉ 10๊ฐœ๋งŒ ์ถœ๋ ฅํ•˜๋ผ.
2. ์ œ๋ชฉ์€ 40์ž ์ด๋‚ด๋กœ ์ž‘์„ฑํ•˜๋ผ.
3. ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€์— ๋งž์ถฐ ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ 10๊ฐœ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
4. ๋ฐ˜๋“œ์‹œ ํ•ต์‹ฌํ‚ค์›Œ๋“œ(Topic)๊ฐ€ ๋ฌธ์žฅ ์•ž์ชฝ์— ๋“ค์–ด๊ฐ€๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
5. ํ•ต์‹ฌ ํ‚ค์›Œ๋“œ์™€ ์—ฐ๊ด€์„ฑ ๋†’์€ ์ฃผ์ œ๋ฅผ ํฌํ•จํ•˜์—ฌ ์ž‘์„ฑํ•˜๋ผ.
"""
    elif (category == "๊ฑด๊ฐ•์ •๋ณด"):
        return """
# ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ ์ƒ์„ฑ ๊ทœ์น™(๊ฑด๊ฐ•์ •๋ณด)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '๊ฑด๊ฐ•, ์˜ํ•™ ์ •๋ณด' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํ„ฐ์ด๋‹ค.
4. ์ •ํ™•ํ•˜๊ณ  ์ „๋ฌธ์ ์ธ ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค.

##[๋ธ”๋กœ๊ทธ ์ œ๋ชฉ ์ž‘์„ฑ ๊ทœ์น™]
1. ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ 10๊ฐœ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์ œ๋ชฉ 10๊ฐœ๋งŒ ์ถœ๋ ฅํ•˜๋ผ.
2. ์ œ๋ชฉ์€ 40์ž ์ด๋‚ด๋กœ ์ž‘์„ฑํ•˜๋ผ.
3. ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€์— ๋งž์ถฐ ๋ธ”๋กœ๊ทธ ์ œ๋ชฉ 10๊ฐœ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
4. ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ํ•ต์‹ฌํ‚ค์›Œ๋“œ(Topic)๊ฐ€ ๋ฌธ์žฅ ์•ž์ชฝ์— ๋“ค์–ด๊ฐ€๋„๋ก ์ œ๋ชฉ์„ ์ž‘์„ฑํ•˜๋ผ.
5. ์ฐธ๊ณ ๊ธ€์„ ๋ถ„์„ํ•˜์—ฌ ๋…์ž๋“ค์ด ๊ฑด๊ฐ•ํ•œ ์ƒํ™œ์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ๋ฐ˜์˜ํ•˜๋ผ.
"""

def get_outline_prompt(category):
    if (category == "์ผ๋ฐ˜"):
        return """
# ๋ธ”๋กœ๊ทธ ์†Œ์ฃผ์ œ(Subtopic) ์ƒ์„ฑ ๊ทœ์น™(์ผ๋ฐ˜)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '์ •๋ณด์„ฑ(Informative)' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
4. ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค. 

##[์†Œ์ฃผ์ œ ์ž‘์„ฑ๊ทœ์น™]
1. [๊ธฐ๋ณธ๊ทœ์น™]์„ ๊ธฐ๋ณธ ์ ์šฉํ•˜๋ผ.
2. ๋ธ”๋กœ๊ทธ ๊ธ€์„ ์ž‘์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
3. ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€๊ณผ ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ์ œ๋ชฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ํ•ต์‹ฌ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•˜์—ฌ ์†Œ์ฃผ์ œ๋ฅผ ์ƒ์„ฑํ•˜๋ผ.
4. ์ „์ฒด ๋งฅ๋ฝ์— ๋งž๊ฒŒ ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
5. ์†Œ์ œ๋ชฉ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก 20์ž ๋‚ด์™ธ๋กœ ์ž‘์„ฑํ•˜๋ผ.
6. ๋…์ž๊ฐ€ ์–ป๊ณ ์ž ํ•˜๋Š” ์ •๋ณด์™€ ํฅ๋ฏธ๋กœ์šด ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋„๋ก ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
7. ์†Œ์ฃผ์ œ์˜ ๋ณธ๋ก ์˜ ๋‚ด์šฉ์ด ์ถฉ๋ถ„ํžˆ ์ž‘์„ฑ๋  ์ˆ˜ ์žˆ๋Š” ์†Œ์ฃผ์ œ๋กœ ์„ค์ •ํ•˜๋ผ. 
8. ๋ฐ˜๋“œ์‹œ [์†Œ์ฃผ์ œ ๊ตฌ์„ฑ]์— ๋งž๊ฒŒ ์ถœ๋ ฅํ•˜๋ผ.

##[์†Œ์ฃผ์ œ ๊ตฌ์„ฑ]
1. ๋ฐ˜๋“œ์‹œ [๋„์ž…๋ถ€] - 1๊ฐœ, [๋ณธ๋ก 1~5] - 5๊ฐœ, [๊ฒฐ๋ก ] - 1๊ฐœ๋กœ ๊ตฌ์„ฑํ•˜์—ฌ ์ถœ๋ ฅํ•˜๋ผ.
2. ๋ฐ˜๋“œ์‹œ [๋„์ž…๋ถ€]์™€ [๊ฒฐ๋ก ]์˜ ์ œ๋ชฉ์ด ์ค‘๋ณต๋˜์ง€ ์•Š๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
"""
    elif (category == "๊ฑด๊ฐ•์ •๋ณด"):
        return """
# ๋ธ”๋กœ๊ทธ ์†Œ์ฃผ์ œ(Subtopic) ์ƒ์„ฑ ๊ทœ์น™(๊ฑด๊ฐ•์ •๋ณด)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '๊ฑด๊ฐ•, ์˜ํ•™ ์ •๋ณด' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํ„ฐ์ด๋‹ค.
4. ์ •ํ™•ํ•˜๊ณ  ์ „๋ฌธ์ ์ธ ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค.

##[์†Œ์ฃผ์ œ ์ž‘์„ฑ๊ทœ์น™]
1. [๊ธฐ๋ณธ๊ทœ์น™]์„ ๊ธฐ๋ณธ ์ ์šฉํ•˜๋ผ.
2. ๋ธ”๋กœ๊ทธ ๊ธ€์„ ์ž‘์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
3. ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€๊ณผ ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ์ œ๋ชฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ํ•ต์‹ฌ ์ฃผ์ œ๋ฅผ ํŒŒ์•…ํ•˜์—ฌ ์†Œ์ฃผ์ œ๋ฅผ ์ƒ์„ฑํ•˜๋ผ.
4. ์ „์ฒด ๋งฅ๋ฝ์— ๋งž๊ฒŒ ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
5. ์†Œ์ œ๋ชฉ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก 20์ž ๋‚ด์™ธ๋กœ ์ž‘์„ฑํ•˜๋ผ.
6. ๋…์ž๊ฐ€ ์–ป๊ณ ์ž ํ•˜๋Š” ์ •ํ™•ํ•œ ์ •๋ณด์™€ ๊ฑด๊ฐ•ํ•œ ์ƒํ™œ์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋„๋ก ์†Œ์ฃผ์ œ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
7. ์†Œ์ฃผ์ œ์˜ ๋ณธ๋ก ์˜ ๋‚ด์šฉ์ด ์ถฉ๋ถ„ํžˆ ์ž‘์„ฑ๋  ์ˆ˜ ์žˆ๋Š” ์†Œ์ฃผ์ œ๋กœ ์„ค์ •ํ•˜๋ผ. 
8. ๋ฐ˜๋“œ์‹œ [์†Œ์ฃผ์ œ ๊ตฌ์„ฑ]์— ๋งž์ถฐ ์†Œ์ฃผ์ œ๋งŒ ์ถœ๋ ฅํ•˜๋ผ.

##[์†Œ์ฃผ์ œ ๊ตฌ์„ฑ]
1. ๋ฐ˜๋“œ์‹œ [๋„์ž…๋ถ€] - 1๊ฐœ, [๋ณธ๋ก 1~5] - 5๊ฐœ, [๊ฒฐ๋ก ] - 1๊ฐœ๋กœ ๊ตฌ์„ฑํ•˜์—ฌ ์ถœ๋ ฅํ•˜๋ผ.
2. ๋ฐ˜๋“œ์‹œ [๋„์ž…๋ถ€]์™€ [๊ฒฐ๋ก ]์˜ ์ œ๋ชฉ์ด ์ค‘๋ณต๋˜์ง€ ์•Š๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
"""

def get_blog_post_prompt(category):
    if (category == "์ผ๋ฐ˜"):
        return """
# ๋ธ”๋กœ๊ทธ ํ…์ŠคํŠธ ์ƒ์„ฑ ๊ทœ์น™(์ผ๋ฐ˜)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '์ •๋ณด์„ฑ(Informative)' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
4. ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค. 

##[ํ…์ŠคํŠธ ์ž‘์„ฑ ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅ๋œ [์†Œ์ฃผ์ œ]์— ๋งž๊ฒŒ ํ…์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
2. ์†Œ์ฃผ์ œ์˜ [๋ณธ๋ก ] 5๊ฐœ๋ฅผ ๊ฐ๊ฐ 300์ž ์ด์ƒ์œผ๋กœ ์ž‘์„ฑํ•˜๋ผ.
3. ์†Œ์ฃผ์ œ์˜ [๋ณธ๋ก ] ์ด 300์ž ์ด์ƒ ์ƒ์„ฑ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, ์ „์ฒด๊ธ€์ด 2000์ž ์ด์ƒ๋˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
4. ์ „์ฒด ๋งฅ๋ฝ์„ ์ดํ•ดํ•˜๊ณ  ๋ฌธ์žฅ์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๋ผ.
5. ์ฃผ์ œ์— ๋งž๋Š” ๋‹‰๋„ค์ž„, ํŽ˜๋ฅด์†Œ๋‚˜๋ฅผ ์ ์šฉํ•˜์—ฌ ์ž‘์„ฑํ•˜๋ผ.
6. ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€์˜ ์–ดํˆฌ๋ฅผ ๋ฐ˜์˜ํ•˜๋˜, [ํฌ์ŠคํŒ… ์Šคํƒ€์ผ]์— ๋งž๊ฒŒ ์ ์šฉํ•˜๋ผ.
7. ์ ˆ๋Œ€๋กœ ์ฐธ๊ณ ๊ธ€์„ ํ•œ๋ฌธ์žฅ ์ด์ƒ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜์ง€ ๋ง ๊ฒƒ.
8. ์ฃผ์ œ์™€ ์ƒํ™ฉ์— ๋งž๋Š” ์ ์ ˆํ•œ ์–ดํœ˜๋ฅผ ์„ ํƒํ•˜๋ผ. 
9. ํ•œ๊ธ€ ์–ดํœ˜์˜ ๋‚œ์ด๋„๋Š” ์‰ฝ๊ฒŒ ์ž‘์„ฑํ•˜๋ผ.
10. ์ ˆ๋Œ€ ๋ฌธ์žฅ์˜ ๋์— '๋‹ต๋‹ˆ๋‹ค'๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ง ๊ฒƒ.

	###[์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ์ž‘์„ฑ ๊ทœ์น™]
	1. ๋…์ž๊ฐ€ ์–ป๊ณ ์ž ํ•˜๋Š” ์œ ์šฉํ•œ ์ •๋ณด์™€ ํฅ๋ฏธ๋กœ์šด ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
	2. ๋…์ž์˜ ๊ณต๊ฐ์„ ์ด๋Œ์–ด๋‚ด๊ณ  ๊ถ๊ธˆ์ฆ์„ ํ•ด๊ฒฐํ•˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
	3. ๋…์ž์˜ ๊ด€์‹ฌ์‚ฌ๋ฅผ ์ถฉ์กฑ์‹œํ‚ค๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
	4. ๋…์ž์—๊ฒŒ ์ด๋“์ด ๋˜๋Š” ์ •๋ณด๋ฅผ ์ž‘์„ฑํ•˜๋ผ.

##[์ œ์™ธ ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ๋น„์†์–ด ๋ฐ ์š•์„ค(expletive, abusive language, slang)์€ ์ œ์™ธํ•˜๋ผ.
2. ๋ฐ˜๋“œ์‹œ ์ฐธ๊ณ ๊ธ€์˜ ๋งํฌ(URL)๋Š” ์ œ์™ธํ•˜๋ผ.
3. ์ฐธ๊ณ ๊ธ€์—์„œ '๋งํฌ๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”'์™€ ๊ฐ™์€ ๋งํฌ ์ด๋™์˜ ๋ฌธ๊ตฌ๋Š” ์ œ์™ธํ•˜๋ผ.
4. ์ฐธ๊ณ ๊ธ€์— ์žˆ๋Š” ์ž‘์„ฑ์ž, ํ™”์ž, ์œ ํŠœ๋ฒ„, ๊ธฐ์ž(Writer, speaker, YouTuber, reporter)์˜ ์ด๋ฆ„, ์• ์นญ, ๋‹‰๋„ค์ž„(Name, Nkickname)์€ ๋ฐ˜๋“œ์‹œ ์ œ์™ธํ•˜๋ผ.
5. ๋ฐ˜๋“œ์‹œ ๋ฌธ์žฅ์˜ ๋๋ถ€๋ถ„์ด ์–ด์ƒ‰ํ•œ ํ•œ๊ตญ์–ด ํ‘œํ˜„์€ ์ œ์™ธํ•˜๋ผ('์˜ˆ์š”', '๋‹ต๋‹ˆ๋‹ค', 'ํ•ด์š”', 'ํ•ด์ฃผ์ฃ ', '๋์ฃ ', '๋์–ด์š”', '๊ณ ์š”' ๋“ฑ.)
"""
    elif (category == "๊ฑด๊ฐ•์ •๋ณด"):
        return """
# ๋ธ”๋กœ๊ทธ ํ…์ŠคํŠธ ์ƒ์„ฑ ๊ทœ์น™(๊ฑด๊ฐ•์ •๋ณด)
##[๊ธฐ๋ณธ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ํ•œ๊ตญ์–ด(ํ•œ๊ธ€)๋กœ ์ž‘์„ฑํ•˜๋ผ.
2. ๋„ˆ๋Š” ๊ฐ€์žฅ ์ฃผ๋ชฉ๋ฐ›๋Š” ๋งˆ์ผ€ํ„ฐ์ด๋ฉฐ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํŒ… ์ „๋ฌธ๊ฐ€์ด๋‹ค.
3. ํŠนํžˆ ๋„ˆ๋Š” '๊ฑด๊ฐ•, ์˜ํ•™ ์ •๋ณด' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํ„ฐ์ด๋‹ค.
4. ์ •ํ™•ํ•˜๊ณ  ์ „๋ฌธ์ ์ธ ์ •๋ณด ์ œ๊ณต์— ์ดˆ์ ์„ ๋งž์ถ”์–ด ์ž‘์„ฑํ•œ๋‹ค.

##[ํ…์ŠคํŠธ ์ž‘์„ฑ ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅ๋œ [์†Œ์ฃผ์ œ]์— ๋งž์ถฐ์„œ ํ…์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•˜๋ผ.
2. ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅ๋œ [์†Œ์ฃผ์ œ]๋Š” ๋ณ€๊ฒฝํ•˜์ง€ ๋ง๊ณ  ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๋ผ.
3. ์†Œ์ฃผ์ œ์˜ [๋„์ž…๋ถ€]๋Š” ๊ฐ€๋ณ๊ฒŒ ์ž‘์„ฑํ•˜๋˜ ๊ณต๊ฐ๊ณผ ํฅ๋ฏธ, ๋ฌธ์ œ์ œ๊ธฐ, ๊ธ€์˜ ๋ชฉ์ , ๋ณธ๋ฌธ์œผ๋กœ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ด์–ด์ง€๋Š” ์ „ํ™˜๋ฌธ์žฅ๋“ฑ์„ ์ถœ๋ ฅํ•˜๋ผ.
3. ์†Œ์ฃผ์ œ์˜ [๋ณธ๋ก ] 5๊ฐœ์˜ ๋‚ด์šฉ์ด ๊ฐ๊ฐ 500์ž ์ด์ƒ์ด ๋˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
4. ๋ฐ˜๋“œ์‹œ ๋„ˆ๊ฐ€ ์ž‘์„ฑํ•œ ์ „์ฒด๊ธ€์ด 2500์ž ์ด์ƒ์ด ๋˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
5. ์ „์ฒด ๋งฅ๋ฝ์„ ์ดํ•ดํ•˜๊ณ  ๋ฌธ์žฅ์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๋ผ.
6. ์ฐธ๊ณ ๊ธ€์„ ๋ฐ”ํƒ•์œผ๋กœ ์ž‘์„ฑํ•œ ๊ธ€์— ๋งž๋Š” ๋‹‰๋„ค์ž„, ํŽ˜๋ฅด์†Œ๋‚˜๋ฅผ ์ ์šฉํ•˜์—ฌ ์ž‘์„ฑํ•˜๋ผ.
7. ์–ดํˆฌ๋Š” ์ œ๊ณต๋œ ์ฐธ๊ณ ๊ธ€์˜ ์–ดํˆฌ๋ฅผ ๋ฐ˜์˜ํ•˜๋˜, '๊ฑด๊ฐ•, ์˜ํ•™ ์ •๋ณด' ์ „๋ฌธ ๋ธ”๋กœ๊ทธ ๋งˆ์ผ€ํ„ฐ๋กœ์„œ ์ž‘์„ฑํ•˜๋ผ.
8. ์ ˆ๋Œ€๋กœ ์ฐธ๊ณ ๊ธ€์„ ํ•œ๋ฌธ์žฅ ์ด์ƒ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜์ง€ ๋ง ๊ฒƒ.
9. ์ฃผ์ œ์™€ ์ƒํ™ฉ์— ๋งž๋Š” ์ ์ ˆํ•œ ์–ดํœ˜๋ฅผ ์„ ํƒํ•˜๋ผ. 

	###[์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ์ž‘์„ฑ ๊ทœ์น™]
	1. ๋…์ž๊ฐ€ ์–ป๊ณ ์ž ํ•˜๋Š” ์ •ํ™•ํ•œ ์ •๋ณด์™€ ๊ฑด๊ฐ•ํ•œ ์ƒํ™œ์„ ์œ ์ง€ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋„๋ก ์†Œ์ฃผ์ œ์— ๋งž๊ฒŒ ๋‚ด์šฉ์„ ์ž‘์„ฑํ•˜๋ผ.
	2. ๋…์ž์˜ ๊ณต๊ฐ์„ ์ด๋Œ์–ด๋‚ด๊ณ  ๊ถ๊ธˆ์ฆ์„ ํ•ด๊ฒฐํ•˜๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
	3. ๋…์ž์˜ ๊ด€์‹ฌ์‚ฌ๋ฅผ ์ถฉ์กฑ์‹œํ‚ค๋„๋ก ์ž‘์„ฑํ•˜๋ผ.
	4. ๋…์ž์—๊ฒŒ ์ด๋“์ด ๋˜๋Š” ์ •๋ณด๋ฅผ ์ž‘์„ฑํ•˜๋ผ.

##[์ œ์™ธ ๊ทœ์น™]
1. ๋ฐ˜๋“œ์‹œ ์ฐธ๊ณ ๊ธ€์˜ ๋งํฌ(URL)๋Š” ์ œ์™ธํ•˜๋ผ.
2. ์ฐธ๊ณ ๊ธ€์—์„œ '๋งํฌ๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”'์™€ ๊ฐ™์€ ๋งํฌ ์ด๋™์˜ ๋ฌธ๊ตฌ๋Š” ์ œ์™ธํ•˜๋ผ.
3. ์ฐธ๊ณ ๊ธ€์— ์žˆ๋Š” ์ž‘์„ฑ์ž, ํ™”์ž, ์œ ํŠœ๋ฒ„, ๊ธฐ์ž(Writer, speaker, YouTuber, reporter)์˜ ์ด๋ฆ„, ์• ์นญ, ๋‹‰๋„ค์ž„(Name, Nkickname)์€ ๋ฐ˜๋“œ์‹œ ์ œ์™ธํ•˜๋ผ.
"""

def get_style_prompt(style):
    prompts = {
        "์นœ๊ทผํ•œ": """
#์นœ๊ทผํ•œ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ… ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ
1. ํ†ค๊ณผ ์–ด์กฐ
   - ๋Œ€ํ™”ํ•˜๋“ฏ ํŽธ์•ˆํ•˜๊ณ  ์นœ๊ทผํ•œ ๋งํˆฌ ์‚ฌ์šฉ
   - ๋…์ž๋ฅผ "์—ฌ๋Ÿฌ๋ถ„" ๋˜๋Š” "๋…์ž๋‹˜๋“ค"๋กœ ์ง€์นญ
   - ์ ์ ˆํ•œ ์ด๋ชจ์ง€๋ฅผ sparseํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜์—ฌ ์นœ๊ทผ๊ฐ ํ‘œํ˜„
2. ๋ฌธ์žฅ ๋ฐ ๋‚ด์šฉ ๊ตฌ์„ฑ
   - ์งง๊ณ  ๊ฐ„๊ฒฐํ•œ ๋ฌธ์žฅ ์œ„์ฃผ๋กœ ์ž‘์„ฑ
   - ๊ตฌ์–ด์ฒด ํ‘œํ˜„ ์‚ฌ์šฉ (์˜ˆ: "~ํ–ˆ์–ด์š”", "~์ธ ๊ฒƒ ๊ฐ™์•„์š”")
   - '~๋‹ˆ๋‹ค', '~ํ–ˆ์ฃ '๋Š” ์‚ฌ์šฉํ•˜์ง€ ๋ง ๊ฒƒ.
   - ๊ฐœ์ธ์ ์ธ ๊ฒฝํ—˜์ด๋‚˜ ์ผํ™”๋กœ ์‹œ์ž‘
   - ์‹ค์ƒํ™œ์—์„œ ์‰ฝ๊ฒŒ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํŒ ์ œ๊ณต
   - ๋…์ž์˜ ๊ณต๊ฐ์„ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์‚ฌ๋ก€ ํฌํ•จ
3. ์šฉ์–ด ๋ฐ ์„ค๋ช… ๋ฐฉ์‹
   - ์ „๋ฌธ ์šฉ์–ด ๋Œ€์‹  ์‰ฌ์šด ๋‹จ์–ด๋กœ ํ’€์–ด์„œ ์„ค๋ช…
   - ๋น„์œ ๋‚˜ ์€์œ ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋ณต์žกํ•œ ๊ฐœ๋… ์„ค๋ช…
   - ์ˆ˜์‚ฌ์˜๋ฌธ๋ฌธ ํ™œ์šฉํ•˜์—ฌ ๋…์ž์™€ ์†Œํ†ตํ•˜๋Š” ๋А๋‚Œ ์ฃผ๊ธฐ
4. ๋…์ž์™€์˜ ์ƒํ˜ธ์ž‘์šฉ
   - ๋…์ž์˜ ์˜๊ฒฌ์„ ๋ฌผ์–ด๋ณด๋Š” ์งˆ๋ฌธ ํฌํ•จ
   - ๋Œ“๊ธ€ ๋‹ฌ๊ธฐ๋ฅผ ๋…๋ คํ•˜๋Š” ๋ฌธ๊ตฌ ์‚ฌ์šฉ
5. ์ด๋ชจ์ง€ ํ™œ์šฉ
   - ์ฃผ์š” ํฌ์ธํŠธ๋‚˜ ์ƒˆ๋กœ์šด ์„น์…˜์„ ์‹œ์ž‘ํ•  ๋•Œ๋งŒ ๊ด€๋ จ ์ด๋ชจ์ง€ ์‚ฌ์šฉ
   - ์ „์ฒด ๊ธ€์—์„œ 3-5๊ฐœ ์ •๋„์˜ ์ด๋ชจ์ง€๋งŒ ์‚ฌ์šฉํ•˜์—ฌ ๊ณผ๋„ํ•˜์ง€ ์•Š๊ฒŒ ์œ ์ง€
6. ๋งˆ๋ฌด๋ฆฌ
   - ์นœ๊ทผํ•˜๊ณ  ๊ฒฉ๋ คํ•˜๋Š” ํ†ค์œผ๋กœ ๋งˆ๋ฌด๋ฆฌ
   - ๋‹ค์Œ ํฌ์ŠคํŒ…์— ๋Œ€ํ•œ ๊ธฐ๋Œ€๊ฐ ์œ ๋ฐœ
์ฃผ์˜์‚ฌํ•ญ: ๋„ˆ๋ฌด ๊ฐ€๋ฒผ์šด ํ†ค์€ ์ง€์–‘ํ•˜๊ณ , ์ฃผ์ œ์˜ ์ค‘์š”์„ฑ์„ ํ•ด์น˜์ง€ ์•Š๋Š” ์„ ์—์„œ ์นœ๊ทผํ•จ ์œ ์ง€
์˜ˆ์‹œ: "์—ฌ๋Ÿฌ๋ถ„, ์˜ค๋Š˜ ํ•˜๋ฃจ๋Š” ์–ด๋– ์…จ๋‚˜์š”? ๐Ÿ˜Š ์ €๋Š” ์˜ค๋Š˜ ์žฌ๋ฏธ์žˆ๋Š” ๊ฒฝํ—˜์„ ํ–ˆ์–ด์š”. ๋ฐ”๋กœ '๋ฏธ๋‹ˆ๋ฉ€ ๋ผ์ดํ”„'์— ๋„์ „ํ•ด๋ณธ ๊ฑด๋ฐ์š”. ์ฒ˜์Œ์—๋Š” ์ข€ ๋ง‰๋ง‰ํ–ˆ์ง€๋งŒ, ์ƒ๊ฐ๋ณด๋‹ค ์ฆ๊ฑฐ์šด ๊ฒฝํ—˜์ด์—ˆ์–ด์š”! ์—ฌ๋Ÿฌ๋ถ„๋„ ํ•œ๋ฒˆ ๋”ฐ๋ผํ•ด๋ณด์‹œ๊ฒ ์–ด์š”? ์ œ๊ฐ€ ์•Œ๊ฒŒ ๋œ ๊ฟ€ํŒ๋“ค์„ ํ•˜๋‚˜ํ•˜๋‚˜ ์•Œ๋ ค๋“œ๋ฆด๊ฒŒ์š”. 
""",
        "์ผ๋ฐ˜": """
#์ผ๋ฐ˜์ ์ธ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ… ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ
1. ํ†ค๊ณผ ์–ด์กฐ
   - ์ค‘๋ฆฝ์ ์ด๊ณ  ๊ฐ๊ด€์ ์ธ ํ†ค ์œ ์ง€
   - ์ ์ ˆํ•œ ์กด๋Œ“๋ง ์‚ฌ์šฉ (์˜ˆ: "~ํ•ฉ๋‹ˆ๋‹ค", "~์ž…๋‹ˆ๋‹ค")
2. ๋‚ด์šฉ ๊ตฌ์กฐ ๋ฐ ์ „๊ฐœ
   - ๋ช…ํ™•ํ•œ ์ฃผ์ œ ์ œ์‹œ๋กœ ์‹œ์ž‘
   - ๋…ผ๋ฆฌ์ ์ธ ์ˆœ์„œ๋กœ ์ •๋ณด ์ „๊ฐœ
   - ์ฃผ์š” ํฌ์ธํŠธ๋ฅผ ๊ฐ•์กฐํ•˜๋Š” ์†Œ์ œ๋ชฉ ํ™œ์šฉ
   - ์ ์ ˆํ•œ ๊ธธ์ด์˜ ๋‹จ๋ฝ์œผ๋กœ ๊ตฌ์„ฑ
3. ์šฉ์–ด ๋ฐ ์„ค๋ช… ๋ฐฉ์‹
   - ์ผ๋ฐ˜์ ์œผ๋กœ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์šฉ์–ด ์„ ํƒ
   - ํ•„์š”์‹œ ๊ฐ„๋‹จํ•œ ์„ค๋ช… ์ถ”๊ฐ€
   - ๊ฐ๊ด€์ ์ธ ์ •๋ณด ์ œ๊ณต์— ์ค‘์ 
4. ํ…์ŠคํŠธ ๊ตฌ์กฐํ™”
   - ๋ถˆ๋ฆฟ ํฌ์ธํŠธ๋‚˜ ๋ฒˆํ˜ธ ๋งค๊ธฐ๊ธฐ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์ •๋ณด ๊ตฌ์กฐํ™”
   - ์ค‘์š”ํ•œ ์ •๋ณด๋Š” ๊ตต์€ ๊ธ€์”จ๋‚˜ ๊ธฐ์šธ์ž„๊ผด๋กœ ๊ฐ•์กฐ
5. ๋…์ž ์ƒํ˜ธ์ž‘์šฉ
   - ์ ์ ˆํžˆ ๋…์ž์˜ ์ƒ๊ฐ์„ ๋ฌป๋Š” ์งˆ๋ฌธ ํฌํ•จ
   - ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ๋Š” ํ‚ค์›Œ๋“œ ์ œ์‹œ
6. ๋งˆ๋ฌด๋ฆฌ
   - ์ฃผ์š” ๋‚ด์šฉ ๊ฐ„๋‹จํžˆ ์š”์•ฝ
   - ์ถ”๊ฐ€ ์ •๋ณด์— ๋Œ€ํ•œ ์•ˆ๋‚ด ์ œ๊ณต
์ฃผ์˜์‚ฌํ•ญ: ๋„ˆ๋ฌด ๋”ฑ๋”ฑํ•˜๊ฑฐ๋‚˜ ์ง€๋ฃจํ•˜์ง€ ์•Š๋„๋ก ๊ท ํ˜• ์œ ์ง€
์˜ˆ์‹œ: "์ตœ๊ทผ ํ™˜๊ฒฝ ๋ฌธ์ œ๊ฐ€ ๋Œ€๋‘๋˜๋ฉด์„œ '์ œ๋กœ ์›จ์ด์ŠคํŠธ' ๋ผ์ดํ”„์Šคํƒ€์ผ์— ๋Œ€ํ•œ ๊ด€์‹ฌ์ด ๋†’์•„์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๋กœ ์›จ์ด์ŠคํŠธ๋ž€ ์ผ์ƒ์ƒํ™œ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์“ฐ๋ ˆ๊ธฐ๋ฅผ ์ตœ์†Œํ™”ํ•˜๋Š” ์ƒํ™œ ๋ฐฉ์‹์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ธ€์—์„œ๋Š” ์ œ๋กœ ์›จ์ด์ŠคํŠธ์˜ ๊ฐœ๋…, ์‹ค์ฒœ ๋ฐฉ๋ฒ•, ๊ทธ๋ฆฌ๊ณ  ๊ทธ ํšจ๊ณผ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋จผ์ € ์ œ๋กœ ์›จ์ด์ŠคํŠธ์˜ ์ •์˜๋ถ€ํ„ฐ ์‚ดํŽด๋ณด๋ฉด...
""",
        "์ „๋ฌธ์ ์ธ": """
#์ „๋ฌธ์ ์ธ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ… ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ
1. ํ†ค๊ณผ ๊ตฌ์กฐ
   - ๊ณต์‹์ ์ด๊ณ  ํ•™์ˆ ์ ์ธ ํ†ค ์‚ฌ์šฉ
   - ๊ฐ๊ด€์ ์ด๊ณ  ๋ถ„์„์ ์ธ ์ ‘๊ทผ ์œ ์ง€
   - ๋ช…ํ™•ํ•œ ์„œ๋ก , ๋ณธ๋ก , ๊ฒฐ๋ก  ๊ตฌ์กฐ
   - ์ฒด๊ณ„์ ์ธ ๋…ผ์  ์ „๊ฐœ
   - ์„ธ๋ถ€ ์„น์…˜์„ ์œ„ํ•œ ๋ช…ํ™•ํ•œ ์†Œ์ œ๋ชฉ ์‚ฌ์šฉ
2. ๋‚ด์šฉ ๊ตฌ์„ฑ ๋ฐ ์ „๊ฐœ
   - ๋ณต์žกํ•œ ๊ฐœ๋…์„ ์ •ํ™•ํžˆ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ์žฅ ๊ตฌ์กฐ ์‚ฌ์šฉ
   - ๋…ผ๋ฆฌ์  ์—ฐ๊ฒฐ์„ ์œ„ํ•œ ์ „ํ™˜์–ด ํ™œ์šฉ
   - ํ•ด๋‹น ๋ถ„์•ผ์˜ ์ „๋ฌธ ์šฉ์–ด ์ ๊ทน ํ™œ์šฉ (ํ•„์š”์‹œ ๊ฐ„๋žตํ•œ ์„ค๋ช… ์ œ๊ณต)
   - ์‹ฌ์ธต์ ์ธ ๋ถ„์„๊ณผ ๋น„ํŒ์  ์‚ฌ๊ณ  ์ „๊ฐœ
   - ๋‹ค์–‘ํ•œ ๊ด€์  ์ œ์‹œ ๋ฐ ๋น„๊ต
3. ๋ฐ์ดํ„ฐ ๋ฐ ๊ทผ๊ฑฐ ํ™œ์šฉ
   - ํ†ต๊ณ„, ์—ฐ๊ตฌ ๊ฒฐ๊ณผ, ์ „๋ฌธ๊ฐ€ ์˜๊ฒฌ ๋“ฑ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ถœ์ฒ˜ ์ธ์šฉ
   - ํ•„์š”์‹œ ๊ฐ์ฃผ๋‚˜ ์ฐธ๊ณ ๋ฌธํ—Œ ๋ชฉ๋ก ํฌํ•จ
   - ์ˆ˜์น˜ ๋ฐ์ดํ„ฐ๋Š” ํ…์ŠคํŠธ๋กœ ๋ช…ํ™•ํžˆ ์„ค๋ช…
4. ํ…์ŠคํŠธ ๊ตฌ์กฐํ™”
   - ๋…ผ๋ฆฌ์  ๊ตฌ์กฐ๋ฅผ ๊ฐ•์กฐํ•˜๊ธฐ ์œ„ํ•ด ๋ฒˆํ˜ธ ๋งค๊ธฐ๊ธฐ ์‚ฌ์šฉ
   - ํ•ต์‹ฌ ๊ฐœ๋…์ด๋‚˜ ์šฉ์–ด๋Š” ๊ธฐ์šธ์ž„๊ผด๋กœ ๊ฐ•์กฐ
   - ๊ธด ์ธ์šฉ๋ฌธ์€ ๋“ค์—ฌ์“ฐ๊ธฐ๋กœ ๊ตฌ๋ถ„
5. ๋งˆ๋ฌด๋ฆฌ
   - ํ•ต์‹ฌ ๋…ผ์  ์žฌ๊ฐ•์กฐ
   - ํ–ฅํ›„ ์—ฐ๊ตฌ ๋ฐฉํ–ฅ์ด๋‚˜ ์‹ค๋ฌด์  ํ•จ์˜ ์ œ์‹œ
์ฃผ์˜์‚ฌํ•ญ: ์ „๋ฌธ์„ฑ์„ ์œ ์ง€ํ•˜๋˜, ์™„์ „ํžˆ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์šด ์ˆ˜์ค€์€ ์ง€์–‘
์˜ˆ์‹œ: "๋ณธ ์—ฐ๊ตฌ์—์„œ๋Š” ์ธ๊ณต์ง€๋Šฅ(AI)์˜ ์œค๋ฆฌ์  ํ•จ์˜์— ๋Œ€ํ•ด ๊ณ ์ฐฐํ•œ๋‹ค. ํŠนํžˆ, ์ž์œจ์ฃผํ–‰ ์ž๋™์ฐจ์˜ ์˜์‚ฌ๊ฒฐ์ • ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์œค๋ฆฌ์  ๋”œ๋ ˆ๋งˆ์— ์ดˆ์ ์„ ๋งž์ถ˜๋‹ค. Bonnefon et al. (2016)์˜ ์—ฐ๊ตฌ์— ๋”ฐ๋ฅด๋ฉด, ์ž์œจ์ฃผํ–‰ ์ฐจ๋Ÿ‰์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ง๋ฉดํ•  ์ˆ˜ ์žˆ๋Š” ์œค๋ฆฌ์  ์„ ํƒ์˜ ๋ณต์žก์„ฑ์ด ์ง€์ ๋œ ๋ฐ” ์žˆ๋‹ค. ๋ณธ๊ณ ์—์„œ๋Š” ์ด๋Ÿฌํ•œ ์œค๋ฆฌ์  ๋”œ๋ ˆ๋งˆ๋ฅผ ์„ธ ๊ฐ€์ง€ ์ฃผ์š” ๊ด€์ ์—์„œ ๋ถ„์„ํ•œ๋‹ค: 1) ๊ณต๋ฆฌ์ฃผ์˜์  ์ ‘๊ทผ, 2) ์˜๋ฌด๋ก ์  ์ ‘๊ทผ, 3) ๋• ์œค๋ฆฌ์  ์ ‘๊ทผ. ๊ฐ ์ ‘๊ทผ๋ฒ•์˜ ์žฅ๋‹จ์ ์„ ๋น„๊ต ๋ถ„์„ํ•˜๊ณ , ์ด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ž์œจ์ฃผํ–‰ ์ฐจ๋Ÿ‰์˜ ์œค๋ฆฌ์  ์˜์‚ฌ๊ฒฐ์ • ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์ œ์•ˆํ•˜๊ณ ์ž ํ•œ๋‹ค...
"""
    }
    return prompts.get(style, "ํฌ์ŠคํŒ… ์Šคํƒ€์ผ ํ”„๋กฌํ”„ํŠธ")

def get_style_description(style):
    descriptions = {
        "์นœ๊ทผํ•œ": "๋…์ž์™€ ๊ฐ€๊นŒ์šด ์นœ๊ตฌ์ฒ˜๋Ÿผ ๋Œ€ํ™”ํ•˜๋Š” ๋“ฏํ•œ ์นœ๊ทผํ•œ ์Šคํƒ€์ผ์ž…๋‹ˆ๋‹ค.",
        "์ผ๋ฐ˜": "์ผ๋ฐ˜์ ์ด๊ณ  ์ค‘๋ฆฝ์ ์ธ ํ†ค์œผ๋กœ ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜๋Š” ์Šคํƒ€์ผ์ž…๋‹ˆ๋‹ค.",
        "์ „๋ฌธ์ ์ธ": "์ „๋ฌธ๊ฐ€์˜ ์‹œ๊ฐ์—์„œ ๊นŠ์ด ์žˆ๋Š” ์ •๋ณด๋ฅผ ์ „๋‹ฌํ•˜๋Š” ์Šคํƒ€์ผ์ž…๋‹ˆ๋‹ค."
    }
    return descriptions.get(style, "ํฌ์ŠคํŒ… ์Šคํƒ€์ผ์„ ์„ ํƒํ•˜์„ธ์š”.")

def update_prompts_and_description(category, style):
    title_prompt = get_title_prompt(category)
    outline_prompt = get_outline_prompt(category)
    blog_post_prompt = get_blog_post_prompt(category)
    style_prompt = get_style_prompt(style)
    style_description = get_style_description(style)
    return style_description


#PDFํŒŒ์ผ ๋งŒ๋“ค
class PDF(FPDF):
    def __init__(self):
        super().__init__()
        current_dir = os.path.dirname(__file__)
        self.add_font("NanumGothic", "", os.path.join(current_dir, "NanumGothic.ttf"), uni=True)
        self.add_font("NanumGothic", "B", os.path.join(current_dir, "NanumGothicBold.ttf"), uni=True)
        self.add_font("NanumGothicExtraBold", "", os.path.join(current_dir, "NanumGothicExtraBold.ttf"), uni=True)
        self.add_font("NanumGothicLight", "", os.path.join(current_dir, "NanumGothicLight.ttf"), uni=True)

    def header(self):
        self.set_font('NanumGothic', '', 10)

    def footer(self):
        self.set_y(-15)
        self.set_font('NanumGothic', '', 8)
        self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')

def save_to_pdf(blog_post):
    pdf = PDF()
    pdf.add_page()
    
    lines = blog_post.split('\n')
    title = lines[0].strip()
    content = '\n'.join(lines[1:]).strip()
    
    filename = format_filename(title) + ".pdf"
    
    pdf.set_font("NanumGothic", 'B', size=14)
    pdf.cell(0, 10, title, ln=True, align='C')
    pdf.ln(10)
    
    pdf.set_font("NanumGothic", '', size=11)
    pdf.multi_cell(0, 5, content)

    print(f"Saving PDF as: {filename}")
    pdf.output(filename)
    return filename

def format_filename(text):
    text = re.sub(r'[^\w\s-]', '', text)
    return text[:50].strip()

# save_content_to_pdf ํ•จ์ˆ˜๋„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ˆ˜์ •
def save_content_to_pdf(blog_post):
    return save_to_pdf(blog_post)

title = "์ •๋ณด์„ฑ ํฌ์ŠคํŒ… ์ž๋™์ƒ์„ฑ๊ธฐ(์ œ๋ชฉ์ถ”์ฒœ ํ›„ ์ž๋™)"

def update_prompts_and_description(category, style):
    title_prompt = get_title_prompt(category)
    outline_prompt = get_outline_prompt(category)
    blog_post_prompt = get_blog_post_prompt(category)
    style_prompt = get_style_prompt(style)
    style_description = get_style_description(style)
    return style_description

with gr.Blocks() as demo:
    gr.Markdown(f"# {title}")
    
    gr.Markdown("### 1๋‹จ๊ณ„ : ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ์ง€์ •ํ•ด์ฃผ์„ธ์š”")
    category = gr.Radio(choices=["์ผ๋ฐ˜", "๊ฑด๊ฐ•์ •๋ณด"], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="์ผ๋ฐ˜")
    
    gr.Markdown("---\n\n")

    gr.Markdown("### 2๋‹จ๊ณ„: ํฌ์ŠคํŒ… ์Šคํƒ€์ผ์„ ์„ ํƒํ•ด์ฃผ์„ธ์š”", elem_id="step-title")
    style = gr.Radio(choices=["์นœ๊ทผํ•œ", "์ผ๋ฐ˜", "์ „๋ฌธ์ ์ธ"], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
    style_description = gr.Markdown(f"_{get_style_description('์นœ๊ทผํ•œ')}_", elem_id="style-description")
    
    gr.Markdown("---\n\n")

    # 2๋‹จ๊ณ„
    gr.Markdown("### 3๋‹จ๊ณ„ : ๋ธ”๋กœ๊ทธ ์ฃผ์ œ, ๋˜๋Š” ํ‚ค์›Œ๋“œ๋ฅผ ์ƒ์„ธํžˆ ์ž…๋ ฅํ•˜์„ธ์š”")
    topic = gr.Textbox(label="๋ธ”๋กœ๊ทธ ์ฃผ์ œ(์˜ˆ์‹œ: ์˜ค์ง•์–ด ๋ฌด์นจํšŒ(X), ์˜ค์ง•์–ด ๋ฌด์นจํšŒ ๋ ˆ์‹œํ”ผ(O))", placeholder="์˜ˆ์‹œ: ์—ฌํ–‰์ง€ ์ถ”์ฒœ(X), 8์›” ๊ตญ๋‚ด ์—ฌํ–‰์ง€ ์ถ”์ฒœ(O)")

    # 3๋‹จ๊ณ„: ์ฐธ๊ณ  ๊ธ€์„ ์œ„ํ•œ ๋ณ€์ˆ˜๋“ค ๋ฏธ๋ฆฌ ์ •์˜
    references1 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ…๊ธ€์„ ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ๋„ฃ์œผ์„ธ์š”", lines=10, visible=False)
    references2 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ…๊ธ€์„ ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ๋„ฃ์œผ์„ธ์š”", lines=10, visible=False)
    references3 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ…๊ธ€์„ ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ๋„ฃ์œผ์„ธ์š”", lines=10, visible=False)

    # ์ œ๋ชฉ ์ถ”์ฒœ
    gr.Markdown("### 4๋‹จ๊ณ„ : ์ œ๋ชฉ ์ถ”์ฒœํ•˜๊ธฐ")

    title_suggestions = gr.Textbox(label="์ œ๋ชฉ ์ถ”์ฒœ", lines=10)
    title_token_output = gr.Markdown(label="์‚ฌ์šฉ๋œ ํ† ํฐ ์ˆ˜")

    # ์ œ๋ชฉ ์ถ”์ฒœ ๋ฒ„ํŠผ
    title_btn = gr.Button("์ œ๋ชฉ ์ถ”์ฒœํ•˜๊ธฐ")
    title_btn.click(fn=suggest_title, inputs=[category, style, topic, references1, references2, references3], outputs=[title_suggestions, title_token_output])
    
    blog_title = gr.Textbox(label="๋ธ”๋กœ๊ทธ ์ œ๋ชฉ", placeholder="๋ธ”๋กœ๊ทธ ์ œ๋ชฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
    
    # ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ
    gr.Markdown("### 5๋‹จ๊ณ„ : ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑํ•˜๊ธฐ")
    gr.HTML("<span style='color: grey;'>[๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑํ•˜๊ธฐ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ฐ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ž‘์„ฑ์ด ์ž๋™์œผ๋กœ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค.]</span>")

    outline_result = gr.Textbox(label="์•„์›ƒ๋ผ์ธ ๊ฒฐ๊ณผ", lines=15, visible=False)
    outline_token_output = gr.Markdown(label="์‚ฌ์šฉ๋œ ํ† ํฐ ์ˆ˜", visible=False)
    output = gr.Textbox(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€", lines=30)
    token_output = gr.Markdown(label="์‚ฌ์šฉ๋œ ํ† ํฐ ์ˆ˜")

    # ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ฒ„ํŠผ
    generate_post_btn = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑํ•˜๊ธฐ")
    generate_post_btn.click(
        fn=fetch_references_and_generate_all_steps,
        inputs=[category, style, topic, blog_title],
        outputs=[references1, references2, references3, outline_result, outline_token_output, output, token_output]
    )

    save_pdf_btn = gr.Button("PDF๋กœ ์ €์žฅํ•˜๊ธฐ")
    pdf_output = gr.File(label="์ƒ์„ฑ๋œ PDF ํŒŒ์ผ")

    save_pdf_btn.click(fn=save_content_to_pdf, inputs=[output], outputs=[pdf_output])

    category.change(fn=update_prompts_and_description, inputs=[category, style], outputs=[style_description])
    style.change(fn=update_prompts_and_description, inputs=[category, style], outputs=[style_description])    

demo.launch()