JeCabrera commited on
Commit
63a0e26
verified
1 Parent(s): 99036c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -16
app.py CHANGED
@@ -200,23 +200,39 @@ with col2:
200
  # Usar la funci贸n actualizada
201
  # In the generate_offer function or wherever the error is occurring
202
  # The function definition needs proper indentation for its body
 
203
  def generate_offer():
204
- # Properly indented function body
205
- selected_formula_name = st.session_state.formula_type
206
-
207
- instruction = create_offer_instruction(
208
- avatar_description=target_audience,
209
- product_name=product_service,
210
- selected_formula_name=selected_formula_name,
211
- offer_formulas=offer_formulas
212
- )
213
-
214
- # Add the rest of your function implementation here
215
- response = model.generate_content(instruction)
216
- offer_result = response.text
217
-
218
- st.session_state.offer_result = offer_result
219
- st.session_state.generated = True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
  # Add additional context based on input type
222
  if st.session_state.input_type == "manual":
 
200
  # Usar la funci贸n actualizada
201
  # In the generate_offer function or wherever the error is occurring
202
  # The function definition needs proper indentation for its body
203
+ # Where you're generating the offer
204
  def generate_offer():
205
+ # Get necessary variables
206
+ selected_formula_name = st.session_state.formula_type
207
+ avatar_description = st.session_state.target_audience
208
+ product_name = st.session_state.product_service
209
+
210
+ # Create the base instruction
211
+ instruction = create_offer_instruction(
212
+ avatar_description=avatar_description,
213
+ product_name=product_name,
214
+ selected_formula_name=selected_formula_name,
215
+ offer_formulas=offer_formulas
216
+ )
217
+
218
+ # If you have additional context to add
219
+ additional_context = ""
220
+
221
+ # Add file content if available
222
+ if st.session_state.input_type in ["file", "both"]:
223
+ additional_context = f"\n\nAdditional context from uploaded file:\n{st.session_state.file_content}"
224
+
225
+ # Now add the additional context to the instruction
226
+ if additional_context:
227
+ instruction += additional_context
228
+
229
+ # Generate the response
230
+ response = model.generate_content(instruction)
231
+ offer_result = response.text
232
+
233
+ # Update session state
234
+ st.session_state.offer_result = offer_result
235
+ st.session_state.generated = True
236
 
237
  # Add additional context based on input type
238
  if st.session_state.input_type == "manual":