Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -258,34 +258,47 @@ with col2:
|
|
| 258 |
# Get the response text
|
| 259 |
response_text = response.text
|
| 260 |
|
| 261 |
-
#
|
| 262 |
if st.session_state.formula_type == "Oferta Dorada":
|
| 263 |
-
#
|
| 264 |
response_text = response_text.replace("```", "").replace("`", "")
|
| 265 |
-
|
|
|
|
| 266 |
response_text = response_text.replace("<div>", "").replace("</div>", "")
|
| 267 |
response_text = response_text.replace("<p>", "").replace("</p>", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
-
#
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
st.session_state.offer_result = response_text
|
| 291 |
st.session_state.generated = True # Mark as generated
|
|
|
|
| 258 |
# Get the response text
|
| 259 |
response_text = response.text
|
| 260 |
|
| 261 |
+
# Cuando procesas la respuesta del modelo para la Oferta Dorada
|
| 262 |
if st.session_state.formula_type == "Oferta Dorada":
|
| 263 |
+
# Eliminar cualquier formato que pueda causar recuadros
|
| 264 |
response_text = response_text.replace("```", "").replace("`", "")
|
| 265 |
+
|
| 266 |
+
# Eliminar posibles etiquetas HTML
|
| 267 |
response_text = response_text.replace("<div>", "").replace("</div>", "")
|
| 268 |
response_text = response_text.replace("<p>", "").replace("</p>", "")
|
| 269 |
+
response_text = response_text.replace("<h1>", "").replace("</h1>", "")
|
| 270 |
+
response_text = response_text.replace("<h2>", "").replace("</h2>", "")
|
| 271 |
+
response_text = response_text.replace("<h3>", "").replace("</h3>", "")
|
| 272 |
+
response_text = response_text.replace("<strong>", "").replace("</strong>", "")
|
| 273 |
|
| 274 |
+
# Eliminar caracteres que puedan causar problemas de formato
|
| 275 |
+
response_text = response_text.replace("#", "")
|
| 276 |
+
response_text = response_text.replace("*", "")
|
| 277 |
+
|
| 278 |
+
# Asegurarse de que no haya líneas en blanco extras que puedan afectar el formato
|
| 279 |
+
lines = [line for line in response_text.split('\n') if line.strip()]
|
| 280 |
+
response_text = '\n\n'.join(lines)
|
| 281 |
+
|
| 282 |
+
# Natural integration of product name in Oferta Dorada
|
| 283 |
+
if hasattr(st.session_state, 'product_service') and st.session_state.product_service:
|
| 284 |
+
product_name = st.session_state.product_service
|
| 285 |
+
|
| 286 |
+
# Split the text into lines to process each part of the formula
|
| 287 |
+
lines = response_text.split('\n')
|
| 288 |
+
|
| 289 |
+
# Process the promise (usually in the first few lines)
|
| 290 |
+
for i in range(min(5, len(lines))):
|
| 291 |
+
# If this line contains the promise, make product name uppercase
|
| 292 |
+
if any(keyword in lines[i].lower() for keyword in ["promesa", "promise"]):
|
| 293 |
+
lines[i] = lines[i].replace(product_name, product_name.upper())
|
| 294 |
+
|
| 295 |
+
# Process the third line (if it exists) to remove quotes around product name
|
| 296 |
+
if len(lines) > 3:
|
| 297 |
+
lines[2] = lines[2].replace(f'"{product_name}"', product_name)
|
| 298 |
+
lines[2] = lines[2].replace(f"'{product_name}'", product_name)
|
| 299 |
+
|
| 300 |
+
# Rejoin the lines
|
| 301 |
+
response_text = '\n'.join(lines)
|
| 302 |
|
| 303 |
st.session_state.offer_result = response_text
|
| 304 |
st.session_state.generated = True # Mark as generated
|