Spaces:
Running
Running
Upload 11 files
Browse files- ad_objectives.py +43 -43
- app.py +7 -6
- prompts.py +35 -1
ad_objectives.py
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
ad_objectives = {
|
2 |
-
"Ninguno": {
|
3 |
-
"name": "Ninguno",
|
4 |
-
"description": "No specific campaign objective",
|
5 |
-
"key_metrics": ["General metrics"],
|
6 |
-
"copy_strategy": "Create a balanced ad without focus on specific metrics"
|
7 |
-
},
|
8 |
-
"Reconocimiento": {
|
9 |
-
"name": "Reconocimiento",
|
10 |
-
"description": "Increase your brand visibility and reach people more likely to remember it",
|
11 |
-
"key_metrics": ["Reach", "Impressions", "Ad recall lift", "Video plays"],
|
12 |
-
"copy_strategy": "Use memorable messages that highlight brand identity, create content with visual and emotional impact, and emphasize what makes the brand unique"
|
13 |
-
},
|
14 |
-
"Tráfico": {
|
15 |
-
"name": "Tráfico",
|
16 |
-
"description": "Direct people to a specific destination such as website, Facebook page, Instagram store or app",
|
17 |
-
"key_metrics": ["Link clicks", "Page views", "Daily unique reach", "Impressions"],
|
18 |
-
"copy_strategy": "Include clear and direct CTAs, create urgency to visit the destination, highlight the value they'll find when clicking, and use language that invites immediate action"
|
19 |
-
},
|
20 |
-
"Interacción": {
|
21 |
-
"name": "Interacción",
|
22 |
-
"description": "Promote interactions with your page, posts, videos or start conversations in Messenger",
|
23 |
-
"key_metrics": ["Page interactions", "Post interactions", "Video plays", "Messages"],
|
24 |
-
"copy_strategy": "Ask intriguing questions, invite people to share opinions, create content that generates discussion, and use a conversational tone that encourages participation"
|
25 |
-
},
|
26 |
-
"Clientes potenciales": {
|
27 |
-
"name": "Clientes potenciales",
|
28 |
-
"description": "Collect contact information from people interested in your business through forms",
|
29 |
-
"key_metrics": ["Lead generation", "Messages", "Conversions", "Cost per lead"],
|
30 |
-
"copy_strategy": "Offer clear value in exchange for contact information, highlight exclusive benefits, minimize risk perception, and create a sense of limited opportunity"
|
31 |
-
},
|
32 |
-
"Promoción de la app": {
|
33 |
-
"name": "Promoción de la app",
|
34 |
-
"description": "Increase installations and specific actions within your mobile application",
|
35 |
-
"key_metrics": ["App installations", "App actions", "Cost per installation"],
|
36 |
-
"copy_strategy": "Highlight the app's unique features, emphasize ease of use, show attractive screenshots, and clearly communicate the problem the app solves"
|
37 |
-
},
|
38 |
-
"Ventas": {
|
39 |
-
"name": "Ventas",
|
40 |
-
"description": "Maximize conversions and sales on your website, app, or Facebook or Instagram store",
|
41 |
-
"key_metrics": ["Conversions", "Catalog sales", "Average order value", "ROAS"],
|
42 |
-
"copy_strategy": "Emphasize irresistible offers, create a sense of scarcity or urgency, highlight testimonials from satisfied customers, and eliminate purchase objections with clear guarantees"
|
43 |
-
}
|
44 |
}
|
|
|
1 |
+
ad_objectives = {
|
2 |
+
"Ninguno": {
|
3 |
+
"name": "Ninguno",
|
4 |
+
"description": "No specific campaign objective",
|
5 |
+
"key_metrics": ["General metrics"],
|
6 |
+
"copy_strategy": "Create a balanced ad without focus on specific metrics"
|
7 |
+
},
|
8 |
+
"Reconocimiento": {
|
9 |
+
"name": "Reconocimiento",
|
10 |
+
"description": "Increase your brand visibility and reach people more likely to remember it",
|
11 |
+
"key_metrics": ["Reach", "Impressions", "Ad recall lift", "Video plays"],
|
12 |
+
"copy_strategy": "Use memorable messages that highlight brand identity, create content with visual and emotional impact, and emphasize what makes the brand unique"
|
13 |
+
},
|
14 |
+
"Tráfico": {
|
15 |
+
"name": "Tráfico",
|
16 |
+
"description": "Direct people to a specific destination such as website, Facebook page, Instagram store or app",
|
17 |
+
"key_metrics": ["Link clicks", "Page views", "Daily unique reach", "Impressions"],
|
18 |
+
"copy_strategy": "Include clear and direct CTAs, create urgency to visit the destination, highlight the value they'll find when clicking, and use language that invites immediate action"
|
19 |
+
},
|
20 |
+
"Interacción": {
|
21 |
+
"name": "Interacción",
|
22 |
+
"description": "Promote interactions with your page, posts, videos or start conversations in Messenger",
|
23 |
+
"key_metrics": ["Page interactions", "Post interactions", "Video plays", "Messages"],
|
24 |
+
"copy_strategy": "Ask intriguing questions, invite people to share opinions, create content that generates discussion, and use a conversational tone that encourages participation"
|
25 |
+
},
|
26 |
+
"Clientes potenciales": {
|
27 |
+
"name": "Clientes potenciales",
|
28 |
+
"description": "Collect contact information from people interested in your business through forms",
|
29 |
+
"key_metrics": ["Lead generation", "Messages", "Conversions", "Cost per lead"],
|
30 |
+
"copy_strategy": "Offer clear value in exchange for contact information, highlight exclusive benefits, minimize risk perception, and create a sense of limited opportunity"
|
31 |
+
},
|
32 |
+
"Promoción de la app": {
|
33 |
+
"name": "Promoción de la app",
|
34 |
+
"description": "Increase installations and specific actions within your mobile application",
|
35 |
+
"key_metrics": ["App installations", "App actions", "Cost per installation"],
|
36 |
+
"copy_strategy": "Highlight the app's unique features, emphasize ease of use, show attractive screenshots, and clearly communicate the problem the app solves"
|
37 |
+
},
|
38 |
+
"Ventas": {
|
39 |
+
"name": "Ventas",
|
40 |
+
"description": "Maximize conversions and sales on your website, app, or Facebook or Instagram store",
|
41 |
+
"key_metrics": ["Conversions", "Catalog sales", "Average order value", "ROAS"],
|
42 |
+
"copy_strategy": "Emphasize irresistible offers, create a sense of scarcity or urgency, highlight testimonials from satisfied customers, and eliminate purchase objections with clear guarantees"
|
43 |
+
}
|
44 |
}
|
app.py
CHANGED
@@ -24,7 +24,7 @@ def get_model(temperature):
|
|
24 |
return genai.GenerativeModel('gemini-2.0-flash', generation_config=generation_config)
|
25 |
|
26 |
# Function to generate Facebook ads
|
27 |
-
def generate_fb_ad(target_audience, product, temperature, selected_formula, selected_angle, selected_persona, ad_objective=None):
|
28 |
if not target_audience or not product:
|
29 |
return "Por favor, completa todos los campos requeridos."
|
30 |
|
@@ -36,7 +36,8 @@ def generate_fb_ad(target_audience, product, temperature, selected_formula, sele
|
|
36 |
selected_angle,
|
37 |
selected_persona,
|
38 |
ad_objective,
|
39 |
-
language="español" # Fixed to Spanish
|
|
|
40 |
)
|
41 |
|
42 |
response = model.generate_content([ad_instruction], generation_config={"temperature": temperature})
|
@@ -69,7 +70,8 @@ col1, col2 = st.columns([1, 2])
|
|
69 |
with col1:
|
70 |
ad_target_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Madres trabajadoras de 30-45 años")
|
71 |
ad_product = st.text_input("¿Qué producto tienes en mente?", placeholder="Ejemplo: Curso de gestión del tiempo")
|
72 |
-
|
|
|
73 |
with st.expander("Opciones avanzadas"):
|
74 |
# Selector de fórmula de anuncio
|
75 |
ad_formula_key = st.selectbox(
|
@@ -78,7 +80,7 @@ with col1:
|
|
78 |
label_visibility="visible"
|
79 |
)
|
80 |
ad_formula = ads_formulas[ad_formula_key]
|
81 |
-
|
82 |
# Selector de ángulo emocional
|
83 |
emotional_angle_key = st.selectbox(
|
84 |
"Ángulo emocional",
|
@@ -129,8 +131,8 @@ if submit_ad:
|
|
129 |
ad_formula,
|
130 |
emotional_angle,
|
131 |
ad_persona,
|
|
|
132 |
selected_objective
|
133 |
-
# Removed language parameter
|
134 |
)
|
135 |
if not isinstance(generated_ad, str):
|
136 |
col2.error("Error al generar el anuncio")
|
@@ -141,6 +143,5 @@ if submit_ad:
|
|
141 |
<p>{generated_ad}</p>
|
142 |
</div>
|
143 |
""", unsafe_allow_html=True)
|
144 |
-
|
145 |
else:
|
146 |
col2.warning("Por favor, completa todos los campos antes de generar el anuncio.")
|
|
|
24 |
return genai.GenerativeModel('gemini-2.0-flash', generation_config=generation_config)
|
25 |
|
26 |
# Function to generate Facebook ads
|
27 |
+
def generate_fb_ad(target_audience, product, temperature, selected_formula, selected_angle, selected_persona, story_prompt="", ad_objective=None):
|
28 |
if not target_audience or not product:
|
29 |
return "Por favor, completa todos los campos requeridos."
|
30 |
|
|
|
36 |
selected_angle,
|
37 |
selected_persona,
|
38 |
ad_objective,
|
39 |
+
language="español", # Fixed to Spanish
|
40 |
+
story_prompt=story_prompt # Add the new parameter
|
41 |
)
|
42 |
|
43 |
response = model.generate_content([ad_instruction], generation_config={"temperature": temperature})
|
|
|
70 |
with col1:
|
71 |
ad_target_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Madres trabajadoras de 30-45 años")
|
72 |
ad_product = st.text_input("¿Qué producto tienes en mente?", placeholder="Ejemplo: Curso de gestión del tiempo")
|
73 |
+
input_prompt = st.text_area("Escribe de qué quieres que trate la historia:", placeholder="Escribe aquí tu idea...")
|
74 |
+
|
75 |
with st.expander("Opciones avanzadas"):
|
76 |
# Selector de fórmula de anuncio
|
77 |
ad_formula_key = st.selectbox(
|
|
|
80 |
label_visibility="visible"
|
81 |
)
|
82 |
ad_formula = ads_formulas[ad_formula_key]
|
83 |
+
|
84 |
# Selector de ángulo emocional
|
85 |
emotional_angle_key = st.selectbox(
|
86 |
"Ángulo emocional",
|
|
|
131 |
ad_formula,
|
132 |
emotional_angle,
|
133 |
ad_persona,
|
134 |
+
input_prompt, # Pass the new story prompt
|
135 |
selected_objective
|
|
|
136 |
)
|
137 |
if not isinstance(generated_ad, str):
|
138 |
col2.error("Error al generar el anuncio")
|
|
|
143 |
<p>{generated_ad}</p>
|
144 |
</div>
|
145 |
""", unsafe_allow_html=True)
|
|
|
146 |
else:
|
147 |
col2.warning("Por favor, completa todos los campos antes de generar el anuncio.")
|
prompts.py
CHANGED
@@ -19,7 +19,7 @@ from emotional_angles import emotional_angles
|
|
19 |
# Importar las fórmulas de anuncios desde la carpeta ads
|
20 |
from ads_formulas import ads_formulas
|
21 |
|
22 |
-
def create_fb_ad_instruction(target_audience, product, selected_formula, selected_angle, selected_persona, ad_objective=None, language="español"):
|
23 |
"""
|
24 |
Creates an instruction for generating Facebook ad copy
|
25 |
|
@@ -31,6 +31,7 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
31 |
- selected_persona: Copywriting legend personality to adopt
|
32 |
- ad_objective: The campaign objective (awareness, traffic, engagement, etc.)
|
33 |
- language: Target language for the ad (default: "español")
|
|
|
34 |
|
35 |
Returns:
|
36 |
- Instruction string for the model
|
@@ -51,6 +52,27 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
51 |
- {ad_objective['copy_strategy']}
|
52 |
"""
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
persona_instruction = f"""
|
55 |
Adopt the personality and writing style of {selected_persona['description']}
|
56 |
|
@@ -105,6 +127,7 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
105 |
Note: These are just the titles. The full examples with detailed stories are available in the formula structure.
|
106 |
"""
|
107 |
|
|
|
108 |
instruction = f"""
|
109 |
{system_prompt}
|
110 |
|
@@ -112,6 +135,8 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
112 |
|
113 |
{objective_instruction if ad_objective else ""}
|
114 |
|
|
|
|
|
115 |
{persona_instruction}
|
116 |
|
117 |
Ad Requirements:
|
@@ -199,6 +224,15 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
199 |
2. Are the headlines creative and compelling enough to make the reader stop scrolling?
|
200 |
3. Do the headlines offer different angles/approaches to the same core message?
|
201 |
4. Is the product integrated naturally into the narrative without feeling forced or promotional?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
Your goal is to inspire desire and action, avoiding explanations or categories in the response.
|
204 |
"""
|
|
|
19 |
# Importar las fórmulas de anuncios desde la carpeta ads
|
20 |
from ads_formulas import ads_formulas
|
21 |
|
22 |
+
def create_fb_ad_instruction(target_audience, product, selected_formula, selected_angle, selected_persona, ad_objective=None, language="español", story_prompt=""):
|
23 |
"""
|
24 |
Creates an instruction for generating Facebook ad copy
|
25 |
|
|
|
31 |
- selected_persona: Copywriting legend personality to adopt
|
32 |
- ad_objective: The campaign objective (awareness, traffic, engagement, etc.)
|
33 |
- language: Target language for the ad (default: "español")
|
34 |
+
- story_prompt: Specific theme or idea for the ad story (default: "")
|
35 |
|
36 |
Returns:
|
37 |
- Instruction string for the model
|
|
|
52 |
- {ad_objective['copy_strategy']}
|
53 |
"""
|
54 |
|
55 |
+
# Create story prompt instruction if provided
|
56 |
+
story_instruction = ""
|
57 |
+
if story_prompt:
|
58 |
+
story_instruction = f"""
|
59 |
+
**Personalized Story - CRITICAL INSTRUCTION:**
|
60 |
+
|
61 |
+
Build an authentic and relatable narrative specifically centered on this theme:
|
62 |
+
"{story_prompt}"
|
63 |
+
|
64 |
+
ESSENTIAL REQUIREMENTS:
|
65 |
+
- The story MUST reflect a real and everyday situation that {target_audience} regularly experiences
|
66 |
+
- Use specific details that make {target_audience} think "this is happening to me"
|
67 |
+
- Include moments of frustration, challenge, or aspiration that are EXACTLY like those experienced by your audience
|
68 |
+
- Narrate the story as if you were describing the situation of someone from the target audience, NOT in first person
|
69 |
+
- Incorporate phrases, jargon, or cultural references that {target_audience} would naturally use
|
70 |
+
- Make sure the story evokes specific emotions that {target_audience} feels about this topic
|
71 |
+
- The narrative must create a "moment of recognition" where the reader feels completely reflected
|
72 |
+
|
73 |
+
This story MUST feel as if you have been observing the daily life of your audience and perfectly understand their challenges related to "{story_prompt}".
|
74 |
+
"""
|
75 |
+
|
76 |
persona_instruction = f"""
|
77 |
Adopt the personality and writing style of {selected_persona['description']}
|
78 |
|
|
|
127 |
Note: These are just the titles. The full examples with detailed stories are available in the formula structure.
|
128 |
"""
|
129 |
|
130 |
+
# Add the story_instruction to the main instruction
|
131 |
instruction = f"""
|
132 |
{system_prompt}
|
133 |
|
|
|
135 |
|
136 |
{objective_instruction if ad_objective else ""}
|
137 |
|
138 |
+
{story_instruction if story_prompt else ""}
|
139 |
+
|
140 |
{persona_instruction}
|
141 |
|
142 |
Ad Requirements:
|
|
|
224 |
2. Are the headlines creative and compelling enough to make the reader stop scrolling?
|
225 |
3. Do the headlines offer different angles/approaches to the same core message?
|
226 |
4. Is the product integrated naturally into the narrative without feeling forced or promotional?
|
227 |
+
5. Does the story authentically reflect a real-life situation that {target_audience} faces daily?
|
228 |
+
6. Are the specific challenges, frustrations, and aspirations mentioned in the ad truly representative of {target_audience}'s experience?
|
229 |
+
7. If a story theme was provided ("{story_prompt}"), does the ad narrative clearly center around this specific topic?
|
230 |
+
8. Does the ad use language, references, and examples that would immediately resonate with {target_audience}?
|
231 |
+
9. Would someone from {target_audience} read this ad and think "this person understands exactly what I'm going through"?
|
232 |
+
10. Does the ad effectively incorporate the emotional angle "{selected_angle['description']}" throughout the copy?
|
233 |
+
11. Is the writing style authentically reflective of {selected_persona['description']}'s signature approach?
|
234 |
+
12. Is the Call to Action (CTA) clear, specific, and compelling enough to drive the desired action?
|
235 |
+
13. Does the CTA naturally flow from the story and provide a logical next step for the reader?
|
236 |
|
237 |
Your goal is to inspire desire and action, avoiding explanations or categories in the response.
|
238 |
"""
|