File size: 4,271 Bytes
9e3f682
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
92
93
94
95
def create_offer_instruction(product_service=None, uploaded_content=None, target_audience=None, skills=None, selected_formula=None):
    """

    Creates instructions for generating a compelling main offer based on deep avatar analysis.

    

    Args:

        product_service: Kind of product or service

        uploaded_content: Content from uploaded files (if any)

        target_audience: Description of the target audience

        skills: User's skills and expertise

        selected_formula: The specific formula to use for the offer

        

    Returns:

        str: Complete instruction for generating the main offer

    """
    # Check if any information is provided
    if not product_service and not target_audience and not uploaded_content and not skills:
        return """

        ADVERTENCIA: No se ha proporcionado ninguna informaci贸n para generar la oferta principal.

        

        Para crear una oferta efectiva y persuasiva, por favor proporciona al menos uno de los siguientes:

        - Descripci贸n del p煤blico objetivo (avatar)

        - Nombre del producto o servicio

        - Contenido adicional relevante

        - Habilidades y experiencia

        

        Sin esta informaci贸n, la oferta generada ser谩 gen茅rica y posiblemente menos efectiva.

        """
    
    # Import the avatar analysis module
    try:
        import sys
        import os
        sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
        from avatar_analysis import get_avatar_analysis_for_formula
        
        # Get the formula-specific avatar analysis
        avatar_analysis = get_avatar_analysis_for_formula(
            selected_formula if selected_formula else "general",
            target_audience,
            product_service,
            uploaded_content,
            skills
        )
    except ImportError:
        # Fallback if avatar_analysis module can't be imported
        avatar_analysis = f"""

        INFORMACI脫N DISPONIBLE PARA AN脕LISIS:

        

        1. DESCRIPCI脫N DEL P脷BLICO OBJETIVO:

        {target_audience if target_audience else "No se ha proporcionado descripci贸n espec铆fica del p煤blico objetivo."}

        

        2. PRODUCTO/SERVICIO:

        {product_service if product_service else "No se ha proporcionado nombre espec铆fico del producto/servicio."}

        

        3. CONTENIDO ADICIONAL:

        {uploaded_content if uploaded_content else "No se ha subido contenido adicional."}

        

        4. HABILIDADES Y EXPERIENCIA:

        {skills if skills else "No se han proporcionado habilidades espec铆ficas."}

        

        IMPORTANTE: Analiza TODA la informaci贸n disponible para identificar puntos de dolor espec铆ficos, objeciones y necesidades que puedan abordarse en la oferta principal.

        """
    
    # If a specific formula is selected, import and use it
    if selected_formula:
        try:
            # Import the formula module
            from formulas import offer_formulas
            
            # Get the formula-specific instructions
            formula_data = offer_formulas.get(selected_formula, {})
            formula_instruction = formula_data.get("instructions", "")
            
            # Combine with avatar analysis
            return f"{avatar_analysis}\n\n{formula_instruction}"
        except (ImportError, AttributeError, KeyError) as e:
            # More comprehensive error handling
            pass
    
    # If no formula is selected or there was an error, use the default comprehensive instructions
    base_instruction = """

    INSTRUCTIONS FOR CREATING AN IRRESISTIBLE OFFER:

    

    You are an expert in copywriting and persuasive marketing, specialized in creating offers that deeply connect with the avatar and generate conversions.

    

    OBJECTIVE:

    - Create a powerful and persuasive main offer in English

    - Connect emotionally with the avatar

    - Present a clear and desirable transformation

    - Position the product/service as the ideal solution

    - Use natural and conversational language

    """
    
    # Combine base instruction with avatar analysis
    return f"{avatar_analysis}\n\n{base_instruction}"