Spaces:
Running
Running
Upload 11 files
Browse files- app.py +14 -2
- prompts.py +9 -5
app.py
CHANGED
@@ -28,6 +28,12 @@ def generate_fb_ad(target_audience, product, temperature, selected_formula, sele
|
|
28 |
if not target_audience or not product:
|
29 |
return "Por favor, completa todos los campos requeridos."
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
model = get_model(temperature)
|
32 |
ad_instruction = create_fb_ad_instruction(
|
33 |
target_audience,
|
@@ -37,10 +43,16 @@ def generate_fb_ad(target_audience, product, temperature, selected_formula, sele
|
|
37 |
selected_persona,
|
38 |
ad_objective,
|
39 |
language="español", # Fixed to Spanish
|
40 |
-
story_prompt=
|
41 |
)
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
return response.parts[0].text if response and response.parts else "Error generating content."
|
45 |
|
46 |
# Configurar la interfaz de usuario con Streamlit
|
|
|
28 |
if not target_audience or not product:
|
29 |
return "Por favor, completa todos los campos requeridos."
|
30 |
|
31 |
+
# Enfatizar el tema de la historia si se proporciona
|
32 |
+
emphasized_story_prompt = story_prompt
|
33 |
+
if story_prompt and story_prompt.strip():
|
34 |
+
# Añadir énfasis al tema para que el modelo le dé más importancia
|
35 |
+
emphasized_story_prompt = story_prompt.strip()
|
36 |
+
|
37 |
model = get_model(temperature)
|
38 |
ad_instruction = create_fb_ad_instruction(
|
39 |
target_audience,
|
|
|
43 |
selected_persona,
|
44 |
ad_objective,
|
45 |
language="español", # Fixed to Spanish
|
46 |
+
story_prompt=emphasized_story_prompt # Usar el tema enfatizado
|
47 |
)
|
48 |
|
49 |
+
# Si hay un tema específico, ajustar la temperatura para mayor coherencia
|
50 |
+
effective_temperature = temperature
|
51 |
+
if story_prompt and story_prompt.strip():
|
52 |
+
# Reducir ligeramente la temperatura para mantener más enfoque en el tema
|
53 |
+
effective_temperature = max(0.1, temperature * 0.9)
|
54 |
+
|
55 |
+
response = model.generate_content([ad_instruction], generation_config={"temperature": effective_temperature})
|
56 |
return response.parts[0].text if response and response.parts else "Error generating content."
|
57 |
|
58 |
# Configurar la interfaz de usuario con Streamlit
|
prompts.py
CHANGED
@@ -58,19 +58,23 @@ def create_fb_ad_instruction(target_audience, product, selected_formula, selecte
|
|
58 |
story_instruction = f"""
|
59 |
**Personalized Story - CRITICAL INSTRUCTION:**
|
60 |
|
61 |
-
Build an authentic and relatable narrative
|
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"""
|
|
|
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 |
+
THIS IS THE MOST IMPORTANT ASPECT OF THE AD - THE STORY MUST BE ABOUT THIS SPECIFIC TOPIC.
|
65 |
+
|
66 |
ESSENTIAL REQUIREMENTS:
|
67 |
+
- The story MUST reflect a real and everyday situation that {target_audience} regularly experiences RELATED TO "{story_prompt}"
|
68 |
+
- Use specific details that make {target_audience} think "this is happening to me" when dealing with "{story_prompt}"
|
69 |
+
- Include moments of frustration, challenge, or aspiration that are EXACTLY like those experienced by your audience regarding "{story_prompt}"
|
70 |
- Narrate the story as if you were describing the situation of someone from the target audience, NOT in first person
|
71 |
+
- Incorporate phrases, jargon, or cultural references that {target_audience} would naturally use when talking about "{story_prompt}"
|
72 |
- Make sure the story evokes specific emotions that {target_audience} feels about this topic
|
73 |
- The narrative must create a "moment of recognition" where the reader feels completely reflected
|
74 |
|
75 |
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}".
|
76 |
+
|
77 |
+
IMPORTANT: If you don't center the story around "{story_prompt}", the ad will fail its purpose completely.
|
78 |
"""
|
79 |
|
80 |
persona_instruction = f"""
|