Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,20 @@ 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, text_type, length,
|
12 |
model = genai.GenerativeModel(model_choice)
|
13 |
|
14 |
# Crear el prompt completo basado en los campos del frontend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
full_prompt = f"""
|
16 |
-
|
17 |
"""
|
18 |
|
19 |
response = model.generate_content([full_prompt])
|
@@ -63,7 +71,10 @@ with col1:
|
|
63 |
product = st.text_input("Producto:", placeholder="Especifica el producto aqu铆...")
|
64 |
text_type = st.selectbox("Tipo de texto:", ["Historia", "Shayari", "Sher", "Poema", "Cita"])
|
65 |
length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
|
66 |
-
|
|
|
|
|
|
|
67 |
mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
68 |
|
69 |
# Opci贸n para seleccionar el modelo
|
@@ -76,7 +87,7 @@ with col1:
|
|
76 |
if submit:
|
77 |
if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
|
78 |
try:
|
79 |
-
response = get_gemini_response(target_audience, product, text_type, length,
|
80 |
col2.subheader("Contenido generado:")
|
81 |
col2.write(response)
|
82 |
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, text_type, length, product_mention, mood, model_choice):
|
12 |
model = genai.GenerativeModel(model_choice)
|
13 |
|
14 |
# Crear el prompt completo basado en los campos del frontend
|
15 |
+
mention_instruction = ""
|
16 |
+
if product_mention == "Direct":
|
17 |
+
mention_instruction = f"Make sure to mention the product '{product}' directly in the text."
|
18 |
+
elif product_mention == "Subtle":
|
19 |
+
mention_instruction = f"Ensure that subtle and realistic references to the product '{product}' are included without explicitly mentioning it."
|
20 |
+
elif product_mention == "Metaphor":
|
21 |
+
mention_instruction = f"Refer to the product '{product}' through a metaphor, without mentioning it explicitly."
|
22 |
+
|
23 |
full_prompt = f"""
|
24 |
+
Eres un escritor creativo experto en el arte de la persuasi贸n. Escribe una {length} {text_type} en espa帽ol. El tono del {text_type} debe ser {mood} y estar dise帽ado espec铆ficamente para resonar emocionalmente con un p煤blico {target_audience}. {mention_instruction} Usa t茅cnicas persuasivas para guiar al lector hacia una comprensi贸n intuitiva de los beneficios del producto, enfoc谩ndote en crear una fuerte conexi贸n emocional con la audiencia.
|
25 |
"""
|
26 |
|
27 |
response = model.generate_content([full_prompt])
|
|
|
71 |
product = st.text_input("Producto:", placeholder="Especifica el producto aqu铆...")
|
72 |
text_type = st.selectbox("Tipo de texto:", ["Historia", "Shayari", "Sher", "Poema", "Cita"])
|
73 |
length = st.selectbox("Longitud del texto:", ["Corto", "Largo"])
|
74 |
+
|
75 |
+
# Nueva opci贸n para c贸mo se debe mencionar el producto
|
76 |
+
product_mention = st.selectbox("Menci贸n del producto:", ["Direct", "Subtle", "Metaphor"])
|
77 |
+
|
78 |
mood = st.selectbox("Tono del Texto:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
79 |
|
80 |
# Opci贸n para seleccionar el modelo
|
|
|
87 |
if submit:
|
88 |
if target_audience and product: # Verificar que se haya proporcionado el p煤blico objetivo y el producto
|
89 |
try:
|
90 |
+
response = get_gemini_response(target_audience, product, text_type, length, product_mention, mood, model_choice)
|
91 |
col2.subheader("Contenido generado:")
|
92 |
col2.write(response)
|
93 |
except ValueError as e:
|