Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -201,23 +201,23 @@ with col2:
|
|
201 |
else:
|
202 |
product_name = "Producto/Servicio"
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
|
222 |
# Add instruction for generating bonuses that complement the offer
|
223 |
instruction += create_bonus_instruction(
|
@@ -227,47 +227,47 @@ with col2:
|
|
227 |
)
|
228 |
|
229 |
# Add additional context based on input type
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
|
272 |
except Exception as e:
|
273 |
st.error(f'Ocurri贸 un error: {str(e)}')
|
|
|
201 |
else:
|
202 |
product_name = "Producto/Servicio"
|
203 |
|
204 |
+
# Get the instruction using the formula
|
205 |
+
instruction = create_offer_instruction(
|
206 |
+
avatar_description=avatar_description,
|
207 |
+
product_name=product_name,
|
208 |
+
selected_formula_name=st.session_state.formula_type
|
209 |
+
)
|
210 |
|
211 |
+
# Add instruction for generating benefit bullets based on the promise
|
212 |
+
bullet_content = None
|
213 |
+
if hasattr(st.session_state, 'file_content') and st.session_state.input_type in ["file", "both"]:
|
214 |
+
bullet_content = st.session_state.file_content
|
215 |
|
216 |
+
instruction += create_bullet_instruction(
|
217 |
+
avatar_description=avatar_description,
|
218 |
+
product_name=product_name,
|
219 |
+
uploaded_content=bullet_content
|
220 |
+
)
|
221 |
|
222 |
# Add instruction for generating bonuses that complement the offer
|
223 |
instruction += create_bonus_instruction(
|
|
|
227 |
)
|
228 |
|
229 |
# Add additional context based on input type
|
230 |
+
if st.session_state.input_type == "manual":
|
231 |
+
additional_context = f"""
|
232 |
+
Additional information:
|
233 |
+
Skills: {st.session_state.skills}
|
234 |
+
"""
|
235 |
+
instruction += additional_context
|
236 |
+
elif st.session_state.input_type == "file":
|
237 |
+
additional_context = f"""
|
238 |
+
Additional information from file:
|
239 |
+
{st.session_state.file_content}
|
240 |
+
"""
|
241 |
+
instruction += additional_context
|
242 |
+
elif st.session_state.input_type == "both":
|
243 |
+
additional_context = f"""
|
244 |
+
Additional information:
|
245 |
+
Skills: {st.session_state.skills}
|
246 |
+
File content: {st.session_state.file_content}
|
247 |
+
"""
|
248 |
+
instruction += additional_context
|
249 |
+
|
250 |
+
try:
|
251 |
+
generation_config = genai.GenerationConfig(temperature=st.session_state.temperature)
|
252 |
+
|
253 |
+
if "image" in st.session_state.input_type:
|
254 |
+
response = model.generate_content([instruction, st.session_state.image_parts[0]], generation_config=generation_config)
|
255 |
+
else:
|
256 |
+
response = model.generate_content(instruction, generation_config=generation_config)
|
257 |
+
|
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 |
+
st.session_state.offer_result = response_text
|
270 |
+
st.session_state.generated = True # Mark as generated
|
271 |
|
272 |
except Exception as e:
|
273 |
st.error(f'Ocurri贸 un error: {str(e)}')
|