Spaces:
Sleeping
Sleeping
Update formulas.py
Browse files- formulas.py +178 -51
formulas.py
CHANGED
@@ -13,6 +13,62 @@ CRITICAL OUTPUT RULES:
|
|
13 |
- Do not include phrases like "Aquí tienes una oferta convincente" or "Esta es tu oferta"
|
14 |
"""
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def create_offer_instruction(avatar_description, product_name, selected_formula_name):
|
17 |
"""
|
18 |
Creates instructions for generating an offer based on the selected formula.
|
@@ -25,6 +81,9 @@ def create_offer_instruction(avatar_description, product_name, selected_formula_
|
|
25 |
Returns:
|
26 |
str: Complete instruction for generating the offer
|
27 |
"""
|
|
|
|
|
|
|
28 |
# Get the selected formula
|
29 |
selected_formula = offer_formulas[selected_formula_name]
|
30 |
|
@@ -34,16 +93,14 @@ def create_offer_instruction(avatar_description, product_name, selected_formula_
|
|
34 |
additional_instructions = """
|
35 |
SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
36 |
1. PRODUCT/SERVICE NAME HANDLING:
|
37 |
-
- If
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
* Is specific to the niche or industry mentioned in avatar_description
|
43 |
-
- If product_name contains a full phrase like "Un curso llamado Inglés sin problemas", extract only the real name ("Inglés sin problemas")
|
44 |
|
45 |
2. Analyze ALL available information:
|
46 |
-
- Product/service name (
|
47 |
- Target audience description (avatar_description)
|
48 |
- Content from uploaded files (if any)
|
49 |
|
@@ -54,7 +111,7 @@ SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
|
54 |
|
55 |
4. Create a comprehensive offer by combining:
|
56 |
- The appropriate type (determined in step 3)
|
57 |
-
- The
|
58 |
- A compelling dream based on avatar_description
|
59 |
- A relevant obstacle based on avatar_description
|
60 |
|
@@ -77,37 +134,79 @@ SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
|
77 |
- "Ahora puedes acceder a un..."
|
78 |
- "Tenemos para ti un..."
|
79 |
- "Disfruta de un..."
|
80 |
-
"""
|
81 |
|
82 |
elif selected_formula_name == "Oferta Dorada":
|
83 |
additional_instructions = """
|
84 |
SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
85 |
-
1.
|
86 |
-
-
|
87 |
-
|
88 |
-
-
|
89 |
-
-
|
90 |
-
-
|
91 |
-
|
92 |
-
2.
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
-
|
98 |
-
-
|
99 |
-
-
|
100 |
-
-
|
101 |
-
|
102 |
-
|
103 |
-
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
-
|
109 |
-
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
# Create the instruction using the system prompt at the beginning
|
113 |
instruction = f"""{offer_system_prompt}
|
@@ -133,6 +232,34 @@ Create a compelling offer following the formula structure exactly.
|
|
133 |
|
134 |
return instruction
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
# The rest of your offer_formulas dictionary remains unchanged
|
137 |
offer_formulas = {
|
138 |
"Oferta Dorada": {
|
@@ -202,39 +329,39 @@ In this part, we explain the result they will obtain, supported by an authority
|
|
202 |
""",
|
203 |
"examples": [
|
204 |
# Example 1
|
205 |
-
"""
|
206 |
|
207 |
-
|
208 |
|
209 |
-
|
210 |
|
211 |
# Example 2
|
212 |
-
"""
|
213 |
|
214 |
-
|
215 |
|
216 |
-
|
217 |
|
218 |
# Example 3
|
219 |
-
"""
|
220 |
|
221 |
-
|
222 |
|
223 |
-
Gracias a nuestro
|
224 |
|
225 |
# Example 4
|
226 |
-
"""
|
227 |
|
228 |
-
|
229 |
|
230 |
-
|
231 |
|
232 |
# Example 5
|
233 |
-
"""
|
234 |
|
235 |
-
|
236 |
|
237 |
-
|
238 |
]
|
239 |
},
|
240 |
"Fórmula Sueño-Obstáculo": {
|
|
|
13 |
- Do not include phrases like "Aquí tienes una oferta convincente" or "Esta es tu oferta"
|
14 |
"""
|
15 |
|
16 |
+
def extract_product_name(product_name_input):
|
17 |
+
"""
|
18 |
+
Extracts the actual product name from user input, especially when it's enclosed in quotes.
|
19 |
+
|
20 |
+
Args:
|
21 |
+
product_name_input: The raw input string containing the product name
|
22 |
+
|
23 |
+
Returns:
|
24 |
+
str: The extracted product name, or empty string if generic
|
25 |
+
"""
|
26 |
+
import re
|
27 |
+
|
28 |
+
# If input is empty or None, return empty string
|
29 |
+
if not product_name_input or product_name_input.strip() == "":
|
30 |
+
return ""
|
31 |
+
|
32 |
+
# Check if there's a name in quotes
|
33 |
+
quote_pattern = r'"([^"]+)"'
|
34 |
+
matches = re.findall(quote_pattern, product_name_input)
|
35 |
+
|
36 |
+
if matches:
|
37 |
+
# Return the first quoted string found
|
38 |
+
return matches[0]
|
39 |
+
|
40 |
+
# If no quotes but contains "llamado" or similar phrases, extract what follows
|
41 |
+
called_patterns = [
|
42 |
+
r'llamado\s+(.+?)(?:\s+que|\s+con|\s+para|\.$|$)',
|
43 |
+
r'titulado\s+(.+?)(?:\s+que|\s+con|\s+para|\.$|$)',
|
44 |
+
r'denominado\s+(.+?)(?:\s+que|\s+con|\s+para|\.$|$)',
|
45 |
+
r'nombrado\s+(.+?)(?:\s+que|\s+con|\s+para|\.$|$)'
|
46 |
+
]
|
47 |
+
|
48 |
+
for pattern in called_patterns:
|
49 |
+
matches = re.search(pattern, product_name_input, re.IGNORECASE)
|
50 |
+
if matches:
|
51 |
+
extracted = matches.group(1).strip()
|
52 |
+
# If the extracted text has quotes, remove them
|
53 |
+
if extracted.startswith('"') and extracted.endswith('"'):
|
54 |
+
extracted = extracted[1:-1]
|
55 |
+
return extracted
|
56 |
+
|
57 |
+
# Check if the input is generic (common course/product types without specific names)
|
58 |
+
generic_patterns = [
|
59 |
+
r'^(curso|taller|programa|webinar|entrenamiento|sistema|método|servicio|producto|aplicación|comunidad|masterclass)(\s+de\s+.+)?$',
|
60 |
+
r'^(un|el|mi|nuestro)\s+(curso|taller|programa|webinar|entrenamiento|sistema|método|servicio|producto|aplicación|comunidad|masterclass)(\s+de\s+.+)?$'
|
61 |
+
]
|
62 |
+
|
63 |
+
for pattern in generic_patterns:
|
64 |
+
if re.match(pattern, product_name_input.lower(), re.IGNORECASE):
|
65 |
+
# This is a generic description, return empty string to trigger creative name generation
|
66 |
+
return ""
|
67 |
+
|
68 |
+
# If no patterns match, return the original input
|
69 |
+
return product_name_input.strip()
|
70 |
+
|
71 |
+
|
72 |
def create_offer_instruction(avatar_description, product_name, selected_formula_name):
|
73 |
"""
|
74 |
Creates instructions for generating an offer based on the selected formula.
|
|
|
81 |
Returns:
|
82 |
str: Complete instruction for generating the offer
|
83 |
"""
|
84 |
+
# Extract the actual product name if it's in quotes or after "llamado"
|
85 |
+
extracted_name = extract_product_name(product_name)
|
86 |
+
|
87 |
# Get the selected formula
|
88 |
selected_formula = offer_formulas[selected_formula_name]
|
89 |
|
|
|
93 |
additional_instructions = """
|
94 |
SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
95 |
1. PRODUCT/SERVICE NAME HANDLING:
|
96 |
+
- CRITICAL: If a product name is provided in quotes or after words like "llamado", "titulado", etc.,
|
97 |
+
YOU MUST USE THAT EXACT NAME. This is non-negotiable.
|
98 |
+
- The extracted product name is: "{extracted_name}"
|
99 |
+
- If this extracted name is not empty, use it EXACTLY as provided with no modifications
|
100 |
+
- Only create a new name if the extracted name is empty or contains generic placeholders
|
|
|
|
|
101 |
|
102 |
2. Analyze ALL available information:
|
103 |
+
- Product/service name (use the extracted name provided above)
|
104 |
- Target audience description (avatar_description)
|
105 |
- Content from uploaded files (if any)
|
106 |
|
|
|
111 |
|
112 |
4. Create a comprehensive offer by combining:
|
113 |
- The appropriate type (determined in step 3)
|
114 |
+
- The EXACT product name as extracted (if provided)
|
115 |
- A compelling dream based on avatar_description
|
116 |
- A relevant obstacle based on avatar_description
|
117 |
|
|
|
134 |
- "Ahora puedes acceder a un..."
|
135 |
- "Tenemos para ti un..."
|
136 |
- "Disfruta de un..."
|
137 |
+
""".format(extracted_name=extracted_name)
|
138 |
|
139 |
elif selected_formula_name == "Oferta Dorada":
|
140 |
additional_instructions = """
|
141 |
SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
|
142 |
+
1. PRODUCT/SERVICE NAME HANDLING:
|
143 |
+
- CRITICAL: If a product name is provided in quotes or after words like "llamado", "titulado", etc.,
|
144 |
+
YOU MUST USE THAT EXACT NAME. This is non-negotiable.
|
145 |
+
- The extracted product name is: "{extracted_name}"
|
146 |
+
- If this extracted name is not empty, use it EXACTLY as provided with no modifications
|
147 |
+
- Only create a new name if the extracted name is empty or contains generic placeholders
|
148 |
+
|
149 |
+
2. FOLLOW THE 6-STEP PROCESS FOR CREATING AN IRRESISTIBLE OFFER:
|
150 |
+
|
151 |
+
STEP 1: IDENTIFY THE MAIN PROBLEM (ATTENTION HOOK)
|
152 |
+
- Analyze the avatar_description DEEPLY to understand their specific pain points
|
153 |
+
- Create a powerful hook that directly addresses their biggest frustration or anxiety
|
154 |
+
- Use statements that make them think "this person understands my situation exactly"
|
155 |
+
- Focus on the emotional impact of their problem, not just the practical aspects
|
156 |
+
- Use statistics, shocking revelations, or direct statements (never questions)
|
157 |
+
- The hook must create an immediate emotional connection
|
158 |
+
|
159 |
+
STEP 2: CRAFT A QUANTIFIABLE VALUE PROMISE
|
160 |
+
- Write a promise COMPLETELY IN CAPITAL LETTERS that includes:
|
161 |
+
* Concrete numbers (money, time, results)
|
162 |
+
* Powerful action verbs (EARN, MULTIPLY, ACHIEVE, MASTER)
|
163 |
+
* Specific timeframes (EN 30 DÍAS, EN SOLO 2 SEMANAS)
|
164 |
+
* Clear effort indicators (CON SOLO 15 MINUTOS DIARIOS)
|
165 |
+
- Follow this structure: CÓMO [LOGRAR RESULTADO DESEADO] SIN [OBJECIÓN O CREENCIA LIMITANTE]
|
166 |
+
- NEVER use exclamation marks (!) in this section
|
167 |
+
- Make the promise both ambitious and believable
|
168 |
+
|
169 |
+
STEP 3: DEMONSTRATE TRUST AND AUTHORITY
|
170 |
+
- Include elements that prove your system works:
|
171 |
+
* Personal results ("Así como he vendido más de $250,000 USD")
|
172 |
+
* Client results ("Mis clientes han vendido más de $5,000,000")
|
173 |
+
* Social proof (testimonials, case studies)
|
174 |
+
- Establish credibility through specific numbers and verifiable claims
|
175 |
+
- Connect your authority directly to the promised result
|
176 |
+
|
177 |
+
STEP 4: REDUCE DELIVERY TIME
|
178 |
+
- Clearly state how quickly they will see results
|
179 |
+
- Make the timeframe specific and believable
|
180 |
+
- Emphasize speed without sacrificing quality
|
181 |
+
- Use phrases like "en solo X días" or "desde la primera semana"
|
182 |
+
|
183 |
+
STEP 5: MINIMIZE CLIENT EFFORT
|
184 |
+
- Address the fear of complicated processes
|
185 |
+
- Use phrases like "sin necesidad de...", "solo con...", "sin invertir más tiempo..."
|
186 |
+
- Make the implementation process seem accessible and straightforward
|
187 |
+
- Emphasize results with minimal effort
|
188 |
+
|
189 |
+
STEP 6: COMBINE ALL ELEMENTS INTO A COHESIVE OFFER
|
190 |
+
- Ensure all elements address the SAME core problem
|
191 |
+
- Create a LOGICAL PROGRESSION from problem to solution to implementation
|
192 |
+
- Maintain thematic consistency throughout the entire offer
|
193 |
+
- Use one of the 5 structure formats for the final benefit statement
|
194 |
+
|
195 |
+
3. FINAL STRUCTURE FORMAT:
|
196 |
+
Choose one of these formats for the benefit statement:
|
197 |
+
1. "[Feature] para que puedas [Benefit] con lo que [Meaning]"
|
198 |
+
2. "Con [Feature] podrás [Benefit] permitiéndote [Meaning]"
|
199 |
+
3. "Gracias a [Feature] lograrás [Benefit] haciendo que [Meaning]"
|
200 |
+
4. "Mediante [Feature] conseguirás [Benefit] lo que significa [Meaning]"
|
201 |
+
5. "Usando [Feature] alcanzarás [Benefit] transformando [Meaning]"
|
202 |
+
|
203 |
+
4. COMPLETE OFFER TEMPLATE:
|
204 |
+
Si [problema principal que enfrenta el cliente]…
|
205 |
+
|
206 |
+
DESCUBRE CÓMO [LOGRAR RESULTADO DESEADO] SIN [MIEDO, CREENCIA LIMITANTE O ESFUERZO INDESEADO].
|
207 |
+
|
208 |
+
[Estructura elegida del punto 3] + [prueba social/autoridad] + [tiempo de entrega] + [esfuerzo mínimo].
|
209 |
+
""".format(extracted_name=extracted_name)
|
210 |
|
211 |
# Create the instruction using the system prompt at the beginning
|
212 |
instruction = f"""{offer_system_prompt}
|
|
|
232 |
|
233 |
return instruction
|
234 |
|
235 |
+
def generate_complete_offer(avatar_description, product_name, selected_formula_name, include_bonuses=True):
|
236 |
+
"""
|
237 |
+
Generates a complete offer including the main offer and optional bonuses.
|
238 |
+
|
239 |
+
Args:
|
240 |
+
avatar_description: Description of the target audience
|
241 |
+
product_name: Name of the product or service
|
242 |
+
selected_formula_name: Name of the formula to use
|
243 |
+
include_bonuses: Whether to include bonuses in the offer
|
244 |
+
|
245 |
+
Returns:
|
246 |
+
dict: Instructions for generating the complete offer
|
247 |
+
"""
|
248 |
+
# Create main offer instruction
|
249 |
+
main_offer_instruction = create_offer_instruction(avatar_description, product_name, selected_formula_name)
|
250 |
+
|
251 |
+
# Create bonus instruction if requested
|
252 |
+
bonus_instruction = None
|
253 |
+
if include_bonuses:
|
254 |
+
# Import the bonus generator from the new module
|
255 |
+
from bonuses.generator import create_bonus_instruction
|
256 |
+
bonus_instruction = create_bonus_instruction(avatar_description, product_name, selected_formula_name)
|
257 |
+
|
258 |
+
return {
|
259 |
+
"main_offer_instruction": main_offer_instruction,
|
260 |
+
"bonus_instruction": bonus_instruction
|
261 |
+
}
|
262 |
+
|
263 |
# The rest of your offer_formulas dictionary remains unchanged
|
264 |
offer_formulas = {
|
265 |
"Oferta Dorada": {
|
|
|
329 |
""",
|
330 |
"examples": [
|
331 |
# Example 1
|
332 |
+
"""Si tus prospectos te preguntan, preguntan y preguntan... y nunca cierras la venta...
|
333 |
|
334 |
+
DESCUBRE CÓMO VENDER CON UNA SOLA LLAMADA PRODUCTOS DE MÁS DE $1,000 USD SIN MANIPULAR, MENTIR O FORZAR LA VENTA.
|
335 |
|
336 |
+
Con nuestro proceso de venta persuasiva podrás convertir objeciones en razones para comprar permitiéndote cerrar el 80% de tus llamadas, así como he vendido más de $250,000 USD solo con el poder de mi voz y una conexión de internet.""",
|
337 |
|
338 |
# Example 2
|
339 |
+
"""Si tu negocio está estancado y cada mes es una lucha para llegar a fin de mes...
|
340 |
|
341 |
+
MULTIPLICA TUS INGRESOS POR 3 EN LOS PRÓXIMOS 90 DÍAS SIN TRABAJAR MÁS HORAS NI CONTRATAR PERSONAL ADICIONAL.
|
342 |
|
343 |
+
Mediante nuestro sistema de optimización de negocios conseguirás identificar y eliminar los 7 bloqueos de crecimiento lo que significa que podrás escalar tu empresa con los recursos que ya tienes, como han hecho más de 327 emprendedores que han pasado de facturar $3,000 a $10,000 mensuales en menos de un trimestre.""",
|
344 |
|
345 |
# Example 3
|
346 |
+
"""Si has intentado perder peso una y otra vez, pero siempre recuperas lo perdido y más...
|
347 |
|
348 |
+
PIERDE ENTRE 5 Y 8 KILOS EN 30 DÍAS SIN DIETAS RESTRICTIVAS, SIN PASAR HAMBRE Y SIN EFECTO REBOTE.
|
349 |
|
350 |
+
Gracias a nuestro método de reprogramación metabólica lograrás activar tu quema de grasa natural haciendo que tu cuerpo se convierta en una máquina de quemar calorías 24/7, avalado por estudios clínicos que demuestran una efectividad del 94% en personas que habían fracasado con más de 5 dietas anteriores.""",
|
351 |
|
352 |
# Example 4
|
353 |
+
"""Si pasas horas creando contenido para redes sociales pero nadie interactúa ni compra...
|
354 |
|
355 |
+
CONSIGUE 100 NUEVOS SEGUIDORES CUALIFICADOS POR SEMANA Y CONVIERTE EL 10% EN CLIENTES PAGANDO CON SOLO 3 PUBLICACIONES SEMANALES.
|
356 |
|
357 |
+
Usando nuestra estrategia de contenido de alto impacto alcanzarás visibilidad exponencial transformando tu presencia en redes en un canal de ventas automático en menos de 30 días, sin necesidad de invertir en publicidad ni pasar 8 horas diarias pegado a tu teléfono.""",
|
358 |
|
359 |
# Example 5
|
360 |
+
"""Si te sientes agotado, sin energía y cada día es una lucha para levantarte de la cama...
|
361 |
|
362 |
+
AUMENTA TU ENERGÍA UN 65% Y RECUPERA 2 HORAS PRODUCTIVAS AL DÍA CON SOLO 15 MINUTOS DE RUTINA MATUTINA.
|
363 |
|
364 |
+
El Sistema de activación bioenergética para que puedas optimizar tu rendimiento físico y mental con lo que multiplicarás tu productividad desde la primera semana, basado en técnicas neurocientíficas utilizadas por los CEOs de las 100 empresas más exitosas del mundo."""
|
365 |
]
|
366 |
},
|
367 |
"Fórmula Sueño-Obstáculo": {
|