Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,24 +10,31 @@ load_dotenv()
|
|
10 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
11 |
|
12 |
# Función para obtener la respuesta del modelo Gemini
|
13 |
-
def get_gemini_response(input_prompt, genre, length, language, mood, target_audience,
|
14 |
if not input_prompt:
|
15 |
return "Por favor, escribe un mensaje para generar contenido."
|
16 |
|
17 |
model = genai.GenerativeModel('gemini-2.0-flash')
|
18 |
full_prompt = f"""
|
19 |
-
You are a professional storyteller. Write a {mood} {genre} in {language} using a natural, engaging, and conversational style.
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
The story should be about "{input_prompt}". Ensure the topic is naturally integrated into the narrative.
|
30 |
-
|
31 |
### **Ejemplo de historia bien escrita:**
|
32 |
En una lejana galaxia, el maestro Xylo dictaba clases en la Tierra.
|
33 |
|
@@ -48,7 +55,6 @@ def get_gemini_response(input_prompt, genre, length, language, mood, target_audi
|
|
48 |
Inscríbete hoy aquí.
|
49 |
|
50 |
**Importante:**
|
51 |
-
- **No menciones directamente {product_type} en el texto**. En su lugar, intégralo de forma sutil y natural en la narrativa.
|
52 |
- **Haz que la historia sea humana y emocional**, evitando frases promocionales evidentes.
|
53 |
"""
|
54 |
response = model.generate_content([full_prompt])
|
@@ -74,7 +80,16 @@ with col1:
|
|
74 |
|
75 |
# Campos de texto libre
|
76 |
target_audience = st.text_input("Público Objetivo:", placeholder="Ejemplo: Profesionales de 25-35 años interesados en tecnología...")
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# Opciones avanzadas en acordeón
|
80 |
with st.expander("Opciones avanzadas"):
|
@@ -90,8 +105,8 @@ with col1:
|
|
90 |
with col2:
|
91 |
if generate_button:
|
92 |
response = get_gemini_response(
|
93 |
-
input_prompt, genre, length, language,
|
94 |
-
mood, target_audience,
|
95 |
)
|
96 |
st.subheader("Contenido generado:")
|
97 |
st.write(response)
|
|
|
10 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
11 |
|
12 |
# Función para obtener la respuesta del modelo Gemini
|
13 |
+
def get_gemini_response(input_prompt, genre, length, language, mood, target_audience, cta_type, benefit):
|
14 |
if not input_prompt:
|
15 |
return "Por favor, escribe un mensaje para generar contenido."
|
16 |
|
17 |
model = genai.GenerativeModel('gemini-2.0-flash')
|
18 |
full_prompt = f"""
|
19 |
+
You are a professional storyteller. Write a {mood} {genre} in {language} using a natural, engaging, and conversational style.
|
20 |
+
The story should be about "{input_prompt}" and use exactly {length} words.
|
21 |
+
|
22 |
+
Target Audience: {target_audience}
|
23 |
+
CTA Type: {cta_type}
|
24 |
+
Main Benefit: {benefit}
|
25 |
+
|
26 |
+
Structure:
|
27 |
+
1. Introduce a relatable problem that captures the audience's attention
|
28 |
+
2. Develop the story with natural narrative and emotional connection
|
29 |
+
3. Show consequences of inaction
|
30 |
+
4. Present the solution organically
|
31 |
+
5. Close with a specific call to action based on the type:
|
32 |
+
- For product purchase: Mention how the product helps achieve {benefit}
|
33 |
+
- For PDF guide: Highlight how the guide provides steps to {benefit}
|
34 |
+
- For webinar: Emphasize how attending will teach them to {benefit}
|
35 |
+
|
36 |
+
Make the CTA feel natural and focus on the value for the reader.
|
37 |
|
|
|
|
|
38 |
### **Ejemplo de historia bien escrita:**
|
39 |
En una lejana galaxia, el maestro Xylo dictaba clases en la Tierra.
|
40 |
|
|
|
55 |
Inscríbete hoy aquí.
|
56 |
|
57 |
**Importante:**
|
|
|
58 |
- **Haz que la historia sea humana y emocional**, evitando frases promocionales evidentes.
|
59 |
"""
|
60 |
response = model.generate_content([full_prompt])
|
|
|
80 |
|
81 |
# Campos de texto libre
|
82 |
target_audience = st.text_input("Público Objetivo:", placeholder="Ejemplo: Profesionales de 25-35 años interesados en tecnología...")
|
83 |
+
|
84 |
+
# Replace product_type with CTA type
|
85 |
+
cta_type = st.selectbox("Tipo de llamado a la acción:", [
|
86 |
+
"Comprar producto",
|
87 |
+
"Descargar guía PDF",
|
88 |
+
"Asistir a webinar"
|
89 |
+
])
|
90 |
+
|
91 |
+
# Add benefit input
|
92 |
+
benefit = st.text_input("Beneficio principal:", placeholder="Ejemplo: Aumentar ventas en 30 días, Aprender técnicas avanzadas...")
|
93 |
|
94 |
# Opciones avanzadas en acordeón
|
95 |
with st.expander("Opciones avanzadas"):
|
|
|
105 |
with col2:
|
106 |
if generate_button:
|
107 |
response = get_gemini_response(
|
108 |
+
input_prompt, genre, length, language,
|
109 |
+
mood, target_audience, cta_type, benefit
|
110 |
)
|
111 |
st.subheader("Contenido generado:")
|
112 |
st.write(response)
|