JeCabrera commited on
Commit
42713d1
·
verified ·
1 Parent(s): 1ddc35b

Upload 6 files

Browse files
Files changed (3) hide show
  1. app.py +3 -2
  2. formulas.py +3 -1
  3. prompts.py +133 -0
app.py CHANGED
@@ -5,6 +5,7 @@ import time
5
  from dotenv import load_dotenv
6
  from styles import get_custom_css, get_response_html_wrapper
7
  from formulas import offer_formulas
 
8
  import PyPDF2
9
  import docx
10
  from PIL import Image
@@ -20,8 +21,8 @@ load_dotenv()
20
  genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
21
  model = genai.GenerativeModel('gemini-2.0-flash')
22
 
23
- # Import the create_offer_instruction function from formulas
24
- from formulas import create_offer_instruction, offer_formulas
25
 
26
  # Initialize session state variables if they don't exist
27
  if 'submitted' not in st.session_state:
 
5
  from dotenv import load_dotenv
6
  from styles import get_custom_css, get_response_html_wrapper
7
  from formulas import offer_formulas
8
+ from prompts import create_offer_instruction
9
  import PyPDF2
10
  import docx
11
  from PIL import Image
 
21
  genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
22
  model = genai.GenerativeModel('gemini-2.0-flash')
23
 
24
+ # Remove duplicate import
25
+ # from formulas import create_offer_instruction, offer_formulas
26
 
27
  # Initialize session state variables if they don't exist
28
  if 'submitted' not in st.session_state:
formulas.py CHANGED
@@ -135,7 +135,9 @@ Create a compelling offer following the formula structure exactly.
135
 
136
  return instruction
137
 
