Update app.py
Browse files
app.py
CHANGED
@@ -116,24 +116,39 @@ def call_api(content, system_message, max_tokens, temperature, top_p):
|
|
116 |
def analyze_info(category, style, topic, references1, references2, references3):
|
117 |
return f"์ ํํ ์นดํ
๊ณ ๋ฆฌ: {category}\n์ ํํ ํฌ์คํ
์คํ์ผ: {style}\n๋ธ๋ก๊ทธ ์ฃผ์ : {topic}\n์ฐธ๊ณ ๊ธ1: {references1}\n์ฐธ๊ณ ๊ธ2: {references2}\n์ฐธ๊ณ ๊ธ3: {references3}"
|
118 |
|
119 |
-
def suggest_title(category, style, topic, references1, references2, references3
|
120 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
|
|
|
|
|
|
|
|
|
|
121 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
122 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(full_content, combined_prompt, max_tokens, temperature, top_p)
|
123 |
token_usage_message = f"[์
๋ ฅ ํ ํฐ์: {input_tokens}]\n[์ถ๋ ฅ ํ ํฐ์: {output_tokens}]\n[์ด ํ ํฐ์: {total_tokens}]"
|
124 |
return modified_text, token_usage_message
|
125 |
|
126 |
-
def generate_outline(category, style, topic, references1, references2, references3, title
|
127 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
128 |
content = f"{full_content}\nTitle: {title}"
|
|
|
|
|
|
|
|
|
|
|
129 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
130 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
|
131 |
token_usage_message = f"[์
๋ ฅ ํ ํฐ์: {input_tokens}]\n[์ถ๋ ฅ ํ ํฐ์: {output_tokens}]\n[์ด ํ ํฐ์: {total_tokens}]"
|
132 |
return modified_text, token_usage_message
|
133 |
|
134 |
-
def generate_blog_post(category, style, topic, references1, references2, references3, title, outline
|
135 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
136 |
content = f"{full_content}\nTitle: {title}\nOutline: {outline}"
|
|
|
|
|
|
|
|
|
|
|
137 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
138 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
|
139 |
formatted_text = modified_text.replace('\n', '\n\n')
|
@@ -156,7 +171,7 @@ def fetch_references(topic):
|
|
156 |
|
157 |
return "์ฐธ๊ณ ๊ธ ์์ฑ ์๋ฃ", references1_content, references2_content, references3_content
|
158 |
|
159 |
-
def fetch_references_and_generate_all_steps(category, style, topic, blog_title
|
160 |
search_url = generate_naver_search_url(topic)
|
161 |
session = setup_session()
|
162 |
if session is None:
|
@@ -172,10 +187,10 @@ def fetch_references_and_generate_all_steps(category, style, topic, blog_title,
|
|
172 |
references3_content = f"์ ๋ชฉ: {selected_results[2]['์ ๋ชฉ']}\n๋ด์ฉ: {crawl_blog_content(selected_results[2]['๋งํฌ'], session)}"
|
173 |
|
174 |
# ์์๋ผ์ธ ์์ฑ
|
175 |
-
outline_result, outline_token_usage = generate_outline(category, style, topic, references1_content, references2_content, references3_content, blog_title
|
176 |
|
177 |
# ๋ธ๋ก๊ทธ ๊ธ ์์ฑ
|
178 |
-
blog_post_result, blog_post_token_usage = generate_blog_post(category, style, topic, references1_content, references2_content, references3_content, blog_title, outline_result
|
179 |
|
180 |
return references1_content, references2_content, references3_content, outline_result, outline_token_usage, blog_post_result, blog_post_token_usage
|
181 |
|
@@ -183,150 +198,30 @@ def get_title_prompt(category):
|
|
183 |
if (category == "์ผ๋ฐ"):
|
184 |
return """
|
185 |
# ๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น(์ผ๋ฐ)
|
186 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
187 |
-
1. ๋ฐ๋์ ๏ฟฝ๏ฟฝ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
188 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
189 |
-
3. ํนํ ๋๋ '์ ๋ณด์ฑ(Informative)' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
190 |
-
4. ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
191 |
-
|
192 |
-
##[๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น]
|
193 |
-
1. ๋ธ๋ก๊ทธ ์ ๋ชฉ 10๊ฐ๋ฅผ ์์ฑํ๊ณ ์ ๋ชฉ 10๊ฐ๋ง ์ถ๋ ฅํ๋ผ.
|
194 |
-
2. ์ ๋ชฉ์ 40์ ์ด๋ด๋ก ์์ฑํ๋ผ.
|
195 |
-
3. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ์ ๋ง์ถฐ ๋ธ๋ก๊ทธ ์ ๋ชฉ 10๊ฐ๋ฅผ ์์ฑํ๋ผ.
|
196 |
-
4. ๋ฐ๋์ ํต์ฌํค์๋(Topic)๊ฐ ๋ฌธ์ฅ ์์ชฝ์ ๋ค์ด๊ฐ๋๋ก ์์ฑํ๋ผ.
|
197 |
-
5. ํต์ฌ ํค์๋์ ์ฐ๊ด์ฑ ๋์ ์ฃผ์ ๋ฅผ ํฌํจํ์ฌ ์์ฑํ๋ผ.
|
198 |
"""
|
199 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
200 |
return """
|
201 |
# ๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
202 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
203 |
-
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
204 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
205 |
-
3. ํนํ ๋๋ '๊ฑด๊ฐ, ์ํ ์ ๋ณด' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํฐ์ด๋ค.
|
206 |
-
4. ์ ํํ๊ณ ์ ๋ฌธ์ ์ธ ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
207 |
-
|
208 |
-
##[๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น]
|
209 |
-
1. ๋ธ๋ก๊ทธ ์ ๋ชฉ 10๊ฐ๋ฅผ ์์ฑํ๊ณ ์ ๋ชฉ 10๊ฐ๋ง ์ถ๋ ฅํ๋ผ.
|
210 |
-
2. ์ ๋ชฉ์ 40์ ์ด๋ด๋ก ์์ฑํ๋ผ.
|
211 |
-
3. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ์ ๋ง์ถฐ ๋ธ๋ก๊ทธ ์ ๋ชฉ 10๊ฐ๋ฅผ ์์ฑํ๋ผ.
|
212 |
-
4. ์ฌ์ฉ์๊ฐ ์
๋ ฅํ ๋ธ๋ก๊ทธ ์ฃผ์ , ํต์ฌํค์๋(Topic)๊ฐ ๋ฌธ์ฅ ์์ชฝ์ ๋ค์ด๊ฐ๋๋ก ์ ๋ชฉ์ ์์ฑํ๋ผ.
|
213 |
-
5. ์ฐธ๊ณ ๊ธ์ ๋ถ์ํ์ฌ ๋
์๋ค์ด ๊ฑด๊ฐํ ์ํ์ ์ ์งํ๋ ๋ฐ ํ์ํ ์ ๋ณด๋ฅผ ๋ฐ์ํ๋ผ.
|
214 |
"""
|
215 |
|
216 |
def get_outline_prompt(category):
|
217 |
if (category == "์ผ๋ฐ"):
|
218 |
return """
|
219 |
# ๋ธ๋ก๊ทธ ์์ฃผ์ (Subtopic) ์์ฑ ๊ท์น(์ผ๋ฐ)
|
220 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
221 |
-
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
222 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
223 |
-
3. ํนํ ๋๋ '์ ๋ณด์ฑ(Informative)' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
224 |
-
4. ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
225 |
-
|
226 |
-
##[์์ฃผ์ ์์ฑ๊ท์น]
|
227 |
-
1. [๊ธฐ๋ณธ๊ท์น]์ ๊ธฐ๋ณธ ์ ์ฉํ๋ผ.
|
228 |
-
2. ๋ธ๋ก๊ทธ ๊ธ์ ์์ฑํ๊ธฐ ์ํ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
229 |
-
3. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ๊ณผ ๋ธ๋ก๊ทธ ์ฃผ์ , ์ ๋ชฉ์ ๋ฐํ์ผ๋ก ํต์ฌ ์ฃผ์ ๋ฅผ ํ์
ํ์ฌ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
230 |
-
4. ์ ์ฒด ๋งฅ๋ฝ์ ๋ง๊ฒ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
231 |
-
5. ์์ ๋ชฉ์ผ๋ก ์ฌ์ฉํ ์ ์๋๋ก 20์ ๋ด์ธ๋ก ์์ฑํ๋ผ.
|
232 |
-
6. ๋
์๊ฐ ์ป๊ณ ์ ํ๋ ์ ๋ณด์ ํฅ๋ฏธ๋ก์ด ์ ๋ณด๋ฅผ ์ ๊ณตํ๋๋ก ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
233 |
-
7. ์์ฃผ์ ์ ๋ณธ๋ก ์ ๋ด์ฉ์ด ์ถฉ๋ถํ ์์ฑ๋ ์ ์๋ ์์ฃผ์ ๋ก ์ค์ ํ๋ผ.
|
234 |
-
8. ๋ฐ๋์ [์์ฃผ์ ๊ตฌ์ฑ]์ ๋ง๊ฒ ์ถ๋ ฅํ๋ผ.
|
235 |
-
|
236 |
-
##[์์ฃผ์ ๊ตฌ์ฑ]
|
237 |
-
1. ๋ฐ๋์ [๋์
๋ถ] - 1๊ฐ, [๋ณธ๋ก 1~5] - 5๊ฐ, [๊ฒฐ๋ก ] - 1๊ฐ๋ก ๊ตฌ์ฑํ์ฌ ์ถ๋ ฅํ๋ผ.
|
238 |
-
2. ๋ฐ๋์ [๋์
๋ถ]์ [๊ฒฐ๋ก ]์ ์ ๋ชฉ์ด ์ค๋ณต๋์ง ์๋๋ก ์์ฑํ๋ผ.
|
239 |
"""
|
240 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
241 |
return """
|
242 |
# ๋ธ๋ก๊ทธ ์์ฃผ์ (Subtopic) ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
243 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
244 |
-
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
245 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
246 |
-
3. ํนํ ๋๋ '๊ฑด๊ฐ, ์ํ ์ ๋ณด' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํฐ์ด๋ค.
|
247 |
-
4. ์ ํํ๊ณ ์ ๋ฌธ์ ์ธ ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
248 |
-
|
249 |
-
##[์์ฃผ์ ์์ฑ๊ท์น]
|
250 |
-
1. [๊ธฐ๋ณธ๊ท์น]์ ๊ธฐ๋ณธ ์ ์ฉํ๋ผ.
|
251 |
-
2. ๋ธ๋ก๊ทธ ๊ธ์ ์์ฑํ๊ธฐ ์ํ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
252 |
-
3. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ๊ณผ ๋ธ๋ก๊ทธ ์ฃผ์ , ์ ๋ชฉ์ ๋ฐํ์ผ๋ก ํต์ฌ ์ฃผ์ ๋ฅผ ํ์
ํ์ฌ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
253 |
-
4. ์ ์ฒด ๋งฅ๋ฝ์ ๋ง๊ฒ ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
254 |
-
5. ์์ ๋ชฉ์ผ๋ก ์ฌ์ฉํ ์ ์๋๋ก 20์ ๋ด์ธ๋ก ์์ฑํ๋ผ.
|
255 |
-
6. ๋
์๊ฐ ์ป๊ณ ์ ํ๋ ์ ํํ ์ ๋ณด์ ๊ฑด๊ฐํ ์ํ์ ์ ์งํ๋ ๋ฐ ํ์ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋๋ก ์์ฃผ์ ๋ฅผ ์์ฑํ๋ผ.
|
256 |
-
7. ์์ฃผ์ ์ ๋ณธ๋ก ์ ๋ด์ฉ์ด ์ถฉ๋ถํ ์์ฑ๋ ์ ์๋ ์์ฃผ์ ๋ก ์ค์ ํ๋ผ.
|
257 |
-
8. ๋ฐ๋์ [์์ฃผ์ ๊ตฌ์ฑ]์ ๋ง์ถฐ ์์ฃผ์ ๋ง ์ถ๋ ฅํ๋ผ.
|
258 |
-
|
259 |
-
##[์์ฃผ์ ๊ตฌ์ฑ]
|
260 |
-
1. ๋ฐ๋์ [๋์
๋ถ] - 1๊ฐ, [๋ณธ๋ก 1~5] - 5๊ฐ, [๊ฒฐ๋ก ] - 1๊ฐ๋ก ๊ตฌ์ฑํ์ฌ ์ถ๋ ฅํ๋ผ.
|
261 |
-
2. ๋ฐ๋์ [๋์
๋ถ]์ [๊ฒฐ๋ก ]์ ์ ๋ชฉ์ด ์ค๋ณต๋์ง ์๋๋ก ์์ฑํ๋ผ.
|
262 |
"""
|
263 |
|
264 |
def get_blog_post_prompt(category):
|
265 |
if (category == "์ผ๋ฐ"):
|
266 |
return """
|
267 |
# ๋ธ๋ก๊ทธ ํ
์คํธ ์์ฑ ๊ท์น(์ผ๋ฐ)
|
268 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
269 |
-
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
270 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
271 |
-
3. ํนํ ๋๋ '์ ๋ณด์ฑ(Informative)' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
272 |
-
4. ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
273 |
-
|
274 |
-
##[ํ
์คํธ ์์ฑ ๊ท์น]
|
275 |
-
1. ๋ฐ๋์ ์
๋ ฅ๋ [์์ฃผ์ ]์ ๋ง๊ฒ ํ
์คํธ๋ฅผ ์์ฑํ๋ผ.
|
276 |
-
2. ์์ฃผ์ ์ [๋ณธ๋ก ] 5๊ฐ๋ฅผ ๊ฐ๊ฐ 300์ ์ด์์ผ๋ก ์์ฑํ๋ผ.
|
277 |
-
3. ์์ฃผ์ ์ [๋ณธ๋ก ] ์ด 300์ ์ด์ ์์ฑ๋์ง ์๋๋ค๋ฉด, ์ ์ฒด๊ธ์ด 2000์ ์ด์๋๋๋ก ์์ฑํ๋ผ.
|
278 |
-
4. ์ ์ฒด ๋งฅ๋ฝ์ ์ดํดํ๊ณ ๋ฌธ์ฅ์ ์ผ๊ด์ฑ์ ์ ์งํ๋ผ.
|
279 |
-
5. ์ฃผ์ ์ ๋ง๋ ๋๋ค์, ํ๋ฅด์๋๋ฅผ ์ ์ฉํ์ฌ ์์ฑํ๋ผ.
|
280 |
-
6. ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ๏ฟฝ๏ฟฝ๏ฟฝ ์ดํฌ๋ฅผ ๋ฐ์ํ๋, [ํฌ์คํ
์คํ์ผ]์ ๋ง๊ฒ ์ ์ฉํ๋ผ.
|
281 |
-
7. ์ ๋๋ก ์ฐธ๊ณ ๊ธ์ ํ๋ฌธ์ฅ ์ด์ ๊ทธ๋๋ก ์ถ๋ ฅํ์ง ๋ง ๊ฒ.
|
282 |
-
8. ์ฃผ์ ์ ์ํฉ์ ๋ง๋ ์ ์ ํ ์ดํ๋ฅผ ์ ํํ๋ผ.
|
283 |
-
9. ํ๊ธ ์ดํ์ ๋์ด๋๋ ์ฝ๊ฒ ์์ฑํ๋ผ.
|
284 |
-
10. ์ ๋ ๋ฌธ์ฅ์ ๋์ '๋ต๋๋ค'๋ฅผ ์ฌ์ฉํ์ง ๋ง ๊ฒ.
|
285 |
-
|
286 |
-
###[์ ๋ณด์ฑ ๋ธ๋ก๊ทธ ์์ฑ ๊ท์น]
|
287 |
-
1. ๋
์๊ฐ ์ป๊ณ ์ ํ๋ ์ ์ฉํ ์ ๋ณด์ ํฅ๋ฏธ๋ก์ด ์ ๋ณด๋ฅผ ์ ๊ณตํ๋๋ก ์์ฑํ๋ผ.
|
288 |
-
2. ๋
์์ ๊ณต๊ฐ์ ์ด๋์ด๋ด๊ณ ๊ถ๊ธ์ฆ์ ํด๊ฒฐํ๋๋ก ์์ฑํ๋ผ.
|
289 |
-
3. ๋
์์ ๊ด์ฌ์ฌ๋ฅผ ์ถฉ์กฑ์ํค๋๋ก ์์ฑํ๋ผ.
|
290 |
-
4. ๋
์์๊ฒ ์ด๋์ด ๋๋ ์ ๋ณด๋ฅผ ์์ฑํ๋ผ.
|
291 |
-
|
292 |
-
##[์ ์ธ ๊ท์น]
|
293 |
-
1. ๋ฐ๋์ ๋น์์ด ๋ฐ ์์ค(expletive, abusive language, slang)์ ์ ์ธํ๋ผ.
|
294 |
-
2. ๋ฐ๋์ ์ฐธ๊ณ ๊ธ์ ๋งํฌ(URL)๋ ์ ์ธํ๋ผ.
|
295 |
-
3. ์ฐธ๊ณ ๊ธ์์ '๋งํฌ๋ฅผ ํ์ธํด์ฃผ์ธ์'์ ๊ฐ์ ๋งํฌ ์ด๋์ ๋ฌธ๊ตฌ๋ ์ ์ธํ๋ผ.
|
296 |
-
4. ์ฐธ๊ณ ๊ธ์ ์๋ ์์ฑ์, ํ์, ์ ํ๋ฒ, ๊ธฐ์(Writer, speaker, YouTuber, reporter)์ ์ด๋ฆ, ์ ์นญ, ๋๋ค์(Name, Nkickname)์ ๋ฐ๋์ ์ ์ธํ๋ผ.
|
297 |
-
5. ๋ฐ๋์ ๋ฌธ์ฅ์ ๋๋ถ๋ถ์ด ์ด์ํ ํ๊ตญ์ด ํํ์ ์ ์ธํ๋ผ('์์', '๋ต๋๋ค', 'ํด์', 'ํด์ฃผ์ฃ ', '๋์ฃ ', '๋์ด์', '๊ณ ์' ๋ฑ.)
|
298 |
"""
|
299 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
300 |
return """
|
301 |
# ๋ธ๋ก๊ทธ ํ
์คํธ ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
302 |
-
##[๊ธฐ๋ณธ๊ท์น]
|
303 |
-
1. ๋ฐ๋์ ํ๊ตญ์ด(ํ๊ธ)๋ก ์์ฑํ๋ผ.
|
304 |
-
2. ๋๋ ๊ฐ์ฅ ์ฃผ๋ชฉ๋ฐ๋ ๋ง์ผํฐ์ด๋ฉฐ ๋ธ๋ก๊ทธ ๋ง์ผํ
์ ๋ฌธ๊ฐ์ด๋ค.
|
305 |
-
3. ํนํ ๋๋ '๊ฑด๊ฐ, ์ํ ์ ๋ณด' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํฐ์ด๋ค.
|
306 |
-
4. ์ ํํ๊ณ ์ ๋ฌธ์ ์ธ ์ ๋ณด ์ ๊ณต์ ์ด์ ์ ๋ง์ถ์ด ์์ฑํ๋ค.
|
307 |
-
|
308 |
-
##[ํ
์คํธ ์์ฑ ๊ท์น]
|
309 |
-
1. ๋ฐ๋์ ์
๋ ฅ๋ [์์ฃผ์ ]์ ๋ง์ถฐ์ ํ
์คํธ๋ฅผ ์์ฑํ๋ผ.
|
310 |
-
2. ๋ฐ๋์ ์
๋ ฅ๋ [์์ฃผ์ ]๋ ๋ณ๊ฒฝํ์ง ๋ง๊ณ ๊ทธ๋๋ก ์ถ๋ ฅํ๋ผ.
|
311 |
-
3. ์์ฃผ์ ์ [๋์
๋ถ]๋ ๊ฐ๋ณ๊ฒ ์์ฑํ๋ ๊ณต๊ฐ๊ณผ ํฅ๋ฏธ, ๋ฌธ์ ์ ๊ธฐ, ๊ธ์ ๋ชฉ์ , ๋ณธ๋ฌธ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ์ด์ด์ง๋ ์ ํ๋ฌธ์ฅ๋ฑ์ ์ถ๋ ฅํ๋ผ.
|
312 |
-
3. ์์ฃผ์ ์ [๋ณธ๋ก ] 5๊ฐ์ ๋ด์ฉ์ด ๊ฐ๊ฐ 500์ ์ด์์ด ๋๋๋ก ์์ฑํ๋ผ.
|
313 |
-
4. ๋ฐ๋์ ๋๊ฐ ์์ฑํ ์ ์ฒด๊ธ์ด 2500์ ์ด์์ด ๋๋๋ก ์์ฑํ๋ผ.
|
314 |
-
5. ์ ์ฒด ๋งฅ๋ฝ์ ์ดํดํ๊ณ ๋ฌธ์ฅ์ ์ผ๊ด์ฑ์ ์ ์งํ๋ผ.
|
315 |
-
6. ์ฐธ๊ณ ๊ธ์ ๋ฐํ์ผ๋ก ์์ฑํ ๊ธ์ ๋ง๋ ๋๋ค์, ํ๋ฅด์๋๋ฅผ ์ ์ฉํ์ฌ ์์ฑํ๋ผ.
|
316 |
-
7. ์ดํฌ๋ ์ ๊ณต๋ ์ฐธ๊ณ ๊ธ์ ์ดํฌ๋ฅผ ๋ฐ์ํ๋, '๊ฑด๊ฐ, ์ํ ์ ๋ณด' ์ ๋ฌธ ๋ธ๋ก๊ทธ ๋ง์ผํฐ๋ก์ ์์ฑํ๋ผ.
|
317 |
-
8. ์ ๋๋ก ์ฐธ๊ณ ๊ธ์ ํ๋ฌธ์ฅ ์ด์ ๊ทธ๋๋ก ์ถ๋ ฅํ์ง ๋ง ๊ฒ.
|
318 |
-
9. ์ฃผ์ ์ ์ํฉ์ ๋ง๋ ์ ์ ํ ์ดํ๋ฅผ ์ ํํ๋ผ.
|
319 |
-
|
320 |
-
###[์ ๋ณด์ฑ ๋ธ๋ก๊ทธ ์์ฑ ๊ท์น]
|
321 |
-
1. ๋
์๊ฐ ์ป๊ณ ์ ํ๋ ์ ํํ ์ ๋ณด์ ๊ฑด๊ฐํ ์ํ์ ์ ์งํ๋ ๋ฐ ํ์ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋๋ก ์์ฃผ์ ์ ๋ง๊ฒ ๋ด์ฉ์ ์์ฑํ๋ผ.
|
322 |
-
2. ๋
์์ ๊ณต๊ฐ์ ์ด๋์ด๋ด๊ณ ๊ถ๊ธ์ฆ์ ํด๊ฒฐํ๋๋ก ์์ฑํ๋ผ.
|
323 |
-
3. ๋
์์ ๊ด์ฌ์ฌ๋ฅผ ์ถฉ์กฑ์ํค๋๋ก ์์ฑํ๋ผ.
|
324 |
-
4. ๋
์์๊ฒ ์ด๋์ด ๋๋ ์ ๋ณด๋ฅผ ์์ฑํ๋ผ.
|
325 |
-
|
326 |
-
##[์ ์ธ ๊ท์น]
|
327 |
-
1. ๋ฐ๋์ ์ฐธ๊ณ ๊ธ์ ๋งํฌ(URL)๋ ์ ์ธํ๋ผ.
|
328 |
-
2. ์ฐธ๊ณ ๊ธ์์ '๋งํฌ๋ฅผ ํ์ธํด์ฃผ์ธ์'์ ๊ฐ์ ๋งํฌ ์ด๋์ ๋ฌธ๊ตฌ๋ ์ ์ธํ๋ผ.
|
329 |
-
3. ์ฐธ๊ณ ๊ธ์ ์๋ ์์ฑ์, ํ์, ์ ํ๋ฒ, ๊ธฐ์(Writer, speaker, YouTuber, reporter)์ ์ด๋ฆ, ์ ์นญ, ๋๋ค์(Name, Nkickname)์ ๋ฐ๋์ ์ ์ธํ๋ผ.
|
330 |
"""
|
331 |
|
332 |
def get_style_prompt(style):
|
@@ -515,36 +410,19 @@ with gr.Blocks() as demo:
|
|
515 |
|
516 |
# ์ ๋ชฉ ์ถ์ฒ
|
517 |
gr.Markdown("### 4๋จ๊ณ : ์ ๋ชฉ ์ถ์ฒํ๊ธฐ")
|
518 |
-
|
519 |
-
with gr.Accordion("์ ๋ชฉ ์ค์ ", open=True):
|
520 |
-
title_system_message = gr.Textbox(label="์์คํ
๋ฉ์์ง", value=get_title_prompt("์ผ๋ฐ"), lines=15)
|
521 |
-
title_max_tokens = gr.Slider(label="Max Tokens", minimum=1000, maximum=8000, value=5000, step=1000)
|
522 |
-
title_temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.8, step=0.1)
|
523 |
-
title_top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
524 |
|
525 |
title_suggestions = gr.Textbox(label="์ ๋ชฉ ์ถ์ฒ", lines=10)
|
526 |
title_token_output = gr.Markdown(label="์ฌ์ฉ๋ ํ ํฐ ์")
|
527 |
|
528 |
# ์ ๋ชฉ ์ถ์ฒ ๋ฒํผ
|
529 |
title_btn = gr.Button("์ ๋ชฉ ์ถ์ฒํ๊ธฐ")
|
530 |
-
title_btn.click(fn=suggest_title, inputs=[category, style, topic, references1, references2, references3
|
531 |
|
532 |
blog_title = gr.Textbox(label="๋ธ๋ก๊ทธ ์ ๋ชฉ", placeholder="๋ธ๋ก๊ทธ ์ ๋ชฉ์ ์
๋ ฅํด์ฃผ์ธ์")
|
533 |
|
534 |
# ๋ธ๋ก๊ทธ ๊ธ ์์ฑ
|
535 |
gr.Markdown("### 5๋จ๊ณ : ๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ")
|
536 |
gr.HTML("<span style='color: grey;'>[๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์์๋ผ์ธ ์์ฑ ๋ฐ ๋ธ๋ก๊ทธ ๊ธ ์์ฑ์ด ์๋์ผ๋ก ์งํ๋ฉ๋๋ค.]</span>")
|
537 |
-
|
538 |
-
with gr.Accordion("๋ธ๋ก๊ทธ ๊ธ ์ค์ ", open=True):
|
539 |
-
outline_system_message = gr.Textbox(label="์์คํ
๋ฉ์์ง", value=get_outline_prompt("์ผ๋ฐ"), lines=20)
|
540 |
-
outline_max_tokens = gr.Slider(label="Max Tokens", minimum=1000, maximum=8000, value=6000, step=1000)
|
541 |
-
outline_temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.8, step=0.1)
|
542 |
-
outline_top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
543 |
-
|
544 |
-
blog_system_message = gr.Textbox(label="์์คํ
๋ฉ์์ง", value=get_blog_post_prompt("์ผ๋ฐ"), lines=20)
|
545 |
-
blog_max_tokens = gr.Slider(label="Max Tokens", minimum=1000, maximum=12000, value=8000, step=1000)
|
546 |
-
blog_temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.8, step=0.1)
|
547 |
-
blog_top_p = gr.Slider(label="Top P", minimum=0.1, maximum=1.0, value=0.95, step=0.05)
|
548 |
|
549 |
outline_result = gr.Textbox(label="์์๋ผ์ธ ๊ฒฐ๊ณผ", lines=15, visible=False)
|
550 |
outline_token_output = gr.Markdown(label="์ฌ์ฉ๋ ํ ํฐ ์", visible=False)
|
@@ -555,7 +433,7 @@ with gr.Blocks() as demo:
|
|
555 |
generate_post_btn = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ")
|
556 |
generate_post_btn.click(
|
557 |
fn=fetch_references_and_generate_all_steps,
|
558 |
-
inputs=[category, style, topic, blog_title
|
559 |
outputs=[references1, references2, references3, outline_result, outline_token_output, output, token_output]
|
560 |
)
|
561 |
|
@@ -564,7 +442,7 @@ with gr.Blocks() as demo:
|
|
564 |
|
565 |
save_pdf_btn.click(fn=save_content_to_pdf, inputs=[output], outputs=[pdf_output])
|
566 |
|
567 |
-
category.change(fn=update_prompts_and_description, inputs=category, outputs=[
|
568 |
-
style.change(fn=update_prompts_and_description, inputs=category, outputs=[
|
569 |
|
570 |
demo.launch()
|
|
|
116 |
def analyze_info(category, style, topic, references1, references2, references3):
|
117 |
return f"์ ํํ ์นดํ
๊ณ ๋ฆฌ: {category}\n์ ํํ ํฌ์คํ
์คํ์ผ: {style}\n๋ธ๋ก๊ทธ ์ฃผ์ : {topic}\n์ฐธ๊ณ ๊ธ1: {references1}\n์ฐธ๊ณ ๊ธ2: {references2}\n์ฐธ๊ณ ๊ธ3: {references3}"
|
118 |
|
119 |
+
def suggest_title(category, style, topic, references1, references2, references3):
|
120 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
121 |
+
category_prompt = get_title_prompt(category)
|
122 |
+
style_prompt = get_style_prompt(style)
|
123 |
+
max_tokens = 5000
|
124 |
+
temperature = 0.8
|
125 |
+
top_p = 0.95
|
126 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
127 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(full_content, combined_prompt, max_tokens, temperature, top_p)
|
128 |
token_usage_message = f"[์
๋ ฅ ํ ํฐ์: {input_tokens}]\n[์ถ๋ ฅ ํ ํฐ์: {output_tokens}]\n[์ด ํ ํฐ์: {total_tokens}]"
|
129 |
return modified_text, token_usage_message
|
130 |
|
131 |
+
def generate_outline(category, style, topic, references1, references2, references3, title):
|
132 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
133 |
content = f"{full_content}\nTitle: {title}"
|
134 |
+
category_prompt = get_outline_prompt(category)
|
135 |
+
style_prompt = get_style_prompt(style)
|
136 |
+
max_tokens = 6000
|
137 |
+
temperature = 0.8
|
138 |
+
top_p = 0.95
|
139 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
140 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
|
141 |
token_usage_message = f"[์
๋ ฅ ํ ํฐ์: {input_tokens}]\n[์ถ๋ ฅ ํ ํฐ์: {output_tokens}]\n[์ด ํ ํฐ์: {total_tokens}]"
|
142 |
return modified_text, token_usage_message
|
143 |
|
144 |
+
def generate_blog_post(category, style, topic, references1, references2, references3, title, outline):
|
145 |
full_content = analyze_info(category, style, topic, references1, references2, references3)
|
146 |
content = f"{full_content}\nTitle: {title}\nOutline: {outline}"
|
147 |
+
category_prompt = get_blog_post_prompt(category)
|
148 |
+
style_prompt = get_style_prompt(style)
|
149 |
+
max_tokens = 8000
|
150 |
+
temperature = 0.8
|
151 |
+
top_p = 0.95
|
152 |
combined_prompt = f"{category_prompt}\n\n{style_prompt}"
|
153 |
modified_text, input_tokens, output_tokens, total_tokens = call_api(content, combined_prompt, max_tokens, temperature, top_p)
|
154 |
formatted_text = modified_text.replace('\n', '\n\n')
|
|
|
171 |
|
172 |
return "์ฐธ๊ณ ๊ธ ์์ฑ ์๋ฃ", references1_content, references2_content, references3_content
|
173 |
|
174 |
+
def fetch_references_and_generate_all_steps(category, style, topic, blog_title):
|
175 |
search_url = generate_naver_search_url(topic)
|
176 |
session = setup_session()
|
177 |
if session is None:
|
|
|
187 |
references3_content = f"์ ๋ชฉ: {selected_results[2]['์ ๋ชฉ']}\n๋ด์ฉ: {crawl_blog_content(selected_results[2]['๋งํฌ'], session)}"
|
188 |
|
189 |
# ์์๋ผ์ธ ์์ฑ
|
190 |
+
outline_result, outline_token_usage = generate_outline(category, style, topic, references1_content, references2_content, references3_content, blog_title)
|
191 |
|
192 |
# ๋ธ๋ก๊ทธ ๊ธ ์์ฑ
|
193 |
+
blog_post_result, blog_post_token_usage = generate_blog_post(category, style, topic, references1_content, references2_content, references3_content, blog_title, outline_result)
|
194 |
|
195 |
return references1_content, references2_content, references3_content, outline_result, outline_token_usage, blog_post_result, blog_post_token_usage
|
196 |
|
|
|
198 |
if (category == "์ผ๋ฐ"):
|
199 |
return """
|
200 |
# ๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น(์ผ๋ฐ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
"""
|
202 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
203 |
return """
|
204 |
# ๋ธ๋ก๊ทธ ์ ๋ชฉ ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
"""
|
206 |
|
207 |
def get_outline_prompt(category):
|
208 |
if (category == "์ผ๋ฐ"):
|
209 |
return """
|
210 |
# ๋ธ๋ก๊ทธ ์์ฃผ์ (Subtopic) ์์ฑ ๊ท์น(์ผ๋ฐ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
"""
|
212 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
213 |
return """
|
214 |
# ๋ธ๋ก๊ทธ ์์ฃผ์ (Subtopic) ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
"""
|
216 |
|
217 |
def get_blog_post_prompt(category):
|
218 |
if (category == "์ผ๋ฐ"):
|
219 |
return """
|
220 |
# ๋ธ๋ก๊ทธ ํ
์คํธ ์์ฑ ๊ท์น(์ผ๋ฐ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
"""
|
222 |
elif (category == "๊ฑด๊ฐ์ ๋ณด"):
|
223 |
return """
|
224 |
# ๋ธ๋ก๊ทธ ํ
์คํธ ์์ฑ ๊ท์น(๊ฑด๊ฐ์ ๋ณด)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
"""
|
226 |
|
227 |
def get_style_prompt(style):
|
|
|
410 |
|
411 |
# ์ ๋ชฉ ์ถ์ฒ
|
412 |
gr.Markdown("### 4๋จ๊ณ : ์ ๋ชฉ ์ถ์ฒํ๊ธฐ")
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
|
414 |
title_suggestions = gr.Textbox(label="์ ๋ชฉ ์ถ์ฒ", lines=10)
|
415 |
title_token_output = gr.Markdown(label="์ฌ์ฉ๋ ํ ํฐ ์")
|
416 |
|
417 |
# ์ ๋ชฉ ์ถ์ฒ ๋ฒํผ
|
418 |
title_btn = gr.Button("์ ๋ชฉ ์ถ์ฒํ๊ธฐ")
|
419 |
+
title_btn.click(fn=suggest_title, inputs=[category, style, topic, references1, references2, references3], outputs=[title_suggestions, title_token_output])
|
420 |
|
421 |
blog_title = gr.Textbox(label="๋ธ๋ก๊ทธ ์ ๋ชฉ", placeholder="๋ธ๋ก๊ทธ ์ ๋ชฉ์ ์
๋ ฅํด์ฃผ์ธ์")
|
422 |
|
423 |
# ๋ธ๋ก๊ทธ ๊ธ ์์ฑ
|
424 |
gr.Markdown("### 5๋จ๊ณ : ๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ")
|
425 |
gr.HTML("<span style='color: grey;'>[๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์์๋ผ์ธ ์์ฑ ๋ฐ ๋ธ๋ก๊ทธ ๊ธ ์์ฑ์ด ์๋์ผ๋ก ์งํ๋ฉ๋๋ค.]</span>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
outline_result = gr.Textbox(label="์์๋ผ์ธ ๊ฒฐ๊ณผ", lines=15, visible=False)
|
428 |
outline_token_output = gr.Markdown(label="์ฌ์ฉ๋ ํ ํฐ ์", visible=False)
|
|
|
433 |
generate_post_btn = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑํ๊ธฐ")
|
434 |
generate_post_btn.click(
|
435 |
fn=fetch_references_and_generate_all_steps,
|
436 |
+
inputs=[category, style, topic, blog_title],
|
437 |
outputs=[references1, references2, references3, outline_result, outline_token_output, output, token_output]
|
438 |
)
|
439 |
|
|
|
442 |
|
443 |
save_pdf_btn.click(fn=save_content_to_pdf, inputs=[output], outputs=[pdf_output])
|
444 |
|
445 |
+
category.change(fn=update_prompts_and_description, inputs=category, outputs=[style_description])
|
446 |
+
style.change(fn=update_prompts_and_description, inputs=category, outputs=[style_description])
|
447 |
|
448 |
demo.launch()
|