Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -52,40 +52,44 @@ IMPORTANT:
|
|
52 |
story_formulas = {
|
53 |
"PASA": {
|
54 |
"description": """
|
55 |
-
|
56 |
-
1. **Problema**:
|
57 |
-
-
|
58 |
-
-
|
59 |
-
-
|
60 |
-
|
61 |
-
-
|
62 |
-
-
|
63 |
-
|
64 |
-
|
65 |
-
-
|
66 |
-
-
|
67 |
-
-
|
68 |
-
|
69 |
-
-
|
70 |
-
-
|
71 |
-
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
-
|
79 |
-
-
|
80 |
-
-
|
81 |
-
|
82 |
-
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
-
|
87 |
-
-
|
88 |
-
-
|
|
|
|
|
|
|
|
|
89 |
"""
|
90 |
},
|
91 |
"GHA": {
|
@@ -109,7 +113,7 @@ story_formulas = {
|
|
109 |
|
110 |
def generate_story(formula_type, target_audience, product, action, mood, length, story_topic=None):
|
111 |
"""Funci贸n unificada para generar historias"""
|
112 |
-
model = genai.GenerativeModel("gemini-
|
113 |
|
114 |
if formula_type not in story_formulas:
|
115 |
raise ValueError("F贸rmula no v谩lida")
|
@@ -135,6 +139,57 @@ Llamada a acci贸n: {action}
|
|
135 |
return response.parts[0].text.strip()
|
136 |
raise ValueError("No se pudo generar la historia")
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
# Inicializar la aplicaci贸n Streamlit
|
139 |
st.set_page_config(page_title="Generador de Historias", page_icon=":pencil:", layout="wide")
|
140 |
|
|
|
52 |
story_formulas = {
|
53 |
"PASA": {
|
54 |
"description": """
|
55 |
+
The P.A.S.A. formula flows naturally through these key elements:
|
56 |
+
1. **Problem (Problema)**:
|
57 |
+
- Identify the core pain point
|
58 |
+
- Current problematic situation
|
59 |
+
- Main frustration or challenge
|
60 |
+
- Hidden fears and concerns
|
61 |
+
- Daily struggles
|
62 |
+
- Unfulfilled desires
|
63 |
+
|
64 |
+
2. **Agitation (Agitaci贸n)**:
|
65 |
+
- Emotional consequences
|
66 |
+
- Daily life impact
|
67 |
+
- Cost of inaction
|
68 |
+
- Future implications
|
69 |
+
- Missed opportunities
|
70 |
+
- Social and personal effects
|
71 |
+
- Ripple effects on relationships
|
72 |
+
- Professional implications
|
73 |
+
|
74 |
+
3. **Solution (Soluci贸n)**:
|
75 |
+
- Product/service introduction
|
76 |
+
- Key benefits and features
|
77 |
+
- Transformation journey
|
78 |
+
- Success stories
|
79 |
+
- Unique value proposition
|
80 |
+
- Immediate relief points
|
81 |
+
- Long-term advantages
|
82 |
+
- Social proof elements
|
83 |
+
|
84 |
+
4. **Action (Acci贸n)**:
|
85 |
+
- Clear next steps
|
86 |
+
- Motivation triggers
|
87 |
+
- Immediate benefits
|
88 |
+
- Sense of urgency
|
89 |
+
- Risk reversal
|
90 |
+
- Value-packed offer
|
91 |
+
- Easy implementation
|
92 |
+
- Quick-start guide
|
93 |
"""
|
94 |
},
|
95 |
"GHA": {
|
|
|
113 |
|
114 |
def generate_story(formula_type, target_audience, product, action, mood, length, story_topic=None):
|
115 |
"""Funci贸n unificada para generar historias"""
|
116 |
+
model = genai.GenerativeModel("gemini-2.0-flash")
|
117 |
|
118 |
if formula_type not in story_formulas:
|
119 |
raise ValueError("F贸rmula no v谩lida")
|
|
|
139 |
return response.parts[0].text.strip()
|
140 |
raise ValueError("No se pudo generar la historia")
|
141 |
|
142 |
+
if formula_type == "PASA":
|
143 |
+
prompt = f"""
|
144 |
+
As a master copywriter and storyteller, craft a compelling {length}-word story in Spanish that follows the P.A.S.A. formula while maintaining a {mood} tone.
|
145 |
+
|
146 |
+
TARGET AUDIENCE PROFILE:
|
147 |
+
{target_audience}
|
148 |
+
|
149 |
+
STORYTELLING GUIDELINES:
|
150 |
+
- Weave a natural narrative that flows seamlessly through problem, agitation, solution, and action
|
151 |
+
- DO NOT explicitly label these sections
|
152 |
+
- Create an emotional connection through relatable scenarios
|
153 |
+
- Use sensory details and vivid descriptions
|
154 |
+
- Maintain consistent tone and voice throughout
|
155 |
+
|
156 |
+
KEY ELEMENTS TO INCLUDE:
|
157 |
+
1. Opening Hook:
|
158 |
+
- Identify a specific problem that resonates with {target_audience}
|
159 |
+
- Create immediate recognition and empathy
|
160 |
+
- Use powerful emotional triggers
|
161 |
+
|
162 |
+
2. Problem Amplification:
|
163 |
+
- Explore deeper emotional impact
|
164 |
+
- Show ripple effects in daily life
|
165 |
+
- Build tension through real consequences
|
166 |
+
- Address hidden fears and frustrations
|
167 |
+
|
168 |
+
3. Solution Development:
|
169 |
+
- Naturally introduce '{product}' as the answer
|
170 |
+
- Show transformation journey
|
171 |
+
- Highlight key benefits without being sales-y
|
172 |
+
- Include subtle social proof elements
|
173 |
+
|
174 |
+
4. Action Integration:
|
175 |
+
- Weave in '{action}' naturally
|
176 |
+
- Create urgency without pressure
|
177 |
+
- Make next steps clear and appealing
|
178 |
+
- End with emotional satisfaction
|
179 |
+
|
180 |
+
IMPORTANT:
|
181 |
+
- Maintain natural flow and cohesion
|
182 |
+
- Avoid explicit marketing language
|
183 |
+
- Keep product placement subtle but effective
|
184 |
+
- Ensure call-to-action feels like a logical next step
|
185 |
+
- Use language that resonates with {target_audience}
|
186 |
+
"""
|
187 |
+
|
188 |
+
response = model.generate_content([prompt])
|
189 |
+
if response and response.parts:
|
190 |
+
return response.parts[0].text.strip()
|
191 |
+
raise ValueError("No se pudo generar la historia")
|
192 |
+
|
193 |
# Inicializar la aplicaci贸n Streamlit
|
194 |
st.set_page_config(page_title="Generador de Historias", page_icon=":pencil:", layout="wide")
|
195 |
|