JeCabrera commited on
Commit
76f72b6
·
verified ·
1 Parent(s): bf165e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -23
app.py CHANGED
@@ -258,34 +258,47 @@ with col2:
258
  # Get the response text
259
  response_text = response.text
260
 
261
- # Special processing for Oferta Dorada to remove any markdown or formatting that might cause the box
262
  if st.session_state.formula_type == "Oferta Dorada":
263
- # Remove any potential markdown formatting that might be causing the box
264
  response_text = response_text.replace("```", "").replace("`", "")
265
- # Remove any HTML tags that might be in the response
 
266
  response_text = response_text.replace("<div>", "").replace("</div>", "")
267
  response_text = response_text.replace("<p>", "").replace("</p>", "")
 
 
 
 
268
 
269
- # Natural integration of product name in Oferta Dorada
270
- if hasattr(st.session_state, 'product_service') and st.session_state.product_service:
271
- product_name = st.session_state.product_service
272
-
273
- # Split the text into lines to process each part of the formula
274
- lines = response_text.split('\n')
275
-
276
- # Process the promise (usually in the first few lines)
277
- for i in range(min(5, len(lines))):
278
- # If this line contains the promise, make product name uppercase
279
- if any(keyword in lines[i].lower() for keyword in ["promesa", "promise"]):
280
- lines[i] = lines[i].replace(product_name, product_name.upper())
281
-
282
- # Process the third line (if it exists) to remove quotes around product name
283
- if len(lines) > 3:
284
- lines[2] = lines[2].replace(f'"{product_name}"', product_name)
285
- lines[2] = lines[2].replace(f"'{product_name}'", product_name)
286
-
287
- # Rejoin the lines
288
- response_text = '\n'.join(lines)
 
 
 
 
 
 
 
 
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