JeCabrera/Perfect_Webinar_FrameWork
0
1from formulas import offer_formulas2from sophistication.generator import create_sophistication_instruction3from avatar_analysis import analyze_avatar4 5# Modify the offer_system_prompt to specify the correct format for PUV6offer_system_prompt = """You are a world-class expert copywriter, experienced in creating compelling offers that connect emotionally with the target audience.7 8OBJECTIVE:9- Generate 3 COMPLETELY DIFFERENT versions of a convincing offer in Spanish10- Each version must be CLEAR, CONCISE and FOCUSED on a SINGLE transformation11- Connect emotionally with the audience's core desire12- Use natural and conversational language13 14CRITICAL OUTPUT RULES:15- Create 3 DISTINCT versions with different angles and emotional appeals16- Each version must focus on ONE problem/vision, ONE transformation, and ONE proof element17- Number each version clearly as "VERSIÓN 1:", "VERSIÓN 2:", and "VERSIÓN 3:"18- Output ONLY the offers themselves with NO explanations or commentary19- Start each version directly with its corresponding formula structure20- Present all 3 versions one after another, clearly separated21 22FORMULA-SPECIFIC FOCUS:231. Oferta Dorada: ONE specific problem, ONE clear transformation, ONE proof element242. Contraste Revelador: ONE inspiring vision, ONE transformative solution, ONE emotional result253. Propuesta Única de Valor: ONE powerful transformation, ONE emotional objection handler26"""27 28def create_offer_instruction(target_audience=None, product_service=None, selected_formula_name=None, file_content=None, skills=None, sophistication_level=None):29 """30 Creates the instruction for generating an offer based on the selected formula.31 32 Args:33 target_audience: Description of the target audience34 product_service: Product/service information35 selected_formula_name: Name of the selected formula36 file_content: Content from uploaded files (if any)37 skills: User's skills and expertise38 sophistication_level: String key for the market sophistication level39 40 Returns:41 str: The complete instruction for generating the offer42 """43 # Get the selected formula44 selected_formula = offer_formulas[selected_formula_name]45 46 # Get formula-specific instructions47 additional_instructions = selected_formula.get("instructions", "")48 49 # Process avatar analysis if target_audience is provided50 avatar_insights = ""51 if target_audience:52 avatar_insights = analyze_avatar(target_audience) # This would call your avatar analysis function53 54 # Create the base instruction with avatar insights55 instruction = f"""{offer_system_prompt}56 57FORMULA TO USE:58{selected_formula["description"]}59 60{additional_instructions}61 62PRODUCT/SERVICE:63{product_service}64 65TARGET AUDIENCE:66{target_audience}67 68AVATAR ANALYSIS:69{avatar_insights}70 71ADDITIONAL INFORMATION:72{file_content}73 74Create a compelling offer following the formula structure exactly, adapting it to the sophistication level provided.75"""76 77 # Add examples if available78 if selected_formula.get("sophistication_examples") and sophistication_level:79 # Extract the sophistication level key (e.g., "nivel_1", "nivel_2", etc.)80 sophistication_key = sophistication_level.split(":")[0].lower().replace(" ", "_")81 82 # Map to the correct key format used in the examples83 if "nivel" not in sophistication_key:84 sophistication_key = f"nivel_{sophistication_key[0]}"85 86 # Get all examples for the specific sophistication level87 examples = []88 for key, example in selected_formula["sophistication_examples"].items():89 # Check if the key starts with the sophistication level (to include nivel_1, nivel_1_ejemplo2, etc.)90 if key.startswith(sophistication_key):91 examples.append(example)92 93 # Format all examples based on the formula type94 if examples:95 instruction += "\n\n### EXAMPLES FOR YOUR REFERENCE:\n"96 97 for i, example in enumerate(examples):98 instruction += f"\n#### Example {i+1}:\n"99 100 # Format based on formula type101 if selected_formula_name == "Oferta Dorada":102 instruction += f"Headline: {example.get('headline', '')}\n"103 instruction += f"Promise: {example.get('promise', '')}\n"104 instruction += f"Subtitle: {example.get('subtitle', '')}\n"105 106 elif selected_formula_name == "Contraste Revelador":107 instruction += f"Situación: {example.get('situation', '')}\n"108 instruction += f"Solución: {example.get('solution', '')}\n"109 instruction += f"Resultado: {example.get('result', '')}\n"110 111 elif selected_formula_name == "Propuesta Única de Valor":112 instruction += f"Transformación: {example.get('transformation', '')}\n"113 instruction += f"Objeciones: {example.get('objections', '')}\n"114 115 # Add more formula types as needed116 # Original code for general examples (keep as fallback)117 elif selected_formula.get("examples") and len(selected_formula["examples"]) > 0:118 examples_text = "\n\n".join([f"Example {i+1}:\n{example}" for i, example in enumerate(selected_formula["examples"])])119 instruction += f"\n\nGet inspired by these examples:\n{examples_text}"120 121 # Add sophistication level guidance using the dedicated function122 if sophistication_level:123 # Get basic sophistication guidance124 base_sophistication_guidance = create_sophistication_instruction(sophistication_level)125 126 # Create concise formula-specific guidance based on sophistication level127 formula_specific_guidance = ""128 level_num = sophistication_level.split(":")[0].replace("Nivel ", "")129 130 if selected_formula_name == "Oferta Dorada":131 # Guidance dictionaries for Oferta Dorada132 headline_guidance = {133 "1": "Educational, introduce the concept as new",134 "2": "Differentiate from competitors, add specific benefits",135 "3": "Highlight unique mechanism or approach",136 "4": "Use data, research or challenge beliefs",137 "5": "Focus on identity and emotional transformation"138 }139 140 promise_guidance = {141 "1": "Direct and clear benefit without comparisons",142 "2": "Quantified benefit with specific advantage",143 "3": "Unique mechanism or proprietary method",144 "4": "Evidence-backed transformation with specifics",145 "5": "Identity shift and deeper meaning beyond results"146 }147 148 subtitle_guidance = {149 "1": "Simple proof with basic numbers",150 "2": "Comparative results with timeframes",151 "3": "Specific mechanism results with details",152 "4": "Research-backed evidence and guarantees",153 "5": "Community and movement-based validation"154 }155 156 formula_specific_guidance = f"""157For Oferta Dorada (Nivel {level_num}):158- Headline: {headline_guidance.get(level_num, "Match market awareness level")}159- Promise: {promise_guidance.get(level_num, "Focus on transformation")}160- Subtitle: {subtitle_guidance.get(level_num, "Provide appropriate proof")}"""161 162 elif selected_formula_name == "Contraste Revelador":163 # Guidance dictionaries for Contraste Revelador164 vision_guidance = {165 "1": "Simple, aspirational future state",166 "2": "Specific vision with clear advantages",167 "3": "Unique approach to achieving desires",168 "4": "Evidence-based optimal state",169 "5": "Transcendent vision beyond conventional goals"170 }171 172 solution_guidance = {173 "1": "Clear, straightforward solution",174 "2": "Solution with specific advantages",175 "3": "Unique mechanism or proprietary method",176 "4": "Validated solution with research backing",177 "5": "Paradigm-shifting approach"178 }179 180 result_guidance = {181 "1": "Simple emotional outcome with basic proof",182 "2": "Specific results with comparative advantages",183 "3": "Detailed outcomes from unique approach",184 "4": "Evidence-backed results with specifics",185 "5": "Identity-level transformation stories"186 }187 188 formula_specific_guidance = f"""189For Contraste Revelador (Nivel {level_num}):190- Visión: {vision_guidance.get(level_num, "Create inspiring vision")}191- Solución: {solution_guidance.get(level_num, "Offer transformative solution")}192- Resultado: {result_guidance.get(level_num, "Show emotional transformation")}"""193 194 elif selected_formula_name == "Propuesta Única de Valor":195 # Guidance dictionaries for Propuesta Única de Valor196 transformation_guidance = {197 "1": "Clear, direct transformation",198 "2": "Specific, quantified transformation",199 "3": "Unique mechanism transformation",200 "4": "Evidence-backed, validated transformation",201 "5": "Identity-level, paradigm-shifting transformation"202 }203 204 objection_guidance = {205 "1": "Address basic concerns simply",206 "2": "Counter specific objections with advantages",207 "3": "Handle objections with unique approach",208 "4": "Evidence-based objection handling",209 "5": "Transform objections into strengths"210 }211 212 formula_specific_guidance = f"""213For Propuesta Única de Valor (Nivel {level_num}):214- Transformación: {transformation_guidance.get(level_num, "Focus on key transformation")}215- Objeciones: {objection_guidance.get(level_num, "Handle emotional objections")}"""216 217 # Add the concise guidance to the instruction218 instruction += f"\n\nSOPHISTICATION GUIDANCE (NIVEL {level_num}):{formula_specific_guidance}"219 220 return instruction221 222 223def create_integrated_instruction(target_audience=None, product_service=None, selected_formula_name=None, 224 file_content=None, bullet_content=None, bonus_content=None, skills=None, 225 sophistication_level=None):226 """227 Crea una instrucción integrada que combina la oferta principal, los beneficios y los bonos228 con un formato consistente para todas las fórmulas.229 230 Args:231 target_audience: Descripción del público objetivo232 product_service: Información del producto/servicio233 selected_formula_name: Nombre de la fórmula seleccionada234 file_content: Contenido de archivos subidos para la oferta principal235 bullet_content: Contenido de archivos subidos para los beneficios236 bonus_content: Contenido de archivos subidos para los bonos237 skills: Habilidades y experiencia del usuario238 sophistication_level: Nivel de sofisticación del mercado239 240 Returns:241 str: Instrucción completa e integrada242 """243 from bullets.generator import create_bullet_instruction244 from bonuses.generator import create_bonus_instruction245 246 # Crear la instrucción base para la oferta principal247 offer_instruction = create_offer_instruction(248 target_audience=target_audience,249 product_service=product_service,250 selected_formula_name=selected_formula_name,251 file_content=file_content,252 skills=skills,253 sophistication_level=sophistication_level254 )255 256 # Crear instrucciones para los beneficios257 try:258 bullet_instruction = create_bullet_instruction(259 target_audience=target_audience,260 product_service=product_service,261 selected_formula_name=selected_formula_name,262 uploaded_content=bullet_content or file_content, # Priorizar bullet_content si existe263 skills=skills264 )265 except TypeError:266 # Si la función no acepta selected_formula_name, llamarla sin ese parámetro267 bullet_instruction = create_bullet_instruction(268 target_audience=target_audience,269 product_service=product_service,270 uploaded_content=bullet_content or file_content, # Priorizar bullet_content si existe271 skills=skills272 )273 274 # Crear instrucciones para los bonos275 try:276 bonus_instruction = create_bonus_instruction(277 target_audience=target_audience,278 product_service=product_service,279 selected_formula_name=selected_formula_name,280 uploaded_content=bonus_content or file_content, # Priorizar bonus_content si existe281 skills=skills282 )283 except TypeError:284 # Si la función no acepta selected_formula_name, llamarla sin ese parámetro285 bonus_instruction = create_bonus_instruction(286 target_audience=target_audience,287 product_service=product_service,288 uploaded_content=bonus_content or file_content, # Priorizar bonus_content si existe289 skills=skills290 )291 292 # Instrucción de integración que especifica el formato exacto para todas las fórmulas293 integration_instruction = f"""294INSTRUCCIÓN DE INTEGRACIÓN IMPORTANTE:295 296Para cada una de las 3 versiones de oferta que generes, sigue EXACTAMENTE esta estructura:297 298VERSIÓN X:299[Promesa principal según la fórmula {selected_formula_name}]300 301BENEFICIOS:302• [Beneficio específico 1]303• [Beneficio específico 2]304• [Beneficio específico 3]305• [Beneficio específico 4]306• [Beneficio específico 5]307 308BONOS:309• BONO #1: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X310• BONO #2: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X311• BONO #3: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X312 313Valor total de bonos: $XXX - Todo incluido con tu inversión hoy.314 315IMPORTANTE: 316- Mantén esta estructura exacta para TODAS las fórmulas, incluyendo Propuesta Única de Valor317- Cada versión debe tener su propia sección de BENEFICIOS y BONOS318- Presenta las 3 versiones completas una tras otra319- No incluyas explicaciones o comentarios adicionales320"""321 322 # Combinar todas las instrucciones323 complete_instruction = offer_instruction + "\n\n" + bullet_instruction + "\n\n" + bonus_instruction + "\n\n" + integration_instruction324 325 return complete_instruction