Update app.py
Browse files
app.py
CHANGED
@@ -119,114 +119,69 @@ def generate_story(formula_type, target_audience, product, action, mood, length,
|
|
119 |
if formula_type not in story_formulas:
|
120 |
raise ValueError("F贸rmula no v谩lida")
|
121 |
|
122 |
-
# System prompt
|
123 |
-
|
124 |
-
|
125 |
-
FORMAT RULES:
|
126 |
-
- Story must be structured in clear paragraphs
|
127 |
-
- Each section must flow naturally into the next
|
128 |
-
- No explicit section labels
|
129 |
-
- Maintain consistent tone throughout
|
130 |
-
- Include smooth transitions between parts
|
131 |
-
- Story must feel complete and cohesive
|
132 |
-
|
133 |
-
IMPORTANT STRUCTURE INSTRUCTIONS:
|
134 |
-
- The selected formula MUST be applied to the entire story
|
135 |
-
- Review and follow the structure detailed in story_formulas[formula_type]["description"]
|
136 |
-
- Use the examples in story_formulas[formula_type]["examples"] as inspiration
|
137 |
-
- Formula provides the framework, tone provides the emotional layer
|
138 |
-
- Both must work together seamlessly
|
139 |
-
|
140 |
-
FORMAT EXAMPLE:
|
141 |
-
[First paragraph introducing the situation]
|
142 |
-
|
143 |
-
[Second paragraph developing tension/conflict]
|
144 |
-
|
145 |
-
[Third paragraph presenting transformation]
|
146 |
-
|
147 |
-
[Final paragraph with natural call to action]
|
148 |
-
|
149 |
-
IMPORTANT:
|
150 |
-
- Each story must be unique and memorable
|
151 |
-
- Avoid clich茅s and generic scenarios
|
152 |
-
- Maintain a credible and authentic voice
|
153 |
-
- Adapt language to target audience
|
154 |
-
- Focus on emotional transformation
|
155 |
-
- Follow formula structure while maintaining selected tone
|
156 |
-
- Never explicitly label sections
|
157 |
-
- Integrate product and call-to-action organically
|
158 |
-
|
159 |
-
STORY STRUCTURE GUIDELINES:
|
160 |
-
1. Study the formula description carefully
|
161 |
-
2. Review provided examples for style and flow
|
162 |
-
3. Maintain similar paragraph length and structure
|
163 |
-
4. Use consistent emotional intensity
|
164 |
-
5. Mirror the narrative progression
|
165 |
-
6. Adapt content for target audience while keeping formula essence
|
166 |
-
|
167 |
-
TONE AND STYLE:
|
168 |
-
- Selected tone must remain consistent
|
169 |
-
- Tone modifies HOW the story is told
|
170 |
-
- Formula provides structure, tone provides emotion
|
171 |
-
- Both elements must complement each other
|
172 |
-
- Maintain voice appropriate for target audience
|
173 |
-
|
174 |
-
KEY ELEMENTS TO INCLUDE:
|
175 |
-
- Emotional hooks that grab attention
|
176 |
-
- Relatable situations and characters
|
177 |
-
- Sensory details and vivid descriptions
|
178 |
-
- Natural problem-solution progression
|
179 |
-
- Organic product integration
|
180 |
-
- Compelling but subtle call-to-action"""
|
181 |
-
|
182 |
-
# Iniciar el prompt con las instrucciones del sistema
|
183 |
story_instruction = f"{system_prompt}\n\n"
|
184 |
|
185 |
-
#
|
186 |
story_instruction += f"""
|
187 |
-
|
188 |
-
{
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
-
|
|
|
|
|
|
|
191 |
"""
|
192 |
|
193 |
-
#
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
195 |
story_instruction += f"""
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
199 |
{example['story']}
|
200 |
"""
|
201 |
|
202 |
-
# Agregar instrucciones espec铆ficas
|
203 |
-
story_instruction +=
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
5. Lead to the call-to-action: {action}
|
213 |
"""
|
214 |
|
215 |
-
# Agregar
|
216 |
-
|
217 |
-
story_instruction += f"""
|
218 |
-
6. Incorporate this specific story topic: {story_topic}
|
219 |
-
"""
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
230 |
"""
|
231 |
|
232 |
response = model.generate_content([story_instruction])
|
|
|
119 |
if formula_type not in story_formulas:
|
120 |
raise ValueError("F贸rmula no v谩lida")
|
121 |
|
122 |
+
# [System prompt anterior se mantiene igual...]
|
123 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
story_instruction = f"{system_prompt}\n\n"
|
125 |
|
126 |
+
# A帽adir instrucciones sobre el producto y beneficios
|
127 |
story_instruction += f"""
|
128 |
+
PRODUCT INTEGRATION GUIDELINES:
|
129 |
+
- Evita menciones obvias de {product}
|
130 |
+
- Enf贸cate en despertar inter茅s genuino mostrando beneficios transformacionales
|
131 |
+
- Integra el producto de manera natural en la narrativa
|
132 |
+
- Destaca c贸mo el producto mejora la vida del protagonista
|
133 |
+
- Mant茅n el tono {mood} al describir los beneficios
|
134 |
+
"""
|
135 |
|
136 |
+
# Instrucciones de estudio de ejemplos
|
137 |
+
story_instruction += f"""
|
138 |
+
IMPORTANTE: Estudia cuidadosamente estos ejemplos de la f贸rmula seleccionada.
|
139 |
+
Cada ejemplo representa el estilo y estructura a seguir, adaptados al tono {mood}:
|
140 |
"""
|
141 |
|
142 |
+
# Seleccionar ejemplos aleatorios
|
143 |
+
random_examples = random.sample(story_formulas[formula_type]['examples'],
|
144 |
+
min(3, len(story_formulas[formula_type]['examples'])))
|
145 |
+
|
146 |
+
# Agregar ejemplos seleccionados
|
147 |
+
story_instruction += "\nEJEMPLOS DE LA F脫RMULA A SEGUIR:\n"
|
148 |
+
for i, example in enumerate(random_examples, 1):
|
149 |
story_instruction += f"""
|
150 |
+
Ejemplo {i}:
|
151 |
+
T铆tulo: {example['title']}
|
152 |
+
Audiencia: {example['target']}
|
153 |
+
Historia:
|
154 |
{example['story']}
|
155 |
"""
|
156 |
|
157 |
+
# Agregar instrucciones espec铆ficas
|
158 |
+
story_instruction += """
|
159 |
+
INSTRUCCIONES ESPEC脥FICAS:
|
160 |
+
1. Mant茅n la misma estructura y longitud que los ejemplos anteriores
|
161 |
+
2. Usa el mismo tono y estilo de escritura, adaptado al mood especificado
|
162 |
+
3. Replica los patrones de construcci贸n de frases y transiciones
|
163 |
+
4. Conserva el nivel de especificidad y detalle en las descripciones
|
164 |
+
5. Adapta el contenido para la audiencia manteniendo la esencia de los ejemplos
|
165 |
+
6. Integra los beneficios del producto de manera sutil y convincente
|
166 |
+
7. Asegura que la transformaci贸n del protagonista sea cre铆ble y emotiva
|
|
|
167 |
"""
|
168 |
|
169 |
+
# Agregar la descripci贸n de la f贸rmula
|
170 |
+
story_instruction += f"\nF脫RMULA A SEGUIR:\n{story_formulas[formula_type]['description']}\n\n"
|
|
|
|
|
|
|
171 |
|
172 |
+
# Recordatorio final
|
173 |
+
story_instruction += f"""
|
174 |
+
RECORDATORIO FINAL:
|
175 |
+
1. Sigue la estructura de la f贸rmula seleccionada
|
176 |
+
2. Aplica el tono {mood} de manera consistente
|
177 |
+
3. Mant茅n la coherencia narrativa
|
178 |
+
4. Asegura que la historia refleje una transformaci贸n aut茅ntica
|
179 |
+
5. Integra {product} y sus beneficios de forma natural
|
180 |
+
6. Culmina con un llamado a la acci贸n convincente: {action}
|
181 |
+
|
182 |
+
GENERA AHORA:
|
183 |
+
Crea una historia persuasiva de {length} palabras que siga fielmente el estilo y estructura de los ejemplos mostrados,
|
184 |
+
manteniendo un tono {mood} y enfoc谩ndote en la transformaci贸n que {product} puede traer a la vida de {target_audience}.
|
185 |
"""
|
186 |
|
187 |
response = model.generate_content([story_instruction])
|