Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ load_dotenv()
|
|
| 8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 9 |
|
| 10 |
# Funci贸n para obtener respuesta del modelo Gemini
|
| 11 |
-
def get_gemini_response(target_audience, product, product_mention,
|
| 12 |
model = genai.GenerativeModel(model_choice)
|
| 13 |
|
| 14 |
# Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
|
|
@@ -20,20 +20,15 @@ def get_gemini_response(target_audience, product, product_mention, text_type, le
|
|
| 20 |
elif product_mention == "Metaf贸rica":
|
| 21 |
mention_instruction = f"Refer to the product '{product}' through a metaphor without explicitly mentioning it."
|
| 22 |
|
| 23 |
-
# Instrucci贸n espec铆fica para el tipo de texto
|
| 24 |
-
format_instruction = ""
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
format_instruction = "Craft a compelling sales pitch that highlights the product's benefits and persuades the reader to take action."
|
| 29 |
-
elif text_type == "Correo":
|
| 30 |
-
format_instruction = "Write a concise and engaging email that captures the reader's attention and encourages a response."
|
| 31 |
-
elif text_type == "Landing page":
|
| 32 |
-
format_instruction = "Design an informative and persuasive landing page that effectively showcases the product and drives conversions."
|
| 33 |
|
| 34 |
# Crear el prompt completo basado en los campos del frontend
|
| 35 |
full_prompt = f"""
|
| 36 |
-
You are a creative writer skilled in the art of persuasion. Write a {length}
|
| 37 |
"""
|
| 38 |
|
| 39 |
response = model.generate_content([full_prompt])
|
|
@@ -87,9 +82,7 @@ with col1:
|
|
| 87 |
# Variable para c贸mo se debe mencionar el producto
|
| 88 |
product_mention = st.selectbox("Menci贸n del producto:", ["Directa", "Indirecta", "Metaf贸rica"])
|
| 89 |
|
| 90 |
-
#
|
| 91 |
-
text_type = st.selectbox("Tipo de texto:", ["Historia", "Carta de venta", "Correo", "Landing page"])
|
| 92 |
-
length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
|
| 93 |
mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
| 94 |
|
| 95 |
# Opci贸n para seleccionar el modelo
|
|
@@ -102,7 +95,7 @@ with col1:
|
|
| 102 |
if submit:
|
| 103 |
if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
|
| 104 |
try:
|
| 105 |
-
response = get_gemini_response(target_audience, product, product_mention,
|
| 106 |
col2.subheader("Contenido generado:")
|
| 107 |
col2.write(response)
|
| 108 |
except ValueError as e:
|
|
|
|
| 8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 9 |
|
| 10 |
# Funci贸n para obtener respuesta del modelo Gemini
|
| 11 |
+
def get_gemini_response(target_audience, product, product_mention, mood, model_choice):
|
| 12 |
model = genai.GenerativeModel(model_choice)
|
| 13 |
|
| 14 |
# Crear la instrucci贸n de menci贸n basada en la opci贸n seleccionada
|
|
|
|
| 20 |
elif product_mention == "Metaf贸rica":
|
| 21 |
mention_instruction = f"Refer to the product '{product}' through a metaphor without explicitly mentioning it."
|
| 22 |
|
| 23 |
+
# Instrucci贸n espec铆fica para el tipo de texto (siempre ser谩 "Historia")
|
| 24 |
+
format_instruction = "Ensure that the narrative is engaging and includes character development, a clear plot, and a resolution."
|
| 25 |
+
|
| 26 |
+
# Longitud del texto (siempre ser谩 "Corto")
|
| 27 |
+
length = "Corto"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Crear el prompt completo basado en los campos del frontend
|
| 30 |
full_prompt = f"""
|
| 31 |
+
You are a creative writer skilled in the art of persuasion. Write a {length} Historia in Spanish. The tone of the Historia should be {mood} and carefully crafted to emotionally resonate with a {target_audience}. {mention_instruction} {format_instruction} Use persuasive techniques to guide the reader towards an intuitive understanding of the product's benefits, focusing on creating a strong emotional connection with the audience.
|
| 32 |
"""
|
| 33 |
|
| 34 |
response = model.generate_content([full_prompt])
|
|
|
|
| 82 |
# Variable para c贸mo se debe mencionar el producto
|
| 83 |
product_mention = st.selectbox("Menci贸n del producto:", ["Directa", "Indirecta", "Metaf贸rica"])
|
| 84 |
|
| 85 |
+
# Eliminar la opci贸n de tipo de texto y longitud del texto
|
|
|
|
|
|
|
| 86 |
mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
| 87 |
|
| 88 |
# Opci贸n para seleccionar el modelo
|
|
|
|
| 95 |
if submit:
|
| 96 |
if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
|
| 97 |
try:
|
| 98 |
+
response = get_gemini_response(target_audience, product, product_mention, mood, model_choice)
|
| 99 |
col2.subheader("Contenido generado:")
|
| 100 |
col2.write(response)
|
| 101 |
except ValueError as e:
|