File size: 10,461 Bytes
0943fed
520c50f
9e3f682
0943fed
58ff37d
0943fed
bf165e3
 
1bd2548
af55e5a
 
 
bf165e3
 
af55e5a
 
1bd2548
af55e5a
1bd2548
 
af55e5a
 
 
 
 
bf165e3
 
27908d2
bf165e3
e74b643
26ce1d0
 
 
81df141
e74b643
 
 
520c50f
e74b643
 
 
bf165e3
 
 
 
9e3f682
4362780
0625c7b
9e3f682
 
 
 
 
 
0943fed
bf165e3
 
 
 
 
 
 
81df141
bf165e3
 
b53d55e
bf165e3
9e3f682
 
 
26ce1d0
 
 
c3badaa
bf165e3
 
 
61c1e67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40b0916
bf165e3
 
520c50f
af55e5a
369b989
 
 
af55e5a
369b989
af55e5a
369b989
 
3ba0740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af55e5a
 
3ba0740
 
 
af55e5a
 
3ba0740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af55e5a
 
3ba0740
 
 
af55e5a
 
3ba0740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af55e5a
 
3ba0740
 
af55e5a
 
 
e74b643
3ba0740
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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('situacion', '')}\n"
                    instruction += f"Soluci贸n: {example.get('solucion', '')}\n"
                    instruction += f"Resultado: {example.get('resultado', '')}\n"
                
                elif selected_formula_name == "Propuesta 脷nica de Valor":
                    instruction += f"Transformaci贸n: {example.get('transformacion', '')}\n"
                    instruction += f"Objeciones: {example.get('objeciones', '')}\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