Spaces:
Sleeping
Sleeping
| from formulas import offer_formulas | |
| from sophistication.generator import create_sophistication_instruction | |
| from avatar_analysis import analyze_avatar | |
| # Modify the offer_system_prompt to specify the correct format for PUV | |
| offer_system_prompt = """You are a world-class expert copywriter, experienced in creating compelling offers that connect emotionally with the target audience. | |
| OBJECTIVE: | |
| - Generate 3 COMPLETELY DIFFERENT versions of a convincing offer in Spanish | |
| - Each version must be CLEAR, CONCISE and FOCUSED on a SINGLE transformation | |
| - Connect emotionally with the audience's core desire | |
| - Use natural and conversational language | |
| CRITICAL OUTPUT RULES: | |
| - Create 3 DISTINCT versions with different angles and emotional appeals | |
| - Each version must focus on ONE problem/vision, ONE transformation, and ONE proof element | |
| - Number each version clearly as "VERSIÓN 1:", "VERSIÓN 2:", and "VERSIÓN 3:" | |
| - Output ONLY the offers themselves with NO explanations or commentary | |
| - Start each version directly with its corresponding formula structure | |
| - Present all 3 versions one after another, clearly separated | |
| FORMULA-SPECIFIC FOCUS: | |
| 1. Oferta Dorada: ONE specific problem, ONE clear transformation, ONE proof element | |
| 2. Contraste Revelador: ONE inspiring vision, ONE transformative solution, ONE emotional result | |
| 3. Propuesta Única de Valor: ONE powerful transformation, ONE emotional objection handler | |
| """ | |
| def create_offer_instruction(target_audience=None, product_service=None, selected_formula_name=None, file_content=None, skills=None, sophistication_level=None): | |
| """ | |
| Creates the instruction for generating an offer based on the selected formula. | |
| Args: | |
| target_audience: Description of the target audience | |
| product_service: Product/service information | |
| selected_formula_name: Name of the selected formula | |
| file_content: Content from uploaded files (if any) | |
| skills: User's skills and expertise | |
| sophistication_level: String key for the market sophistication level | |
| Returns: | |
| str: The complete instruction for generating the offer | |
| """ | |
| # Get the selected formula | |
| selected_formula = offer_formulas[selected_formula_name] | |
| # Get formula-specific instructions | |
| additional_instructions = selected_formula.get("instructions", "") | |
| # Process avatar analysis if target_audience is provided | |
| avatar_insights = "" | |
| if target_audience: | |
| avatar_insights = analyze_avatar(target_audience) # This would call your avatar analysis function | |
| # Create the base instruction with avatar insights | |
| instruction = f"""{offer_system_prompt} | |
| FORMULA TO USE: | |
| {selected_formula["description"]} | |
| {additional_instructions} | |
| PRODUCT/SERVICE: | |
| {product_service} | |
| TARGET AUDIENCE: | |
| {target_audience} | |
| AVATAR ANALYSIS: | |
| {avatar_insights} | |
| ADDITIONAL INFORMATION: | |
| {file_content} | |
| Create a compelling offer following the formula structure exactly, adapting it to the sophistication level provided. | |
| """ | |
| # Add examples if available | |
| if selected_formula.get("sophistication_examples") and sophistication_level: | |
| # Extract the sophistication level key (e.g., "nivel_1", "nivel_2", etc.) | |
| sophistication_key = sophistication_level.split(":")[0].lower().replace(" ", "_") | |
| # Map to the correct key format used in the examples | |
| if "nivel" not in sophistication_key: | |
| sophistication_key = f"nivel_{sophistication_key[0]}" | |
| # Get all examples for the specific sophistication level | |
| examples = [] | |
| for key, example in selected_formula["sophistication_examples"].items(): | |
| # Check if the key starts with the sophistication level (to include nivel_1, nivel_1_ejemplo2, etc.) | |
| if key.startswith(sophistication_key): | |
| examples.append(example) | |
| # Format all examples based on the formula type | |
| if examples: | |
| instruction += "\n\n### EXAMPLES FOR YOUR REFERENCE:\n" | |
| for i, example in enumerate(examples): | |
| instruction += f"\n#### Example {i+1}:\n" | |
| # Format based on formula type | |
| if selected_formula_name == "Oferta Dorada": | |
| instruction += f"Headline: {example.get('headline', '')}\n" | |
| instruction += f"Promise: {example.get('promise', '')}\n" | |
| instruction += f"Subtitle: {example.get('subtitle', '')}\n" | |
| elif selected_formula_name == "Contraste Revelador": | |
| instruction += f"Situación: {example.get('situation', '')}\n" | |
| instruction += f"Solución: {example.get('solution', '')}\n" | |
| instruction += f"Resultado: {example.get('result', '')}\n" | |
| elif selected_formula_name == "Propuesta Única de Valor": | |
| instruction += f"Transformación: {example.get('transformation', '')}\n" | |
| instruction += f"Objeciones: {example.get('objections', '')}\n" | |
| # Add more formula types as needed | |
| # Original code for general examples (keep as fallback) | |
| elif selected_formula.get("examples") and len(selected_formula["examples"]) > 0: | |
| examples_text = "\n\n".join([f"Example {i+1}:\n{example}" for i, example in enumerate(selected_formula["examples"])]) | |
| instruction += f"\n\nGet inspired by these examples:\n{examples_text}" | |
| # Add sophistication level guidance using the dedicated function | |
| if sophistication_level: | |
| # Get basic sophistication guidance | |
| base_sophistication_guidance = create_sophistication_instruction(sophistication_level) | |
| # Create concise formula-specific guidance based on sophistication level | |
| formula_specific_guidance = "" | |
| level_num = sophistication_level.split(":")[0].replace("Nivel ", "") | |
| if selected_formula_name == "Oferta Dorada": | |
| # Guidance dictionaries for Oferta Dorada | |
| headline_guidance = { | |
| "1": "Educational, introduce the concept as new", | |
| "2": "Differentiate from competitors, add specific benefits", | |
| "3": "Highlight unique mechanism or approach", | |
| "4": "Use data, research or challenge beliefs", | |
| "5": "Focus on identity and emotional transformation" | |
| } | |
| promise_guidance = { | |
| "1": "Direct and clear benefit without comparisons", | |
| "2": "Quantified benefit with specific advantage", | |
| "3": "Unique mechanism or proprietary method", | |
| "4": "Evidence-backed transformation with specifics", | |
| "5": "Identity shift and deeper meaning beyond results" | |
| } | |
| subtitle_guidance = { | |
| "1": "Simple proof with basic numbers", | |
| "2": "Comparative results with timeframes", | |
| "3": "Specific mechanism results with details", | |
| "4": "Research-backed evidence and guarantees", | |
| "5": "Community and movement-based validation" | |
| } | |
| formula_specific_guidance = f""" | |
| For Oferta Dorada (Nivel {level_num}): | |
| - Headline: {headline_guidance.get(level_num, "Match market awareness level")} | |
| - Promise: {promise_guidance.get(level_num, "Focus on transformation")} | |
| - Subtitle: {subtitle_guidance.get(level_num, "Provide appropriate proof")}""" | |
| elif selected_formula_name == "Contraste Revelador": | |
| # Guidance dictionaries for Contraste Revelador | |
| vision_guidance = { | |
| "1": "Simple, aspirational future state", | |
| "2": "Specific vision with clear advantages", | |
| "3": "Unique approach to achieving desires", | |
| "4": "Evidence-based optimal state", | |
| "5": "Transcendent vision beyond conventional goals" | |
| } | |
| solution_guidance = { | |
| "1": "Clear, straightforward solution", | |
| "2": "Solution with specific advantages", | |
| "3": "Unique mechanism or proprietary method", | |
| "4": "Validated solution with research backing", | |
| "5": "Paradigm-shifting approach" | |
| } | |
| result_guidance = { | |
| "1": "Simple emotional outcome with basic proof", | |
| "2": "Specific results with comparative advantages", | |
| "3": "Detailed outcomes from unique approach", | |
| "4": "Evidence-backed results with specifics", | |
| "5": "Identity-level transformation stories" | |
| } | |
| formula_specific_guidance = f""" | |
| For Contraste Revelador (Nivel {level_num}): | |
| - Visión: {vision_guidance.get(level_num, "Create inspiring vision")} | |
| - Solución: {solution_guidance.get(level_num, "Offer transformative solution")} | |
| - Resultado: {result_guidance.get(level_num, "Show emotional transformation")}""" | |
| elif selected_formula_name == "Propuesta Única de Valor": | |
| # Guidance dictionaries for Propuesta Única de Valor | |
| transformation_guidance = { | |
| "1": "Clear, direct transformation", | |
| "2": "Specific, quantified transformation", | |
| "3": "Unique mechanism transformation", | |
| "4": "Evidence-backed, validated transformation", | |
| "5": "Identity-level, paradigm-shifting transformation" | |
| } | |
| objection_guidance = { | |
| "1": "Address basic concerns simply", | |
| "2": "Counter specific objections with advantages", | |
| "3": "Handle objections with unique approach", | |
| "4": "Evidence-based objection handling", | |
| "5": "Transform objections into strengths" | |
| } | |
| formula_specific_guidance = f""" | |
| For Propuesta Única de Valor (Nivel {level_num}): | |
| - Transformación: {transformation_guidance.get(level_num, "Focus on key transformation")} | |
| - Objeciones: {objection_guidance.get(level_num, "Handle emotional objections")}""" | |
| # Add the concise guidance to the instruction | |
| instruction += f"\n\nSOPHISTICATION GUIDANCE (NIVEL {level_num}):{formula_specific_guidance}" | |
| return instruction | |
| def create_integrated_instruction(target_audience=None, product_service=None, selected_formula_name=None, | |
| file_content=None, bullet_content=None, bonus_content=None, skills=None, | |
| sophistication_level=None): | |
| """ | |
| Crea una instrucción integrada que combina la oferta principal, los beneficios y los bonos | |
| con un formato consistente para todas las fórmulas. | |
| Args: | |
| target_audience: Descripción del público objetivo | |
| product_service: Información del producto/servicio | |
| selected_formula_name: Nombre de la fórmula seleccionada | |
| file_content: Contenido de archivos subidos para la oferta principal | |
| bullet_content: Contenido de archivos subidos para los beneficios | |
| bonus_content: Contenido de archivos subidos para los bonos | |
| skills: Habilidades y experiencia del usuario | |
| sophistication_level: Nivel de sofisticación del mercado | |
| Returns: | |
| str: Instrucción completa e integrada | |
| """ | |
| from bullets.generator import create_bullet_instruction | |
| from bonuses.generator import create_bonus_instruction | |
| # Crear la instrucción base para la oferta principal | |
| offer_instruction = create_offer_instruction( | |
| target_audience=target_audience, | |
| product_service=product_service, | |
| selected_formula_name=selected_formula_name, | |
| file_content=file_content, | |
| skills=skills, | |
| sophistication_level=sophistication_level | |
| ) | |
| # Crear instrucciones para los beneficios | |
| try: | |
| bullet_instruction = create_bullet_instruction( | |
| target_audience=target_audience, | |
| product_service=product_service, | |
| selected_formula_name=selected_formula_name, | |
| uploaded_content=bullet_content or file_content, # Priorizar bullet_content si existe | |
| skills=skills | |
| ) | |
| except TypeError: | |
| # Si la función no acepta selected_formula_name, llamarla sin ese parámetro | |
| bullet_instruction = create_bullet_instruction( | |
| target_audience=target_audience, | |
| product_service=product_service, | |
| uploaded_content=bullet_content or file_content, # Priorizar bullet_content si existe | |
| skills=skills | |
| ) | |
| # Crear instrucciones para los bonos | |
| try: | |
| bonus_instruction = create_bonus_instruction( | |
| target_audience=target_audience, | |
| product_service=product_service, | |
| selected_formula_name=selected_formula_name, | |
| uploaded_content=bonus_content or file_content, # Priorizar bonus_content si existe | |
| skills=skills | |
| ) | |
| except TypeError: | |
| # Si la función no acepta selected_formula_name, llamarla sin ese parámetro | |
| bonus_instruction = create_bonus_instruction( | |
| target_audience=target_audience, | |
| product_service=product_service, | |
| uploaded_content=bonus_content or file_content, # Priorizar bonus_content si existe | |
| skills=skills | |
| ) | |
| # Instrucción de integración que especifica el formato exacto para todas las fórmulas | |
| integration_instruction = f""" | |
| INSTRUCCIÓN DE INTEGRACIÓN IMPORTANTE: | |
| Para cada una de las 3 versiones de oferta que generes, sigue EXACTAMENTE esta estructura: | |
| VERSIÓN X: | |
| [Promesa principal según la fórmula {selected_formula_name}] | |
| BENEFICIOS: | |
| • [Beneficio específico 1] | |
| • [Beneficio específico 2] | |
| • [Beneficio específico 3] | |
| • [Beneficio específico 4] | |
| • [Beneficio específico 5] | |
| BONOS: | |
| • BONO #1: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X | |
| • BONO #2: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X | |
| • BONO #3: [NOMBRE ATRACTIVO] - [Descripción breve] - Valor: $X | |
| Valor total de bonos: $XXX - Todo incluido con tu inversión hoy. | |
| IMPORTANTE: | |
| - Mantén esta estructura exacta para TODAS las fórmulas, incluyendo Propuesta Única de Valor | |
| - Cada versión debe tener su propia sección de BENEFICIOS y BONOS | |
| - Presenta las 3 versiones completas una tras otra | |
| - No incluyas explicaciones o comentarios adicionales | |
| """ | |
| # Combinar todas las instrucciones | |
| complete_instruction = offer_instruction + "\n\n" + bullet_instruction + "\n\n" + bonus_instruction + "\n\n" + integration_instruction | |
| return complete_instruction |