Spaces:
Sleeping
Sleeping
Update app.py
Browse files64 unmodified lines656667686970717273747576777879808182838485868788899046 unmodified lines13713813914014114214314464 unmodified linesmodel_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizandogeneration_config=generation_config, # Configuración de generaciónsystem_instruction=(f"Eres un experto copywriter especializado en escribir bullets que resuelven los problemas de {target_audience}. ""Tu tarea es crear bullets creativos y persuasivos que capturen la atención de {target_audience}. ""Usa estos ejemplos como inspiración: {', '.join(selected_bullets)}."))# Crear un mensaje para el modelo que incluye los bullets generados según los tipos seleccionadosbullets_instruction = (f"Tu tarea es crear {num_bullets} bullets que denoten los beneficios que resolverán los problemas de {target_audience}. ""Asegúrate de que cada bullet sea atractivo y siga el estilo conversacional.")# Generar el resultado utilizando el modelo con la instrucción de bullet específicatry:response = model.generate_content([bullets_instruction])# Extraer solo el texto de la respuestagenerated_bullets = response.candidates[0].content.parts[0].textreturn generated_bulletsexcept Exception as e:raise ValueError("Error generando el contenido: " + str(e))# Inicializar la aplicación Streamlitst.set_page_config(page_title="Generador de Bullets", layout="wide")46 unmodified linestry:# Obtener la respuesta del modelogenerated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, temperature)# Limpiar el texto para eliminar caracteres extrañosgenerated_bullets = generated_bullets.replace("\n", "<br>") # Para formatear en HTMLcol2.markdown(f"""<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;"><h4>🧙🏻♂️ Mira la magia en acción:</h4>64 unmodified lines656667686970717273747576777879808182838485868788899091929394959697989910046 unmodified lines14714814915015115264 unmodified linesmodel_name="gemini-1.5-flash", # Nombre del modelo que estamos utilizandogeneration_config=generation_config, # Configuración de generaciónsystem_instruction=(f"You are a world-class copywriter, expert in creating bullets that connect symptoms with problems of {target_audience}. "f"You deeply understand the emotions, desires, and challenges of {target_audience}, allowing you to design personalized bullets that resonate and motivate action. ""Generate unusual, creative, and fascinating bullets that capture {target_audience}'s attention. Respond in Spanish and use a numbered list format. "f"When responding, always include a heading referencing {target_audience} as follows: 'Aquí hay {num_bullets} bullets para convencer a {target_audience}.'"))# Crear la instrucción para generar bulletschat_session = model.start_chat(history=[{"role": "user","parts": [f"Tu tarea es escribir {num_bullets} bullets que denoten los beneficios al hablar de {product} que resolverán los problemas de {target_audience}. ""Un buen bullet conecta los síntomas con los problemas enfrentados por {target_audience} de una manera natural, que no se note como manipuladora. "f"Escribe bullets creativos, en un estilo conversacional, que no sean aburridos, sino más bien divertidos. "f"Sé sutil a la hora de crear los bullets para referirte a los beneficios de tu {product}. ""Por favor, crea los bullets ahora."],},])# Crear un mensaje para el modelo que incluye los bullets generadosresponse = model.generate_content(chat_session.history)if response and response.parts:return response.parts[0].textelse:raise ValueError("Lo sentimos, intenta con una combinación diferente de entradas.")# Inicializar la aplicación Streamlitst.set_page_config(page_title="Generador de Bullets", layout="wide")46 unmodified linestry:# Obtener la respuesta del modelogenerated_bullets = get_gemini_response_bullets(target_audience, product, num_bullets, temperature)col2.markdown(f"""<div style="border: 1px solid #000000; padding: 5px; border-radius: 8px; background-color: #ffffff;"><h4>🧙🏻♂️ Mira la magia en acción:</h4>
app.py+25-17