138
- # The rest of your offer_formulas dictionary remains unchanged
 
 
139
  offer_formulas = {
140
  "Oferta Dorada": {
141
  "description": """
 
135
 
136
  return instruction
137
 
138
+ # Keep only the offer_formulas dictionary in this file
139
+
140
+ # The offer_formulas dictionary containing formula definitions
141
  offer_formulas = {
142
  "Oferta Dorada": {
143
  "description": """
prompts.py CHANGED
@@ -16,6 +16,139 @@ CRITICAL OUTPUT RULES:
16
  - Do not include phrases like "Aquí tienes una oferta convincente" or "Esta es tu oferta"
17
  """
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # System prompt for benefits generation
20
  system_prompt = """You are a world-class expert copywriter, experienced in creating benefits that emotionally connect and address the desires, problems, and motivations of the target audience.
21
 
 
16
  - Do not include phrases like "Aquí tienes una oferta convincente" or "Esta es tu oferta"
17
  """
18
 
19
+ # Import offer_formulas from formulas to use in the create_offer_instruction function
20
+ from formulas import offer_formulas
21
+
22
+ def create_offer_instruction(avatar_description, product_name, selected_formula_name):
23
+ """
24
+ Creates instructions for generating an offer based on the selected formula.
25
+
26
+ Args:
27
+ avatar_description: Description of the target audience
28
+ product_name: Name of the product or service
29
+ selected_formula_name: Name of the formula to use ("Fórmula Sueño-Obstáculo" or "Oferta Dorada")
30
+
31
+ Returns:
32
+ str: Complete instruction for generating the offer
33
+ """
34
+ # Get the selected formula
35
+ selected_formula = offer_formulas[selected_formula_name]
36
+
37
+ # Add specific instructions for each formula
38
+ additional_instructions = ""
39
+ if selected_formula_name == "Fórmula Sueño-Obstáculo":
40
+ additional_instructions = """
41
+ SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
42
+ 1. PRODUCT/SERVICE NAME HANDLING:
43
+ - If product_name is provided and not empty, use it EXACTLY as written
44
+ - If product_name is empty, generic (like "Producto/Servicio"), or contains placeholders, CREATE a compelling name that:
45
+ * Reflects the target audience's desires and challenges
46
+ * Communicates the main benefit or transformation
47
+ * Sounds professional and memorable
48
+ * Is specific to the niche or industry mentioned in avatar_description
49
+ - If product_name contains a full phrase like "Un curso llamado Inglés sin problemas", extract only the real name ("Inglés sin problemas")
50
+
51
+ 2. Analyze ALL available information:
52
+ - Product/service name (product_name variable) or create one if needed
53
+ - Target audience description (avatar_description)
54
+ - Content from uploaded files (if any)
55
+
56
+ 3. Determine the most appropriate type (curso, webinar, entrenamiento, etc.) based on:
57
+ - Any type mentioned in product_name
58
+ - The nature of the solution described in avatar_description
59
+ - The most suitable format for the target audience's needs
60
+
61
+ 4. Create a comprehensive offer by combining:
62
+ - The appropriate type (determined in step 3)
63
+ - The exact product name (if provided) or your created name (if needed)
64
+ - A compelling dream based on avatar_description
65
+ - A relevant obstacle based on avatar_description
66
+
67
+ 5. The dream should be ambitious but believable, incorporating:
68
+ - Target audience desires from avatar_description
69
+ - Explicit goals mentioned in uploaded content (if any)
70
+
71
+ 6. The obstacle should reflect:
72
+ - Real problems mentioned in avatar_description
73
+ - Challenges that would normally prevent achieving the dream
74
+
75
+ 7. IMPORTANT: Vary the way you start the phrase. Instead of always using "Se trata de un...", use different openings such as:
76
+ - "Presentamos un..."
77
+ - "Te ofrecemos un..."
78
+ - "Descubre nuestro..."
79
+ - "Conoce el..."
80
+ - "Hemos creado un..."
81
+ - "Imagina tener acceso a un..."
82
+ - "Por fin existe un..."
83
+ - "Ahora puedes acceder a un..."
84
+ - "Tenemos para ti un..."
85
+ - "Disfruta de un..."
86
+ """
87
+
88
+ elif selected_formula_name == "Oferta Dorada":
89
+ additional_instructions = """
90
+ SPECIFIC INSTRUCTIONS FOR THIS FORMULA:
91
+ 1. ATTENTION HOOK HANDLING:
92
+ - Analyze the avatar_description DEEPLY to understand their specific pain points, frustrations, and desires
93
+ - Select a powerful attention hook that DIRECTLY connects with the avatar's current reality
94
+ - DO NOT use questions as hooks - use statements, statistics, or shocking revelations instead
95
+ - CUSTOMIZE the hook specifically for this avatar - don't use generic examples
96
+ - The hook MUST address the SAME problem that your promise will solve
97
+
98
+ Choose randomly from these statement hooks and CUSTOMIZE for your avatar:
99
+ - "El 83% de los [avatar's profession/role] pierden [specific resource] en [specific activity] que nadie aprovecha."
100
+ - "9 de cada 10 [avatar's field] fracasan en sus primeros 6 meses por este error."
101
+ - "Lo que nadie te dice sobre [avatar's challenge] es que la mayoría fracasa en los primeros 3 meses."
102
+ - "El secreto que [competitors/industry] no quieren que sepas sobre [avatar's goal]."
103
+ - "Tu [avatar's current strategy/approach] está ahuyentando a tus [avatar's desired outcome]."
104
+ - "Mientras algunos [positive outcome], tú sigues [negative current situation]."
105
+ - "La mayoría de [current solutions] son una pérdida total de [resources]."
106
+ - "Hace 6 meses estaba exactamente donde tú estás: [avatar's current struggle]."
107
+
108
+ 2. MAINTAIN THEMATIC CONSISTENCY:
109
+ - The attention hook, quantifiable promise, and benefit statement MUST all address the SAME problem
110
+ - Create a LOGICAL PROGRESSION from problem (hook) to solution (promise) to implementation (benefit)
111
+
112
+ 3. Create a compelling QUANTIFIABLE PROMISE that:
113
+ - Is written COMPLETELY IN CAPITAL LETTERS
114
+ - Includes concrete numbers (money, time, results)
115
+ - Uses powerful action verbs (EARN, MULTIPLY, ACHIEVE, MASTER)
116
+ - Specifies the exact result they will obtain
117
+ - Optionally includes time or effort required
118
+ - NEVER uses exclamation marks (!)
119
+ - DIRECTLY addresses the same problem mentioned in the hook
120
+
121
+ 4. Craft a benefit statement that:
122
+ - Clearly explains the result they will obtain
123
+ - Includes an authority element (proven method, studies, experience)
124
+ - Establishes a realistic timeframe or effort needed
125
+ - CONTINUES the same theme established in the hook and promise
126
+ """
127
+
128
+ # Create the instruction using the system prompt at the beginning
129
+ instruction = f"""{offer_system_prompt}
130
+
131
+ FORMULA TO USE:
132
+ {selected_formula["description"]}
133
+
134
+ {additional_instructions}
135
+
136
+ PRODUCT/SERVICE:
137
+ {product_name}
138
+
139
+ TARGET AUDIENCE:
140
+ {avatar_description}
141
+
142
+ Create a compelling offer following the formula structure exactly.
143
+ """
144
+
145
+ # Add examples if available
146
+ if selected_formula.get("examples") and len(selected_formula["examples"]) > 0:
147
+ examples_text = "\n\n".join([f"Example {i+1}:\n{example}" for i, example in enumerate(selected_formula["examples"][:3])])
148
+ instruction += f"\n\nGet inspired by these examples:\n{examples_text}"
149
+
150
+ return instruction
151
+
152
  # System prompt for benefits generation
153
  system_prompt = """You are a world-class expert copywriter, experienced in creating benefits that emotionally connect and address the desires, problems, and motivations of the target audience.
154