JeCabrera commited on
Commit
a905d89
·
verified ·
1 Parent(s): a8bb96f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -265,6 +265,27 @@ with col2:
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
  st.session_state.offer_result = response_text
270
  st.session_state.generated = True # Mark as generated
 
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