Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,457 @@
|
|
1 |
-
import
|
|
|
2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
openai.api_key = api_key
|
9 |
-
else:
|
10 |
-
raise ValueError("OPENAI_API_KEY ํ๊ฒฝ ๋ณ์๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
import os
|
4 |
+
import re
|
5 |
+
import openai
|
6 |
+
from fpdf import FPDF
|
7 |
+
from datetime import datetime
|
8 |
+
from zoneinfo import ZoneInfo
|
9 |
+
from sklearn.feature_extraction.text import CountVectorizer
|
10 |
+
|
11 |
+
# OpenAI API ํด๋ผ์ด์ธํธ ์ค์
|
12 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
13 |
+
|
14 |
+
def call_api(content, system_message, max_tokens, temperature, top_p):
|
15 |
+
try:
|
16 |
+
messages = [
|
17 |
+
{"role": "system", "content": system_message},
|
18 |
+
{"role": "user", "content": content}
|
19 |
+
]
|
20 |
+
|
21 |
+
response = openai.ChatCompletion.create(
|
22 |
+
model="gpt-4o-mini",
|
23 |
+
messages=messages,
|
24 |
+
max_tokens=max_tokens,
|
25 |
+
temperature=temperature,
|
26 |
+
top_p=top_p,
|
27 |
+
request_timeout=50
|
28 |
+
)
|
29 |
+
|
30 |
+
return response.choices[0].message['content']
|
31 |
+
except Exception as e:
|
32 |
+
print(f"API ํธ์ถ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
33 |
+
raise
|
34 |
+
|
35 |
+
def analyze_info(data):
|
36 |
+
return f"์ ํํ ์นดํ
๊ณ ๋ฆฌ: {data['category']}\n์ ํํ ํฌ์คํ
์คํ์ผ: {data['style']}\n์ฐธ๊ณ ๊ธ1: {data['references1']}\n์ฐธ๊ณ ๊ธ2: {data['references2']}\n์ฐธ๊ณ ๊ธ3: {data['references3']}"
|
37 |
+
|
38 |
+
def generate_outline(category, style, references1, references2, references3):
|
39 |
+
data = {
|
40 |
+
'category': category,
|
41 |
+
'style': style,
|
42 |
+
'references1': references1,
|
43 |
+
'references2': references2,
|
44 |
+
'references3': references3
|
45 |
+
}
|
46 |
+
full_content = analyze_info(data)
|
47 |
+
system_prompt = get_outline_prompt(data['category']) + "\n\n" + get_style_prompt(data['style'])
|
48 |
+
modified_text = call_api(full_content, system_prompt, 2000, 0.7, 0.95)
|
49 |
+
|
50 |
+
# ํต์ฌ๊ธฐ๋ฅ์ ๋ถ๋ฆฌํ์ฌ ๋ฆฌ์คํธ๋ก ๋ฐํ
|
51 |
+
features = re.findall(r'ํต์ฌ๊ธฐ๋ฅ : (.+)', modified_text)
|
52 |
+
return features[:3] # ์ต๋ 3๊ฐ์ ํต์ฌ๊ธฐ๋ฅ๋ง ๋ฐํ
|
53 |
+
def remove_unwanted_phrases(text):
|
54 |
+
unwanted_phrases = [
|
55 |
+
'์ฌ๋ฌ๋ถ', '์ต๊ทผ', '๋ง์ง๋ง์ผ๋ก', '๊ฒฐ๋ก ์ ์ผ๋ก', '๊ฒฐ๊ตญ',
|
56 |
+
'์ข
ํฉ์ ์ผ๋ก', '๋ฐ๋ผ์', '๋ง๋ฌด๋ฆฌ', '์์ฝ'
|
57 |
+
]
|
58 |
+
words = re.findall(r'\S+|\n', text)
|
59 |
+
result_words = [word for word in words if not any(phrase in word for phrase in unwanted_phrases)]
|
60 |
+
return ' '.join(result_words).replace(' \n ', '\n').replace(' \n', '\n').replace('\n ', '\n')
|
61 |
+
|
62 |
+
def generate_blog_post(category, style, references1, references2, references3, outline):
|
63 |
+
try:
|
64 |
+
data = {
|
65 |
+
'category': category,
|
66 |
+
'style': style,
|
67 |
+
'references1': references1,
|
68 |
+
'references2': references2,
|
69 |
+
'references3': references3,
|
70 |
+
'outline': outline
|
71 |
+
}
|
72 |
+
|
73 |
+
system_prompt = get_blog_post_prompt(data['category'])
|
74 |
+
style_prompt = get_style_prompt(data['style'])
|
75 |
+
|
76 |
+
user_prompt = f"""
|
77 |
+
์นดํ
๊ณ ๋ฆฌ: {data['category']}
|
78 |
+
ํฌ์คํ
์คํ์ผ: {data['style']}
|
79 |
+
ํต์ฌ๊ธฐ๋ฅ: {data['outline']}
|
80 |
+
|
81 |
+
์ฐธ๊ณ ๊ธ1: {data['references1']}
|
82 |
+
์ฐธ๊ณ ๊ธ2: {data['references2']}
|
83 |
+
์ฐธ๊ณ ๊ธ3: {data['references3']}
|
84 |
+
"""
|
85 |
+
|
86 |
+
blog_content = call_api(
|
87 |
+
user_prompt,
|
88 |
+
system_prompt + "\n" + style_prompt,
|
89 |
+
5000,
|
90 |
+
0.7,
|
91 |
+
0.95
|
92 |
+
)
|
93 |
+
|
94 |
+
filtered_post = remove_unwanted_phrases(blog_content)
|
95 |
+
filtered_post = filtered_post.lstrip()
|
96 |
+
|
97 |
+
html_post = convert_to_html(filtered_post)
|
98 |
+
|
99 |
+
return html_post
|
100 |
+
except Exception as e:
|
101 |
+
print(f"๊ธ ์์ฑ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
102 |
+
return ""
|
103 |
+
|
104 |
+
def convert_to_html(text):
|
105 |
+
lines = text.split('\n')
|
106 |
+
html_lines = []
|
107 |
+
for line in lines:
|
108 |
+
line = line.strip()
|
109 |
+
if line.startswith('####'):
|
110 |
+
html_lines.append(f"<h4>{line[4:].strip()}</h4>")
|
111 |
+
elif line.startswith('###'):
|
112 |
+
html_lines.append(f"<h3>{line[3:].strip()}</h3>")
|
113 |
+
elif line.startswith('##'):
|
114 |
+
html_lines.append(f"<h2>{line[2:].strip()}</h2>")
|
115 |
+
elif line.startswith('#'):
|
116 |
+
html_lines.append(f"<h1>{line[1:].strip()}</h1>")
|
117 |
+
elif line.startswith('- '): # ๋ฆฌ์คํธ ์์ดํ
|
118 |
+
html_lines.append(f"<li>{line[2:]}</li>")
|
119 |
+
elif line: # ์ผ๋ฐ ํ
์คํธ (๋น ์ค ์ ์ธ)
|
120 |
+
# '**'๋ก ๊ฐ์ธ์ง ๋ถ๋ถ์ <strong> ํ๊ทธ๋ก ๋ณํ
|
121 |
+
line = re.sub(r'\*\*(.*?)\*\*', r'<strong>\1</strong>', line)
|
122 |
+
html_lines.append(f"<p>{line}</p>")
|
123 |
+
else: # ๋น ์ค
|
124 |
+
html_lines.append("<br>")
|
125 |
+
|
126 |
+
html_content = f"""
|
127 |
+
<div style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
|
128 |
+
{"".join(html_lines)}
|
129 |
+
</div>
|
130 |
+
"""
|
131 |
+
return html_content
|
132 |
+
|
133 |
+
def remove_unwanted_phrases(text):
|
134 |
+
unwanted_phrases = [
|
135 |
+
'์ฌ๋ฌ๋ถ', '์ต๊ทผ', '๋ง์ง๋ง์ผ๋ก', '๊ฒฐ๋ก ์ ์ผ๋ก', '๊ฒฐ๊ตญ',
|
136 |
+
'์ข
ํฉ์ ์ผ๋ก', '๋ฐ๋ผ์', '๋ง๋ฌด๋ฆฌ', '์์ฝ'
|
137 |
+
]
|
138 |
+
|
139 |
+
# ๋ฌธ๋จ๋ณ๋ก ๋๋์ด ์ฒ๋ฆฌ
|
140 |
+
lines = text.split('\n')
|
141 |
+
result_lines = []
|
142 |
+
|
143 |
+
for line in lines:
|
144 |
+
if "๋ค์ ์น์
์์๋" in line:
|
145 |
+
parts = line.split("๋ค์ ์น์
์์๋")
|
146 |
+
if parts[0].strip():
|
147 |
+
result_lines.append(parts[0].strip())
|
148 |
+
else:
|
149 |
+
# ๋ถํ์ํ ํํ ์ ๊ฑฐ (๊ตฌ๋์ ํฌํจ)
|
150 |
+
for phrase in unwanted_phrases:
|
151 |
+
# ๋ถํ์ํ ํํ ์๋ค์ ๊ตฌ๋์ ๊ณผ ๊ณต๋ฐฑ๊น์ง ํฌํจํ์ฌ ์ ๊ฑฐ
|
152 |
+
pattern = rf'(\b{re.escape(phrase)}\b[\s,.!?]*)|([,.!?]*\b{re.escape(phrase)}\b)'
|
153 |
+
line = re.sub(pattern, '', line)
|
154 |
+
|
155 |
+
# ๋ฌธ์ฅ ๋ด ์์ฌ ๊ณต๋ฐฑ ๋ฐ ๊ตฌ๋์ ์ ๋ฆฌ
|
156 |
+
line = re.sub(r'\s{2,}', ' ', line) # ์ฐ์ ๊ณต๋ฐฑ ์ ๊ฑฐ
|
157 |
+
line = line.strip() # ์๋ค ๊ณต๋ฐฑ ์ ๊ฑฐ
|
158 |
+
result_lines.append(line)
|
159 |
+
|
160 |
+
return '\n'.join(result_lines)
|
161 |
+
|
162 |
+
def get_outline_prompt(category):
|
163 |
+
if (category == "ํต์ฌ๊ธฐ๋ฅ์ง์คํ"):
|
164 |
+
return """
|
165 |
+
[์ํ๋ฆฌ๋ทฐ ์์ฃผ์ (Outline) ์์ฑ ๊ท์น]
|
166 |
+
[๊ธฐ๋ณธ๊ท์น]
|
167 |
+
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ
|
168 |
+
2. ๋ฐ๋์ ์ํ์ ํต์ฌ ๊ธฐ๋ฅ 3๊ฐ๋ง ์ ์ ํ๋ผ
|
169 |
+
- ํต์ฌ๊ธฐ๋ฅ์ ์ฐธ๊ณ ๊ธ์ ๋ถ์ํ์ฌ ์ ์ ํ๋ผ
|
170 |
+
4. ๋ฐ๋์ ํต์ฌ ๊ธฐ๋ฅ 3๊ฐ์ ๋ํ ํฅ๋ฏธ๋ก์ด ์์ ๋ชฉ๋ง ์์ฑํ๋ผ(์ ๋ ๋ด์ฉ ์์ฑ ๊ธ์ง)
|
171 |
+
5. ๋ฐ๋์ ๋งํฌ๋ค์ด ํ์์ด ์๋ ์์ํ ํ
์คํธ๋ก ์ถ๋ ฅํ๋ผ
|
172 |
+
6. ์์ ๋ชฉ์ ๋ฐ๋์ 30์ ์ด๋ด๋ก ์์ฑํ๋ผ
|
173 |
+
[์ถ๋ ฅ์์]
|
174 |
+
ํต์ฌ๊ธฐ๋ฅ : ์ ์ ํ ํต์ฌ๊ธฐ๋ฅ1์ ์์ ๋ชฉ
|
175 |
+
ํต์ฌ๊ธฐ๋ฅ : ์ ์ ํ ํต์ฌ๊ธฐ๋ฅ2์ ์์ ๋ชฉ
|
176 |
+
ํต์ฌ๊ธฐ๋ฅ : ์ ์ ํ ํต์ฌ๊ธฐ๋ฅ3์ ์์ ๋ชฉ
|
177 |
+
"""
|
178 |
+
|
179 |
+
def get_blog_post_prompt(category):
|
180 |
+
if (category == "ํต์ฌ๊ธฐ๋ฅ์ง์คํ"):
|
181 |
+
return """
|
182 |
+
[์ํ๋ฆฌ๋ทฐ ์ฝํ
์ธ ์์ฑ ๊ท์น]
|
183 |
+
[๊ธฐ๋ณธ๊ท์น]
|
184 |
+
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ
|
185 |
+
2. ๋ฐ๋์ ์ฃผ์ด์ง ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ์ฃผ์ ์ ๋ํด์๋ง ์์ฑํ๋ผ
|
186 |
+
- ์ ๋๋ก ์ฃผ์ด์ง ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ์ฃผ์ ์ด์ธ์ ๋ด์ฉ์ ์์ฑํ์ง ๋ง ๊ฒ
|
187 |
+
3. ์ฃผ์ด์ง ํต์ฌ ๊ธฐ๋ฅ 1๊ฐ์ ๋ํ ํน์ฅ์ , ๊ฐ์ข
์ ๋ณด, ํ ๋ฑ์ ์์ธํ ์ค๋ช
ํ๋ผ
|
188 |
+
4. ์ ๋ฌธ ์ฉ์ด๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ ์ผ๋ฐ ์ฌ์ฉ์๋ ์ดํด๊ฐ ๋๋๋ก ํ์ด์ ์ค๋ช
ํ๋ผ
|
189 |
+
5. ๋งํฌ๋ค์ด ํ์์ผ๋ก ์์ฑํ๋ผ๋ผ
|
190 |
+
[ํ
์คํธ ์์ฑ ๊ท์น]
|
191 |
+
1. ๋ฐ๋์ ์
๋ ฅ๋ ์ฐธ๊ณ ๊ธ ์์์ ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ๋ํ ๋ด์ฉ์ ์์ฑ
|
192 |
+
2. ์ ๋๋ก ์ฃผ์ด์ง ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ์ฃผ์ ์ด์ธ์ ๋ด์ฉ์ ์์ฑํ์ง ๋ง ๊ฒ
|
193 |
+
3. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ์ ์ดํฌ๋ฅผ ๋ฐ์ํ๋, ์ ๋๋ก ํ ๋ฌธ์ฅ ์ด์ ๊ทธ๋๋ก ์ถ๋ ฅํ์ง ๋ง ๊ฒ
|
194 |
+
4. ์ฝ๊ฒ ์ฝํ ์ ์๋๋ก ์ฌ์ด ์ดํ๋ก ์์ฑ
|
195 |
+
5. ํต์ฌ๊ธฐ๋ฅ์ ๋ํ ์๋น์ ํ๊ฒ์ ๋ถ์ํ์ฌ ์์ฑ
|
196 |
+
6. ์ฃผ์ด์ง ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ๋ง๋ ์คํ, ๊ธฐ๋ฅ, ์ฑ๋ฅ, ์ฅ๋จ์ , ๊ฐ๊ฒฉ ๋๋น ์ฑ๋ฅ(๊ฐ์ฑ๋น), ํ, ์ฃผ์์ฌํญ ๋ฑ์ ์์ฑ
|
197 |
+
7. ์ฃผ์ด์ง ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ๊ด๋ จ๋ ๊ตฌ์ฒด์ ์ธ ์์น(๋ฐ์ดํฐ)๊ฐ ์๋ค๋ฉด ๋ฐ์ํ๋ผ
|
198 |
+
8. ๋ฐ๋์ ํต์ฌ๊ธฐ๋ฅ 1๊ฐ์ ๋ํ ์ฝํ
์ธ ๋ง 1800์ ์ด์ ์์ฑํ๋ผ
|
199 |
+
"""
|
200 |
+
|
201 |
+
def get_style_prompt(style):
|
202 |
+
prompts = {
|
203 |
+
"์น๊ทผํ": """
|
204 |
+
[์น๊ทผํ ํฌ์คํ
์คํ์ผ ๊ฐ์ด๋]
|
205 |
+
1. ํค๊ณผ ์ด์กฐ
|
206 |
+
- ๋ํํ๋ฏ ํธ์ํ๊ณ ์น๊ทผํ ๋งํฌ ์ฌ์ฉ
|
207 |
+
2. ๋ฌธ์ฅ ๋ฐ ์ดํฌ
|
208 |
+
- ๋ฐ๋์ 'ํด์์ฒด'๋ก ์์ฑ, ์ ๋ '์ต๋๋ค'์ฒด๋ฅผ ์ฌ์ฉํ์ง ๋ง ๊ฒ.
|
209 |
+
- '~์'๋ก ๋๋๋๋ก ์์ฑ, '~๋ค'๋ก ๋๋์ง ์๊ฒ ํ๋ผ
|
210 |
+
- ๊ตฌ์ด์ฒด ํํ ์ฌ์ฉ (์: "~ํ์ด์", "~์ธ ๊ฒ ๊ฐ์์")
|
211 |
+
3. ์ฉ์ด ๋ฐ ์ค๋ช
๋ฐฉ์
|
212 |
+
- ์ ๋ฌธ ์ฉ์ด ๋์ ์ฌ์ด ๋จ์ด๋ก ํ์ด์ ์ค๋ช
|
213 |
+
- ๋น์ ๋ ์์ ๋ฅผ ํ์ฉํ์ฌ ๋ณต์กํ ๊ฐ๋
์ค๋ช
|
214 |
+
- ์์ฌ์๋ฌธ๋ฌธ ํ์ฉํ์ฌ ๋
์์ ์ํตํ๋ ๋๋ ์ฃผ๊ธฐ
|
215 |
+
์ฃผ์์ฌํญ: ๋๋ฌด ๊ฐ๋ฒผ์ด ํค์ ์ง์ํ๊ณ , ์ฃผ์ ์ ์ค์์ฑ์ ํด์น์ง ์๋ ์ ์์ ์น๊ทผํจ ์ ์ง
|
216 |
+
(์์: ์๋๋ค~ ์ค๋ ์ค ์ฝ์นด์ฝ๋ผ๋ง์ด์๋ก ์ถ์๊ฐ ๋๋ค๋๊ฑฐ ์๊ณ ๊ณ์
จ๋์?!ใ
์ค๋ ์ค ์ฝ์นด์ฝ๋ผ๋ง์ ์ด๋ค์ง ์์งํ๊ณผ๊ตฌ๋งค์ ๋ณด, ๊ฐ๊ฒฉ, ์นผ๋ก๋ฆฌ ๋ฑ์ ๋ํด ์์ธ~ ํ ์ ์ด๋ณด๋๋ก ํ ๊ป์! ์ค๋ ์ค๋ฅผ ์ข์ํ๋ ์๋ค์๊ฒ๊ฐ์์ผ๋ก ์ค๋ ์ค ์ฝ์นด์ฝ๋ผ๋ง์ ์คฌ๋๋๋ง์๋ค๊ณ ์ข์ํ๋๋ผ๊ตฌ์. ์ฝ๋ผํฅ์ด ๋์ ๋ ๋ง์์ ๋ ๋ค๋ฉฐใ
๊ฐ์ธ์ ์ผ๋ก๋ ๋ณ โญ๏ธโญ๏ธโญ๏ธ.์๊ฑด ๊ฐ์ธ์ฐจ๊ฐ ์์๊ฑฐ ๊ฐ์์~)
|
217 |
+
""",
|
218 |
+
"์ผ๋ฐ": """
|
219 |
+
#์ผ๋ฐ์ ์ธ ๋ธ๋ก๊ทธ ํฌ์คํ
์คํ์ผ ๊ฐ์ด๋
|
220 |
+
1. ํค๊ณผ ์ด์กฐ
|
221 |
+
- ์ค๋ฆฝ์ ์ด๊ณ ๊ฐ๊ด์ ์ธ ํค ์ ์ง
|
222 |
+
- ์ ์ ํ ์กด๋๋ง ์ฌ์ฉ (์: "~ํฉ๋๋ค", "~์
๋๋ค")
|
223 |
+
2. ๋ด์ฉ ๊ตฌ์กฐ ๋ฐ ์ ๊ฐ
|
224 |
+
- ๋ช
ํํ ์ฃผ์ ์ ์๋ก ์์
|
225 |
+
- ๋
ผ๋ฆฌ์ ์ธ ์์๋ก ์ ๋ณด ์ ๊ฐ
|
226 |
+
- ์ฃผ์ ํฌ์ธํธ๋ฅผ ๊ฐ์กฐํ๋ ์์ ๋ชฉ ํ์ฉ
|
227 |
+
- ์ ์ ํ ๊ธธ์ด์ ๋จ๋ฝ์ผ๋ก ๊ตฌ์ฑ
|
228 |
+
3. ์ฉ์ด ๋ฐ ์ค๋ช
๋ฐฉ์
|
229 |
+
- ์ผ๋ฐ์ ์ผ๋ก ์ดํดํ๊ธฐ ์ฌ์ด ์ฉ์ด ์ ํ
|
230 |
+
- ํ์์ ๊ฐ๋จํ ์ค๋ช
์ถ๊ฐ
|
231 |
+
- ๊ฐ๊ด์ ์ธ ์ ๋ณด ์ ๊ณต์ ์ค์
|
232 |
+
4. ํ
์คํธ ๊ตฌ์กฐํ
|
233 |
+
- ๋ถ๋ฆฟ ํฌ์ธํธ๋ ๋ฒํธ ๋งค๊ธฐ๊ธฐ๋ฅผ ํ์ฉํ์ฌ ์ ๋ณด ๊ตฌ์กฐํ
|
234 |
+
- ์ค์ํ ์ ๋ณด๋ ๊ตต์ ๊ธ์จ๋ ๊ธฐ์ธ์๊ผด๋ก ๊ฐ์กฐ
|
235 |
+
5. ๋
์ ์ํธ์์ฉ
|
236 |
+
- ์ ์ ํ ๋
์์ ์๊ฐ์ ๋ฌป๋ ์ง๋ฌธ ํฌํจ
|
237 |
+
- ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์๋ ํค์๋ ์ ์
|
238 |
+
6. ๋ง๋ฌด๋ฆฌ
|
239 |
+
- ์ฃผ์ ๋ด์ฉ ๊ฐ๋จํ ์์ฝ
|
240 |
+
- ์ถ๊ฐ ์ ๋ณด์ ๋ํ ์๋ด ์ ๊ณต
|
241 |
+
์ฃผ์์ฌํญ: ๋๋ฌด ๋ฑ๋ฑํ๊ฑฐ๋ ์ง๋ฃจํ์ง ์๋๋ก ๊ท ํ ์ ์ง
|
242 |
+
์์: "์ต๊ทผ ํ๊ฒฝ ๋ฌธ์ ๊ฐ ๋๋๋๋ฉด์ '์ ๋ก ์จ์ด์คํธ' ๋ผ์ดํ์คํ์ผ์ ๋ํ ๊ด์ฌ์ด ๋์์ง๊ณ ์์ต๋๋ค. ์ ๋ก ์จ์ด์คํธ๋ ์ผ์์ํ์์ ๋ฐ์ํ๋ ์ฐ๋ ๊ธฐ๋ฅผ ์ต์ํํ๋ ์ํ ๋ฐฉ์์ ๋งํฉ๋๋ค. ์ด ๊ธ์์๋ ์ ๋ก ์จ์ด์คํธ์ ๊ฐ๋
, ์ค์ฒ ๋ฐฉ๋ฒ, ๊ทธ๋ฆฌ๊ณ ๊ทธ ํจ๊ณผ์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค. ๋จผ์ ์ ๋ก ์จ์ด์คํธ์ ์ ์๋ถํฐ ์ดํด๋ณด๋ฉด...
|
243 |
+
""",
|
244 |
+
"์ ๋ฌธ์ ์ธ": """
|
245 |
+
#์ ๋ฌธ์ ์ธ ๋ธ๋ก๊ทธ ํฌ์คํ
์คํ์ผ ๊ฐ์ด๋
|
246 |
+
1. ํค๊ณผ ๊ตฌ์กฐ
|
247 |
+
- ๊ณต์์ ์ด๊ณ ํ์ ์ ์ธ ํค ์ฌ์ฉ
|
248 |
+
- ๊ฐ๊ด์ ์ด๊ณ ๋ถ์์ ์ธ ์ ๊ทผ ์ ์ง
|
249 |
+
- ๋ช
ํํ ์๋ก , ๋ณธ๋ก , ๊ฒฐ๋ก ๊ตฌ์กฐ
|
250 |
+
- ์ฒด๊ณ์ ์ธ ๋
ผ์ ์ ๊ฐ
|
251 |
+
- ์ธ๋ถ ์น์
์ ์ํ ๋ช
ํํ ์์ ๋ชฉ ์ฌ์ฉ
|
252 |
+
2. ๋ด์ฉ ๊ตฌ์ฑ ๋ฐ ์ ๊ฐ
|
253 |
+
- ๋ณต์กํ ๊ฐ๋
์ ์ ํํ ์ ๋ฌํ ์ ์๋ ๋ฌธ์ฅ ๊ตฌ์กฐ ์ฌ์ฉ
|
254 |
+
- ๋
ผ๋ฆฌ์ ์ฐ๊ฒฐ์ ์ํ ์ ํ์ด ํ์ฉ
|
255 |
+
- ํด๋น ๋ถ์ผ์ ์ ๋ฌธ ์ฉ์ด ์ ๊ทน ํ์ฉ (ํ์์ ๊ฐ๋ตํ ์ค๋ช
์ ๊ณต)
|
256 |
+
- ์ฌ์ธต์ ์ธ ๋ถ์๊ณผ ๋นํ์ ์ฌ๊ณ ์ ๊ฐ
|
257 |
+
- ๋ค์ํ ๊ด์ ์ ์ ๋ฐ ๋น๊ต
|
258 |
+
3. ๋ฐ์ดํฐ ๋ฐ ๊ทผ๊ฑฐ ํ์ฉ
|
259 |
+
- ํต๊ณ, ์ฐ๊ตฌ ๊ฒฐ๊ณผ, ์ ๋ฌธ๊ฐ ์๊ฒฌ ๋ฑ ์ ๋ขฐํ ์ ์๋ ์ถ์ฒ ์ธ์ฉ
|
260 |
+
- ํ์์ ๊ฐ์ฃผ๋ ์ฐธ๊ณ ๋ฌธํ ๋ชฉ๋ก ํฌํจ
|
261 |
+
- ์์น ๋ฐ์ดํฐ๋ ํ
์คํธ๋ก ๋ช
ํํ ์ค๋ช
|
262 |
+
4. ํ
์คํธ ๊ตฌ์กฐํ
|
263 |
+
- ๋
ผ๋ฆฌ์ ๊ตฌ์กฐ๋ฅผ ๊ฐ์กฐํ๊ธฐ ์ํด ๋ฒํธ ๋งค๊ธฐ๊ธฐ ์ฌ์ฉ
|
264 |
+
- ํต์ฌ ๊ฐ๋
์ด๋ ์ฉ์ด๋ ๊ธฐ์ธ์๊ผด๋ก ๊ฐ์กฐ
|
265 |
+
- ๊ธด ์ธ์ฉ๋ฌธ์ ๋ค์ฌ์ฐ๊ธฐ๋ก ๊ตฌ๋ถ
|
266 |
+
5. ๋ง๋ฌด๋ฆฌ
|
267 |
+
- ํต์ฌ ๋
ผ์ ์ฌ๊ฐ์กฐ
|
268 |
+
- ํฅํ ์ฐ๊ตฌ ๋ฐฉํฅ์ด๋ ์ค๋ฌด์ ํจ์ ์ ์
|
269 |
+
์ฃผ์์ฌํญ: ์ ๋ฌธ์ฑ์ ์ ์งํ๋, ์์ ํ ์ดํดํ๊ธฐ ์ด๋ ค์ด ์์ค์ ์ง์
|
270 |
+
์์: "๋ณธ ์ฐ๊ตฌ์์๋ ์ธ๊ณต์ง๋ฅ(AI)์ ์ค๋ฆฌ์ ํจ์์ ๋ํด ๊ณ ์ฐฐํ๋ค. ํนํ, ์์จ์ฃผํ ์๋์ฐจ์ ์์ฌ๊ฒฐ์ ์๊ณ ๋ฆฌ์ฆ์์ ๋ฐ์ํ ์ ์๋ ์ค๋ฆฌ์ ๋๋ ๋ง์ ์ด์ ์ ๋ง์ถ๋ค. Bonnefon et al. (2016)์ ์ฐ๊ตฌ์ ๋ฐ๋ฅด๋ฉด, ์์จ์ฃผํ ์ฐจ๋์ ์๊ณ ๋ฆฌ์ฆ์ด ์ง๋ฉดํ ์ ์๋ ์ค๋ฆฌ์ ์ ํ์ ๋ณต์ก์ฑ์ด ์ง์ ๋ ๋ฐ ์๋ค. ๋ณธ๊ณ ์์๋ ์ด๋ฌํ ์ค๋ฆฌ์ ๋๋ ๋ง๋ฅผ ์ธ ๊ฐ์ง ์ฃผ์ ๊ด์ ์์ ๋ถ์ํ๋ค: 1) ๊ณต๋ฆฌ์ฃผ์์ ์ ๊ทผ, 2) ์๋ฌด๋ก ์ ์ ๊ทผ, 3) ๋ ์ค๋ฆฌ์ ์ ๊ทผ. ๊ฐ ์ ๊ทผ๋ฒ์ ์ฅ๋จ์ ์ ๋น๊ต ๋ถ์ํ๊ณ , ์ด๋ฅผ ๋ฐํ์ผ๋ก ์์จ์ฃผํ ์ฐจ๋์ ์ค๋ฆฌ์ ์์ฌ๊ฒฐ์ ํ๋ ์์ํฌ๋ฅผ ์ ์ํ๊ณ ์ ํ๋ค...
|
271 |
+
"""
|
272 |
+
}
|
273 |
+
return prompts.get(style, "ํฌ์คํ
์คํ์ผ ํ๋กฌํํธ")
|
274 |
+
|
275 |
+
def split_titles(suggested_titles):
|
276 |
+
titles = suggested_titles.split('\n')
|
277 |
+
titles = [re.sub(r'^(1\.|2\.|3\.|4\.|5\.|6\.|7\.|8\.|9\.|10\.|## |# |\* |\*\* |\*\*\*)', '', title.strip()) for title in titles if title.strip()]
|
278 |
+
titles = titles[::-1] # ๋ฆฌ์คํธ๋ฅผ ์ญ์์ผ๋ก ์ ๋ ฌ
|
279 |
+
titles += [""] * (10 - len(titles)) # 10๊ฐ๋ณด๋ค ์ ์ผ๋ฉด ๋น ๋ฌธ์์ด๋ก ์ฑ์ฐ๊ธฐ
|
280 |
+
return titles[:10] # ์ต๋ 10๊ฐ์ ์ ๋ชฉ๋ง ๋ฐํ
|
281 |
+
|
282 |
+
class PDF(FPDF):
|
283 |
+
def __init__(self):
|
284 |
+
super().__init__(orientation='P', unit='mm', format='A4')
|
285 |
+
self.set_margins(10, 10, 10)
|
286 |
+
current_dir = os.path.dirname(__file__)
|
287 |
+
self.add_font("NanumGothic", "", os.path.join(current_dir, "NanumGothic.ttf"))
|
288 |
+
self.add_font("NanumGothic", "B", os.path.join(current_dir, "NanumGothicBold.ttf"))
|
289 |
+
self.add_font("NanumGothicExtraBold", "", os.path.join(current_dir, "NanumGothicExtraBold.ttf"))
|
290 |
+
self.add_font("NanumGothicLight", "", os.path.join(current_dir, "NanumGothicLight.ttf"))
|
291 |
+
|
292 |
+
def header(self):
|
293 |
+
self.set_font('NanumGothic', '', 10)
|
294 |
+
# ํค๋ ๋ด์ฉ ์ถ๊ฐ (ํ์ํ ๊ฒฝ์ฐ)
|
295 |
+
|
296 |
+
def footer(self):
|
297 |
+
self.set_y(-15)
|
298 |
+
self.set_font('NanumGothic', '', 8)
|
299 |
+
self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
|
300 |
+
|
301 |
+
def chapter_title(self, title):
|
302 |
+
self.set_font("NanumGothic", 'B', 12)
|
303 |
+
self.cell(0, 6, title, 0, 1, 'L')
|
304 |
+
self.ln(4)
|
305 |
+
|
306 |
+
def chapter_body(self, body):
|
307 |
+
self.set_font("NanumGothic", '', 11)
|
308 |
+
self.multi_cell(0, 5, body)
|
309 |
+
self.ln()
|
310 |
+
|
311 |
+
def print_chapter(self, title, body):
|
312 |
+
self.add_page()
|
313 |
+
self.chapter_title(title)
|
314 |
+
self.chapter_body(body)
|
315 |
+
|
316 |
+
def format_filename(text):
|
317 |
+
if not isinstance(text, str):
|
318 |
+
text = str(text) # ๋ฌธ์์ด์ด ์๋ ๊ฒฝ์ฐ ๋ฌธ์์ด๋ก ๋ณํ
|
319 |
+
text = re.sub(r'[^\w\s-]', '', text)
|
320 |
+
return text[:50].strip()
|
321 |
+
|
322 |
+
def save_to_pdf(blog_post, outline):
|
323 |
+
try:
|
324 |
+
pdf = PDF()
|
325 |
+
pdf.add_page()
|
326 |
+
# HTML ํ๊ทธ๋ฅผ ํ์ฑํ๊ธฐ ์ํ ์ ๊ทํํ์
|
327 |
+
tag_pattern = re.compile(r'<(/?)(\w+)([^>]*)>')
|
328 |
+
# ํ์ฌ ๋ ์ง์ ์๊ฐ์ ๊ฐ์ ธ์ต๋๋ค (๋ํ๋ฏผ๊ตญ ์๊ฐ ๊ธฐ์ค)
|
329 |
+
now = datetime.now(ZoneInfo("Asia/Seoul"))
|
330 |
+
date_str = now.strftime("%y%m%d")
|
331 |
+
time_str = now.strftime("%H%M")
|
332 |
+
# ์ฒซ ๋ฒ์งธ ์ ๋ชฉ์ ์ฐพ์ ํ์ผ๋ช
์ผ๋ก ์ฌ์ฉ
|
333 |
+
filename = f"{date_str}_{time_str}_{format_filename(outline)}.pdf"
|
334 |
+
# HTML ๋ด์ฉ์ ์ํํ๋ฉฐ PDF์ ์์ฑ
|
335 |
+
current_tag = ''
|
336 |
+
buffer = ''
|
337 |
+
for part in re.split(tag_pattern, blog_post):
|
338 |
+
# HTML ํ๊ทธ๊ฐ ๋ฑ์ฅํ ๊ฒฝ์ฐ
|
339 |
+
if part in ['h1', 'h2', 'h3', 'p', 'strong', 'li', 'br']:
|
340 |
+
# ์ด์ ํ๊ทธ์ ๋ด์ฉ์ ์ฒ๋ฆฌ
|
341 |
+
if buffer:
|
342 |
+
if current_tag in ['h1', 'h2', 'h3']:
|
343 |
+
pdf.chapter_title(buffer.strip()) # ์์ ๋ชฉ ์ฒ๋ฆฌ
|
344 |
+
elif current_tag == 'p':
|
345 |
+
pdf.chapter_body(buffer.strip()) # ์ผ๋ฐ ๋ฌธ๋จ ์ฒ๋ฆฌ
|
346 |
+
elif current_tag == 'strong':
|
347 |
+
pdf.set_font("NanumGothic", 'B', 11) # ๊ตต์ ๊ธ์จ ์ฒ๋ฆฌ
|
348 |
+
pdf.cell(0, 5, buffer.strip(), 0, 1)
|
349 |
+
pdf.set_font("NanumGothic", '', 11) # ๋ค์ ๊ธฐ๋ณธ ํฐํธ๋ก ๋ณ๊ฒฝ
|
350 |
+
elif current_tag == 'li':
|
351 |
+
pdf.chapter_body("โข " + buffer.strip()) # ๋ฆฌ์คํธ ์์ดํ
์ฒ๋ฆฌ
|
352 |
+
elif current_tag == 'br':
|
353 |
+
pdf.ln(5) # ์ค๋ฐ๊ฟ ์ฒ๋ฆฌ
|
354 |
+
# ํ์ฌ ํ๊ทธ์ ๋ฒํผ ์ด๊ธฐํ
|
355 |
+
buffer = ''
|
356 |
+
current_tag = part
|
357 |
+
# ์ข
๋ฃ ํ๊ทธ๋ ๋ฌด์ (div ํฌํจ)
|
358 |
+
elif part.startswith('/'):
|
359 |
+
continue
|
360 |
+
# ํ
์คํธ ๋ถ๋ถ ์ฒ๋ฆฌ
|
361 |
+
elif not tag_pattern.match(part) and part.strip() != 'div':
|
362 |
+
buffer += part
|
363 |
+
# ๋ง์ง๋ง ๋ฒํผ ์ฒ๋ฆฌ
|
364 |
+
if buffer:
|
365 |
+
if current_tag in ['h1', 'h2', 'h3']:
|
366 |
+
pdf.chapter_title(buffer.strip()) # ์ ๋ชฉ ํ์์ผ๋ก ์ฒ๋ฆฌ
|
367 |
+
elif current_tag == 'p':
|
368 |
+
pdf.chapter_body(buffer.strip()) # ๋ณธ๋ฌธ ํ์์ผ๋ก ์ฒ๋ฆฌ
|
369 |
+
# PDF ์ ์ฅ
|
370 |
+
print(f"Saving PDF as: {filename}")
|
371 |
+
pdf.output(filename, 'F') # 'F' ์ต์
์ถ๊ฐ
|
372 |
+
return filename
|
373 |
+
except Exception as e:
|
374 |
+
print(f"PDF ์์ฑ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
375 |
+
import traceback
|
376 |
+
traceback.print_exc() # ์์ธํ ์ค๋ฅ ์ ๋ณด ์ถ๋ ฅ
|
377 |
+
return None # ์ค๋ฅ ๋ฐ์ ์ None ๋ฐํ
|
378 |
+
|
379 |
+
def save_content_to_pdf(blog_post, outline):
|
380 |
+
pdf_filename = save_to_pdf(blog_post, outline)
|
381 |
+
if pdf_filename:
|
382 |
+
return pdf_filename
|
383 |
+
else:
|
384 |
+
return None
|
385 |
+
|
386 |
+
title = "ํต์ฌ๊ธฐ๋ฅ์ง์คํ"
|
387 |
+
|
388 |
+
with gr.Blocks() as demo:
|
389 |
+
gr.Markdown(f"# ํต์ฌ๊ธฐ๋ฅ์ง์คํ")
|
390 |
+
|
391 |
+
gr.Markdown("### 1๋จ๊ณ: ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ๋ฅผ ์ง์ ํด์ฃผ์ธ์", elem_id="step-title")
|
392 |
+
category = gr.Radio(choices=["ํต์ฌ๊ธฐ๋ฅ์ง์คํ"], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="ํต์ฌ๊ธฐ๋ฅ์ง์คํ")
|
393 |
+
|
394 |
+
gr.Markdown("---\n\n")
|
395 |
+
|
396 |
+
gr.Markdown("### 2๋จ๊ณ: ํฌ์คํ
์คํ์ผ์ ์ ํํด์ฃผ์ธ์", elem_id="step-title")
|
397 |
+
style = gr.Radio(choices=["์น๊ทผํ", "์ผ๋ฐ", "์ ๋ฌธ์ ์ธ"], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
398 |
+
|
399 |
+
gr.Markdown("---\n\n")
|
400 |
+
|
401 |
+
gr.Markdown("### 3๋จ๊ณ: ์ฐธ๊ณ ๊ธ์ ์
๋ ฅํ์ธ์", elem_id="step-title")
|
402 |
+
references1 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ์ผ์ธ์", lines=10)
|
403 |
+
references2 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ์ผ์ธ์", lines=10)
|
404 |
+
references3 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ์ผ์ธ์", lines=10)
|
405 |
+
|
406 |
+
gr.Markdown("---\n\n")
|
407 |
+
|
408 |
+
gr.Markdown("### 4๋จ๊ณ: ํต์ฌ๊ธฐ๋ฅ์ ์์ฑํด์ฃผ์ธ์", elem_id="step-title")
|
409 |
+
gr.HTML("<span style='color: grey;'>[๋์จ ๊ฒฐ๊ณผ๋ฅผ ์์ ํด์ ์ฌ์ฉํด์ฃผ์ธ์]</span>")
|
410 |
+
|
411 |
+
outline_generate_btn = gr.Button("ํต์ฌ๊ธฐ๋ฅ ์ ์ ํ๊ธฐ")
|
412 |
+
outline_result1 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 1", lines=2)
|
413 |
+
outline_result2 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 2", lines=2)
|
414 |
+
outline_result3 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 3", lines=2)
|
415 |
+
outline_input = gr.Textbox(label="์์ฑํ ํต์ฌ๊ธฐ๋ฅ ์ฃผ์ ์ค์ 1๊ฐ๋ง ์
๋ ฅํด์ฃผ์ธ์", placeholder="ํต์ฌ๊ธฐ๋ฅ 1๊ฐ๋ง ์
๋ ฅํ์ธ์", lines=2)
|
416 |
+
|
417 |
+
outline_generate_btn.click(
|
418 |
+
fn=generate_outline,
|
419 |
+
inputs=[category, style, references1, references2, references3],
|
420 |
+
outputs=[outline_result1, outline_result2, outline_result3]
|
421 |
+
)
|
422 |
+
|
423 |
+
gr.Markdown("---\n\n")
|
424 |
+
|
425 |
+
gr.Markdown("### 5๋จ๊ณ: ๊ธ ์์ฑํ๊ธฐ", elem_id="step-title")
|
426 |
+
gr.HTML("<span style='color: grey;'>[ํต์ฌ๊ธฐ๋ฅ์ ํ์ธํ์ธ์]</span>")
|
427 |
+
|
428 |
+
generate_btn = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ")
|
429 |
+
html_output = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ")
|
430 |
+
|
431 |
+
generate_btn.click(
|
432 |
+
fn=generate_blog_post,
|
433 |
+
inputs=[category, style, references1, references2, references3, outline_input],
|
434 |
+
outputs=[html_output],
|
435 |
+
show_progress=True
|
436 |
+
)
|
437 |
|
438 |
+
save_pdf_btn = gr.Button("PDF๋ก ์ ์ฅํ๊ธฐ")
|
439 |
+
pdf_output = gr.File(label="์์ฑ๋ PDF ํ์ผ")
|
440 |
+
|
441 |
+
save_pdf_btn.click(
|
442 |
+
fn=save_content_to_pdf,
|
443 |
+
inputs=[html_output, outline_input], # outline_input ์ถ๊ฐ
|
444 |
+
outputs=[pdf_output],
|
445 |
+
show_progress=True
|
446 |
+
)
|
447 |
|
448 |
+
demo.launch()
|
|
|
|
|
|
|
449 |
|
450 |
+
gr.HTML("""
|
451 |
+
<style>
|
452 |
+
#step-title {
|
453 |
+
font-size: 1.7em;
|
454 |
+
font-weight: bold;
|
455 |
+
}
|
456 |
+
</style>
|
457 |
+
""")
|