JeCabrera commited on
Commit
5d59b46
·
verified ·
1 Parent(s): eb66a37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -193,6 +193,9 @@ with col2:
193
  with st.spinner('Creando tu oferta perfecta...'):
194
  # Use the create_offer_instruction function to generate the prompt
195
  avatar_description = st.session_state.target_audience if hasattr(st.session_state, 'target_audience') and st.session_state.target_audience else 'General audience'
 
 
 
196
 
197
  # Preparar el contenido del archivo si existe
198
  file_content = ""
@@ -201,10 +204,10 @@ with col2:
201
 
202
  # Get the instruction using the formula
203
  instruction = create_offer_instruction(
204
- target_audience=avatar_description, # Cambiado de avatar_description a target_audience
205
- product_service=product_service,
206
  selected_formula_name=st.session_state.formula_type,
207
- file_content=file_content # Añadido el contenido del archivo
208
  )
209
 
210
  # Add instruction for generating benefit bullets based on the promise
@@ -214,14 +217,14 @@ with col2:
214
 
215
  instruction += create_bullet_instruction(
216
  avatar_description=avatar_description,
217
- product_name=product_name,
218
  uploaded_content=bullet_content
219
  )
220
 
221
  # Add instruction for generating bonuses that complement the offer
222
  instruction += create_bonus_instruction(
223
  avatar_description=avatar_description,
224
- product_name=product_name,
225
  selected_formula_name=st.session_state.formula_type
226
  )
227
 
@@ -258,7 +261,7 @@ with col2:
258
 
259
  # Natural integration of product name in the response
260
  if hasattr(st.session_state, 'product_service') and st.session_state.product_service:
261
- product_name = st.session_state.product_service
262
 
263
  # Split the text into lines to process each part of the formula
264
  lines = response_text.split('\n')
@@ -270,14 +273,14 @@ with col2:
270
  lines[i] = lines[i].upper()
271
 
272
  # Remove quotes around product name in all lines
273
- lines[i] = lines[i].replace(f'"{product_name}"', product_name)
274
- lines[i] = lines[i].replace(f"'{product_name}'", product_name)
275
 
276
  # Ensure product name is properly capitalized in benefit descriptions
277
- if i >= 2 and "sistema" in lines[i].lower() and product_name.lower() not in lines[i].lower():
278
- lines[i] = lines[i].replace("sistema", product_name, 1)
279
- if i >= 2 and "método" in lines[i].lower() and product_name.lower() not in lines[i].lower():
280
- lines[i] = lines[i].replace("método", product_name, 1)
281
 
282
  # Rejoin the lines
283
  response_text = '\n'.join(lines)
 
193
  with st.spinner('Creando tu oferta perfecta...'):
194
  # Use the create_offer_instruction function to generate the prompt
195
  avatar_description = st.session_state.target_audience if hasattr(st.session_state, 'target_audience') and st.session_state.target_audience else 'General audience'
196
+
197
+ # Get product_service from session state or use the current value
198
+ product_service_value = st.session_state.product_service if hasattr(st.session_state, 'product_service') and st.session_state.product_service else product_service
199
 
200
  # Preparar el contenido del archivo si existe
201
  file_content = ""
 
204
 
205
  # Get the instruction using the formula
206
  instruction = create_offer_instruction(
207
+ target_audience=avatar_description,
208
+ product_name=product_service_value, # Using product_service_value but with parameter name product_name
209
  selected_formula_name=st.session_state.formula_type,
210
+ file_content=file_content
211
  )
212
 
213
  # Add instruction for generating benefit bullets based on the promise
 
217
 
218
  instruction += create_bullet_instruction(
219
  avatar_description=avatar_description,
220
+ product_name=product_service_value, # Using product_service_value
221
  uploaded_content=bullet_content
222
  )
223
 
224
  # Add instruction for generating bonuses that complement the offer
225
  instruction += create_bonus_instruction(
226
  avatar_description=avatar_description,
227
+ product_name=product_service_value, # Using product_service_value
228
  selected_formula_name=st.session_state.formula_type
229
  )
230
 
 
261
 
262
  # Natural integration of product name in the response
263
  if hasattr(st.session_state, 'product_service') and st.session_state.product_service:
264
+ product_service_value = st.session_state.product_service
265
 
266
  # Split the text into lines to process each part of the formula
267
  lines = response_text.split('\n')
 
273
  lines[i] = lines[i].upper()
274
 
275
  # Remove quotes around product name in all lines
276
+ lines[i] = lines[i].replace(f'"{product_service_value}"', product_service_value)
277
+ lines[i] = lines[i].replace(f"'{product_service_value}'", product_service_value)
278
 
279
  # Ensure product name is properly capitalized in benefit descriptions
280
+ if i >= 2 and "sistema" in lines[i].lower() and product_service_value.lower() not in lines[i].lower():
281
+ lines[i] = lines[i].replace("sistema", product_service_value, 1)
282
+ if i >= 2 and "método" in lines[i].lower() and product_service_value.lower() not in lines[i].lower():
283
+ lines[i] = lines[i].replace("método", product_service_value, 1)
284
 
285
  # Rejoin the lines
286
  response_text = '\n'.join(lines)