Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -132,7 +132,7 @@ def generate_blog_post(query, prompt_template):
|
|
132 |
try:
|
133 |
# λͺ©ν κΈμμ μ€μ (λ¬Έμ μ)
|
134 |
target_char_length = 2000
|
135 |
-
max_attempts = 2 # μ΅λ μλ νμ
|
136 |
|
137 |
# μ°Έκ³ κΈ κ°μ Έμ€κΈ°
|
138 |
references = fetch_references(query)
|
@@ -159,15 +159,17 @@ def generate_blog_post(query, prompt_template):
|
|
159 |
'μμ½'
|
160 |
]
|
161 |
|
162 |
-
# λΆνμν
|
163 |
def remove_unwanted_phrases(text):
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
171 |
|
172 |
# μ΄κΈ° ν둬ννΈ κ΅¬μ±
|
173 |
base_prompt = prompt_template + f"""
|
@@ -182,10 +184,10 @@ def generate_blog_post(query, prompt_template):
|
|
182 |
# 첫 λ²μ§Έ μλ μ΄νμλ ν둬ννΈμ μΆκ° μ§μΉ¨μ ν¬ν¨
|
183 |
if attempt > 0:
|
184 |
additional_instructions = f"""
|
185 |
-
1. μμ±λ κΈμ κΈΈμ΄κ° λͺ©ν κΈμμμ
|
186 |
-
2. μ€λ³΅λλ λ΄μ©μ νΌνκ³ μλ‘μ΄ μ 보λ₯Ό
|
187 |
-
3. λ°λμ λ§ν¬λ€μ΄ νμμ΄ μλ μμν ν
μ€νΈλ‘λ§
|
188 |
-
4. λ°λμ μ΄ ννλ€μ
|
189 |
"""
|
190 |
else:
|
191 |
additional_instructions = ""
|
|
|
132 |
try:
|
133 |
# λͺ©ν κΈμμ μ€μ (λ¬Έμ μ)
|
134 |
target_char_length = 2000
|
135 |
+
max_attempts = 2 # μ΅λ μλ νμ
|
136 |
|
137 |
# μ°Έκ³ κΈ κ°μ Έμ€κΈ°
|
138 |
references = fetch_references(query)
|
|
|
159 |
'μμ½'
|
160 |
]
|
161 |
|
162 |
+
# λΆνμν ννμ΄ ν¬ν¨λ λ¨μ΄ μ 체λ₯Ό μ κ±°νλ ν¨μ
|
163 |
def remove_unwanted_phrases(text):
|
164 |
+
# λ¨μ΄ λ¨μλ‘ ν
μ€νΈλ₯Ό λΆν
|
165 |
+
words = re.findall(r'\S+|\n', text)
|
166 |
+
result_words = []
|
167 |
+
for word in words:
|
168 |
+
# λΆνμν ννμ΄ λ¨μ΄μ ν¬ν¨λμ΄ μλμ§ νμΈ
|
169 |
+
if not any(phrase in word for phrase in unwanted_phrases):
|
170 |
+
result_words.append(word)
|
171 |
+
# λ¨μ΄λ€μ λ€μ μ‘°ν©νμ¬ κ²°κ³Ό ν
μ€νΈ μμ±
|
172 |
+
return ' '.join(result_words).replace(' \n ', '\n').replace(' \n', '\n').replace('\n ', '\n')
|
173 |
|
174 |
# μ΄κΈ° ν둬ννΈ κ΅¬μ±
|
175 |
base_prompt = prompt_template + f"""
|
|
|
184 |
# 첫 λ²μ§Έ μλ μ΄νμλ ν둬ννΈμ μΆκ° μ§μΉ¨μ ν¬ν¨
|
185 |
if attempt > 0:
|
186 |
additional_instructions = f"""
|
187 |
+
1. μμ±λ κΈμ κΈΈμ΄κ° λͺ©ν κΈμμμ λ―Έλ¬μ
λλ€. λ΄μ©μ μ§μ μ μ§νκ³ λμ± νλΆνκ² μμ±νκ³ , μΈλΆμ¬νμ μΆκ°νμ¬ μμ°μ€λ½κ² νμ₯νμΈμ.
|
188 |
+
2. μ€λ³΅λλ λ΄μ©μ νΌνκ³ μλ‘μ΄ μ 보λ₯Ό μΆκ°νμΈμ.
|
189 |
+
3. λ°λμ λ§ν¬λ€μ΄ νμμ΄ μλ μμν ν
μ€νΈλ‘λ§ μΆλ ₯νμΈμ.
|
190 |
+
4. λ°λμ μ΄ ννλ€μ μ¬μ©νμ§ λ§μΈμ: μ¬λ¬λΆ, μ΅κ·Ό, λ§μ§λ§μΌλ‘, κ²°λ‘ μ μΌλ‘, κ²°κ΅, μ’
ν©μ μΌλ‘, λ°λΌμ, λ§λ¬΄λ¦¬, μμ½.
|
191 |
"""
|
192 |
else:
|
193 |
additional_instructions = ""
|