JeCabrera commited on
Commit
268f28a
·
verified ·
1 Parent(s): 0b6e682

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +539 -549
app.py CHANGED
@@ -1,550 +1,540 @@
1
- from dotenv import load_dotenv
2
- import streamlit as st
3
- import os
4
- import google.generativeai as genai
5
- import random
6
- import datetime
7
- from streamlit import session_state as state
8
- from formulas.webinar_formulas import webinar_formulas
9
- from formulas.webinar_name_formulas import webinar_name_formulas
10
- from formulas.angles_webinar_names import angles_webinar_names
11
-
12
- # Cargar las variables de entorno
13
- load_dotenv()
14
-
15
- # Configurar la API de Google
16
- genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
17
-
18
- # Función auxiliar para mostrar el contenido generado y los botones de descarga
19
- def display_generated_content(col, generated_content, content_type):
20
- timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
21
-
22
- # Determinar el tipo de contenido para personalizar los botones y títulos
23
- if content_type == "script":
24
- download_label = "DESCARGAR GUIÓN DE WEBINAR ▶▶"
25
- file_name = f"guion_webinar_{timestamp}.txt"
26
- subheader_text = "Tu guión de webinar:"
27
-
28
- # Mostrar botón de descarga superior para guiones
29
- col.download_button(
30
- label=download_label,
31
- data=generated_content,
32
- file_name=file_name,
33
- mime="text/plain",
34
- key=f"download_top_{content_type}"
35
- )
36
-
37
- # Mostrar el contenido generado
38
- col.subheader(subheader_text)
39
- col.markdown(generated_content)
40
-
41
- # Mostrar botón de descarga inferior
42
- col.download_button(
43
- label=download_label,
44
- data=generated_content,
45
- file_name=file_name,
46
- mime="text/plain",
47
- key=f"download_bottom_{content_type}"
48
- )
49
- else: # nombres
50
- subheader_text = "Tus nombres de webinar:"
51
- file_name = f"nombres_webinar_{timestamp}.txt"
52
- download_label = "DESCARGAR NOMBRES DE WEBINAR ▶▶"
53
-
54
- # Contar el número de nombres generados (aproximadamente por el número de líneas)
55
- num_names = len([line for line in generated_content.split('\n') if line.strip().startswith(('1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.', '10.', '11.', '12.', '13.', '14.', '15.'))])
56
-
57
- # Determinar si hay más de 5 nombres para mostrar los botones de descarga
58
- has_many_items = num_names > 5
59
-
60
- # Crear un contenedor con las clases adecuadas - Siempre aplicar el borde
61
- container_classes = "webinar-names-container with-border"
62
- if has_many_items:
63
- container_classes += " many-items"
64
-
65
- # Abrir el contenedor con las clases - ANTES de cualquier contenido
66
- col.markdown(f'<div class="{container_classes}">', unsafe_allow_html=True)
67
-
68
- # Mostrar botón de descarga superior solo si hay más de 5 nombres
69
- if has_many_items:
70
- col.download_button(
71
- label=download_label,
72
- data=generated_content,
73
- file_name=file_name,
74
- mime="text/plain",
75
- key=f"download_top_{content_type}",
76
- help="Descargar todos los nombres generados"
77
- )
78
-
79
- # Mostrar el contenido generado DENTRO del contenedor
80
- col.subheader(subheader_text)
81
- col.markdown(generated_content)
82
-
83
- # Mostrar botón de descarga inferior solo si hay más de 5 nombres
84
- if has_many_items:
85
- col.download_button(
86
- label=download_label,
87
- data=generated_content,
88
- file_name=file_name,
89
- mime="text/plain",
90
- key=f"download_bottom_{content_type}",
91
- help="Descargar todos los nombres generados"
92
- )
93
-
94
- # Cerrar el contenedor div DESPUÉS de todo el contenido
95
- col.markdown('</div>', unsafe_allow_html=True)
96
-
97
- # Implementar la función generate_and_display para reemplazar código duplicado
98
- def generate_and_display(col, generator_func, audience, product, temperature, selected_formula, content_type, **kwargs):
99
- if validate_inputs(audience, product):
100
- try:
101
- with col:
102
- with st.spinner(f"Generando {'guión' if content_type == 'script' else 'nombres'} de webinar...", show_time=True):
103
- # Llamar a la función generadora con los parámetros adecuados
104
- generated_content = generator_func(
105
- audience=audience,
106
- topic=product,
107
- temperature=temperature,
108
- selected_formula=selected_formula,
109
- **kwargs
110
- )
111
-
112
- # Mostrar el contenido generado usando la función auxiliar
113
- display_generated_content(col, generated_content, content_type)
114
-
115
- except ValueError as e:
116
- col.error(f"Error: {str(e)}")
117
- else:
118
- col.error("Por favor, proporciona el público objetivo y el tema del webinar.")
119
-
120
- # Función para crear la configuración del modelo (evita duplicación)
121
- def create_model_config(temperature):
122
- return {
123
- "temperature": temperature,
124
- "top_p": 0.65,
125
- "top_k": 360,
126
- "max_output_tokens": 8196,
127
- }
128
-
129
- # Función para inicializar el modelo
130
- def initialize_model(temperature):
131
- config = create_model_config(temperature)
132
- return genai.GenerativeModel(
133
- model_name="gemini-2.0-flash",
134
- generation_config=config,
135
- )
136
-
137
- # Refactored model interaction function to reduce duplication
138
- def generate_content(prompt_instructions, temperature):
139
- model = initialize_model(temperature)
140
- chat_session = model.start_chat(
141
- history=[
142
- {
143
- "role": "user",
144
- "parts": [prompt_instructions],
145
- },
146
- ]
147
- )
148
- response = chat_session.send_message("Generate the content following exactly the provided instructions. All content must be in Spanish.")
149
- return response.text
150
-
151
- # Función para generar nombres de webinars
152
- # Refactorizar la función generate_webinar_names para que acepte los mismos parámetros que generate_webinar_script
153
- def generate_webinar_names(audience, topic, temperature, selected_formula, number_of_names=5, selected_angle=None, **kwargs):
154
- # Incluir las instrucciones del sistema en el prompt principal
155
- system_prompt = """You are a world-class copywriter, with expertise in crafting compelling and disruptive webinar titles that immediately capture the audience's attention and drive registrations.
156
-
157
- FORMAT RULES:
158
- - Each webinar name must start with number and period
159
- - One webinar name per line
160
- - No explanations or categories
161
- - Add a line break between each name
162
- - Avoid unnecessary : symbols
163
- - Each webinar name must be a complete, intriguing and creative title
164
- - WRITE ALL WEBINAR NAMES IN SPANISH
165
-
166
- FORMAT EXAMPLE:
167
- 1. Nombre del Webinar 1.
168
-
169
- 2. Nombre del Webinar 2.
170
-
171
- 3. Nombre del Webinar 3.
172
-
173
- 4. Nombre del Webinar 4.
174
-
175
- 5. Nombre del Webinar 5.
176
-
177
- IMPORTANT:
178
- - Each webinar name must be unique, memorable and disruptive
179
- - Create curiosity and intrigue with unexpected combinations
180
- - Use creative language that stands out from typical webinar titles
181
- - Incorporate pattern interrupts that make people stop scrolling
182
- - Adapt speaking language from the audience
183
- - Focus on transformative benefits with creative angles
184
- - Follow the selected formula structure but add creative twists
185
- - WRITE ALL WEBINAR NAMES IN SPANISH"""
186
-
187
- # Iniciar el prompt con las instrucciones del sistema
188
- webinar_names_instruction = f"{system_prompt}\n\n"
189
-
190
- # Añadir instrucciones de ángulo solo si no es "NINGUNO" y se proporcionó un ángulo
191
- if selected_angle and selected_angle != "NINGUNO":
192
- webinar_names_instruction += f"""
193
- MAIN ANGLE: {selected_angle}
194
- SPECIFIC ANGLE INSTRUCTIONS:
195
- {angles_webinar_names[selected_angle]["instruction"]}
196
-
197
- IMPORTANT: The {selected_angle} angle should be applied as a "style layer" over the formula structure:
198
- 1. Keep the base structure of the formula intact
199
- 2. Apply the tone and style of the {selected_angle} angle
200
- 3. Ensure that each element of the formula reflects the angle
201
- 4. The angle affects "how" it is said, not "what" is said
202
-
203
- SUCCESSFUL EXAMPLES OF THE {selected_angle} ANGLE:
204
- """
205
- for example in angles_webinar_names[selected_angle]["examples"]:
206
- webinar_names_instruction += f"- {example}\n"
207
-
208
- # Instrucciones específicas para la tarea
209
- webinar_names_instruction += (
210
- f"\nYour task is to create {number_of_names} irresistible, creative and disruptive webinar names for {audience} "
211
- f"that instantly capture attention and generate registrations for a webinar about {topic}. "
212
- f"Focus on awakening genuine curiosity, creating intrigue, and communicating the value they will get by registering."
213
- f"\n\n"
214
- f"IMPORTANT: Use these examples of the selected formula as inspiration, but make your titles more creative and disruptive. "
215
- f"Each example represents a base structure to follow, but add unexpected elements and creative twists"
216
- f":\n\n"
217
- )
218
-
219
- # Agregar ejemplos aleatorios de la fórmula (keeping examples in Spanish)
220
- random_examples = random.sample(selected_formula['examples'], min(5, len(selected_formula['examples'])))
221
- webinar_names_instruction += "EXAMPLES OF THE FORMULA TO FOLLOW (BUT MAKE YOURS MORE CREATIVE):\n"
222
- for i, example in enumerate(random_examples, 1):
223
- webinar_names_instruction += f"{i}. {example}\n"
224
-
225
- # Instrucciones específicas (translated to English)
226
- webinar_names_instruction += "\nSPECIFIC INSTRUCTIONS:\n"
227
- webinar_names_instruction += "1. Use the same basic structure as the examples but add creative twists\n"
228
- webinar_names_instruction += "2. Create curiosity gaps that make people want to learn more\n"
229
- webinar_names_instruction += "3. Use unexpected word combinations that surprise the reader\n"
230
- webinar_names_instruction += "4. Incorporate pattern interrupts that make people stop and think\n"
231
- webinar_names_instruction += f"5. Adapt the content for {audience} while making titles more memorable and disruptive\n\n"
232
- webinar_names_instruction += f"FORMULA TO FOLLOW (AS A BASE):\n{selected_formula['description']}\n\n"
233
- webinar_names_instruction += f"""
234
- CREATIVE TECHNIQUES TO APPLY:
235
- 1. Use unexpected metaphors or analogies
236
- 2. Create intriguing contrasts or paradoxes
237
- 3. Challenge conventional wisdom with provocative statements
238
- 4. Use power words that evoke emotion
239
- 5. Create curiosity with incomplete loops or questions
240
- 6. Use specific numbers or data points that seem unusual
241
-
242
- GENERATE NOW:
243
- Create {number_of_names} creative, disruptive webinar names that use the formula structure as a base but add unexpected creative elements to make them stand out.
244
- """
245
-
246
- # Enviar el mensaje al modelo
247
- # Use the common generate_content function
248
- return generate_content(webinar_names_instruction, temperature)
249
-
250
- # Update the create_input_section function to include the product/offer field
251
- def create_input_section(col, audience_key, product_key, formulas, formula_key, offer_key=None):
252
- audience = col.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key=audience_key)
253
- product = col.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key=product_key)
254
-
255
- # Add the new product/offer field if a key is provided
256
- offer = None
257
- if offer_key:
258
- offer = col.text_input("¿Cuál es tu producto u oferta?", placeholder="Ejemplo: Curso de marketing de afiliados", key=offer_key)
259
-
260
- # Formula selection
261
- formula_keys = list(formulas.keys())
262
- selected_formula_key = col.selectbox(
263
- "Selecciona un framework de webinar",
264
- options=formula_keys,
265
- key=formula_key
266
- )
267
-
268
- if offer_key:
269
- return audience, product, selected_formula_key, offer
270
- else:
271
- return audience, product, selected_formula_key
272
-
273
- # Update the generate_webinar_script function to include the offer parameter
274
- def generate_webinar_script(audience, topic, temperature, selected_formula, offer=None, creative_idea=None):
275
- model = initialize_model(temperature)
276
-
277
- # Include offer in the system prompt if provided
278
- offer_text = f" and selling {offer}" if offer else ""
279
-
280
- # Incluir las instrucciones del sistema en el prompt principal
281
- system_prompt = f"""You are a collaborative team of world-class experts working together to create an exceptional webinar script that converts audience into customers.
282
-
283
- THE EXPERT TEAM:
284
-
285
- 1. MASTER WEBINAR STRATEGIST:
286
- - Expert in webinar frameworks and conversion strategies
287
- - Trained in the Perfect Webinar methodology by Russell Brunson
288
- - Ensures the script follows the selected framework structure precisely
289
- - Focuses on strategic placement of key conversion elements
290
-
291
- 2. ELITE DIRECT RESPONSE COPYWRITER:
292
- - Trained by Gary Halbert, Gary Bencivenga, and David Ogilvy
293
- - Creates compelling hooks, stories, and persuasive elements
294
- - Crafts irresistible calls to action that drives conversions
295
- - Ensures the language resonates with the target audience
296
-
297
- 3. AUDIENCE PSYCHOLOGY SPECIALIST:
298
- - Expert in understanding audience motivations and objections
299
- - Creates content that builds genuine connection and trust
300
- - Identifies and addresses hidden fears and desires
301
- - Ensures the content feels personal and relevant
302
-
303
- 4. STORYTELLING MASTER:
304
- - Creates compelling narratives that illustrate key points
305
- - Develops relatable examples and case studies
306
- - Ensures stories support the transformation being offered
307
- - Makes complex concepts accessible through narrative
308
-
309
- 5. WEBINAR ENGAGEMENT EXPERT:
310
- - Specializes in maintaining audience attention throughout
311
- - Creates interactive elements and engagement hooks
312
- - Develops compelling transitions between sections
313
- - Ensures the webinar flows naturally and keeps interest high
314
-
315
- FORMAT REQUIREMENTS:
316
- - Create a complete webinar script with clear sections and subsections
317
- - Include specific talking points for each section
318
- - Write in a conversational, engaging tone
319
- - Include persuasive elements and calls to action
320
- - Follow the selected webinar framework structure exactly
321
- - WRITE THE ENTIRE SCRIPT IN SPANISH
322
- - Start directly with the webinar content without introductory text
323
- - DO NOT include any explanatory text at the beginning like "Here's the webinar script..." or "I've created a webinar script..."
324
-
325
- COLLABORATIVE PROCESS:
326
- As a team of experts, you will:
327
- 1. Analyze the framework '{selected_formula['description']}' to understand its core principles
328
- 2. Identify how to best adapt this framework for {audience} learning about {topic}{offer_text}
329
- 3. Create persuasive language that resonates with {audience}
330
- 4. Ensure the script maintains engagement throughout
331
- 5. Follow the exact structure provided in the framework"""
332
-
333
- # Añadir instrucciones para la idea creativa si existe
334
- if creative_idea:
335
- system_prompt += f"""
336
- CREATIVE CONCEPT:
337
- Use the following creative concept as the central theme for the webinar:
338
- "{creative_idea}"
339
-
340
- CREATIVE CONCEPT INSTRUCTIONS:
341
- 1. This concept should be the unifying theme across the entire webinar
342
- 2. Use it as a metaphor or analogy throughout the presentation
343
- 3. Develop different aspects of this concept in each section
344
- 4. Make sure the concept naturally connects to the product benefits
345
- 5. The concept should make the webinar more memorable and engaging
346
- """
347
-
348
- # Update the task instructions to include the offer
349
- offer_instruction = f" and selling {offer}" if offer else ""
350
-
351
- # Instrucciones específicas para la tarea
352
- webinar_script_instruction = (
353
- f"{system_prompt}\n\n"
354
- f"\nYour task is to create a complete webinar script IN SPANISH for {audience} "
355
- f"about {topic}{offer_instruction} that is persuasive and converts the audience into customers. "
356
- f"The script must follow exactly the structure of the framework '{selected_formula['description']}' "
357
- f"and must include all the necessary elements for a successful webinar."
358
- f"\n\n"
359
- )
360
-
361
- # Estructura del webinar
362
- webinar_script_instruction += "WEBINAR STRUCTURE TO FOLLOW:\n"
363
- for i, step in enumerate(selected_formula['structure'], 1):
364
- webinar_script_instruction += f"{i}. {step}\n"
365
-
366
- # Ejemplos de webinars exitosos
367
- webinar_script_instruction += "\n\nEXAMPLES OF SUCCESSFUL WEBINARS WITH THIS STRUCTURE:\n"
368
- for i, example in enumerate(selected_formula['examples'], 1):
369
- webinar_script_instruction += f"{i}. {example}\n"
370
-
371
- # Instrucciones específicas - Reforzar el español
372
- webinar_script_instruction += f"""
373
- SPECIFIC INSTRUCTIONS:
374
- 1. Create a complete script that follows exactly the provided structure
375
- 2. Include persuasive elements and clear calls to action
376
- 3. Adapt the language and examples specifically for {audience}
377
- 4. Focus on the transformative benefits of {topic}
378
- 5. Include relevant stories and examples that reinforce your points
379
- 6. Use a conversational but professional tone
380
- 7. Make sure each section fulfills its specific purpose in the framework
381
- 8. IMPORTANT: Write the ENTIRE script in Spanish (neutral Latin American Spanish)
382
- 9. DO NOT include any introductory text like "Here's the webinar script..." or "I've created a webinar script..."
383
- 10. Start directly with the webinar title and content
384
- 11. ALL section titles, headers, and content MUST be in Spanish
385
- 12. Ensure ALL examples, stories, and calls to action are in Spanish
386
-
387
- GENERATE NOW:
388
- Create a complete webinar script following faithfully the structure of the selected framework, entirely in Spanish.
389
- """
390
-
391
- # Enviar el mensaje al modelo
392
- chat_session = model.start_chat(
393
- history=[
394
- {
395
- "role": "user",
396
- "parts": [webinar_script_instruction],
397
- },
398
- ]
399
- )
400
- response = chat_session.send_message("Generate the webinar script IN NEUTRAL SPANISH following exactly the provided structure. All content must be in neutral Spanish (not Spain Spanish). Start directly with the webinar content without any introductory text.")
401
-
402
- return response.text
403
-
404
- # Función para validar entradas (evita duplicación)
405
- def validate_inputs(audience, product):
406
- has_audience = audience.strip() != ""
407
- has_product = product.strip() != ""
408
- return has_audience and has_product
409
-
410
- # Update the load_css function comment to be more descriptive
411
- def load_css():
412
- css_path = "styles/styles.css"
413
- if os.path.exists(css_path):
414
- try:
415
- with open(css_path, "r") as f:
416
- st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
417
- except Exception as e:
418
- st.warning(f"Error al cargar el archivo CSS: {str(e)}")
419
- else:
420
- st.warning(f"No se encontró el archivo CSS en {css_path}")
421
-
422
- # Modify the page config section to include the CSS loading and remove menu
423
- st.set_page_config(
424
- page_title="Perfect Webinar Framework",
425
- layout="wide",
426
- initial_sidebar_state="expanded",
427
- menu_items=None # This removes the three dots menu
428
- )
429
- load_css() # This will load the styles from styles.css
430
-
431
- # Leer el contenido del archivo manual.md
432
- with open("manual.md", "r", encoding="utf-8") as file:
433
- manual_content = file.read()
434
-
435
- # Mostrar el contenido del manual en el sidebar
436
- st.sidebar.markdown(manual_content)
437
-
438
- # Agregar título y subtítulo usando HTML
439
- st.markdown("<h1 style='text-align: center;'>Perfect Webinar Framework</h1>", unsafe_allow_html=True)
440
- st.markdown("<h3 style='text-align: center;'>Crea guiones y títulos de webinars persuasivos que convierten</h3>", unsafe_allow_html=True)
441
-
442
- # Crear pestañas para la interfaz
443
- tab1, tab2 = st.tabs(["Guiones de Webinar", "Nombres de Webinar"])
444
-
445
- # Primera pestaña - Generador de Guiones de Webinar
446
- with tab1:
447
- tab1.subheader("Script Webinar")
448
-
449
- # Crear columnas para la interfaz
450
- col1, col2 = tab1.columns([1, 2])
451
-
452
- # Columna de entrada usando la función reutilizable
453
- with col1:
454
- # Inputs básicos (fuera del acordeón)
455
- webinar_script_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key="webinar_script_audience")
456
- webinar_script_product = st.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key="webinar_script_product")
457
- webinar_script_offer = st.text_input("¿Cuál es tu producto u oferta?", placeholder="Ejemplo: Curso de marketing de afiliados", key="webinar_script_offer")
458
-
459
- # Botón de generación (movido aquí, justo después de los campos principales)
460
- submit_webinar_script = st.button("GENERAR GUIÓN DE WEBINAR ▶▶", key="generate_webinar_script")
461
-
462
- # Opciones avanzadas en el acordeón
463
- with st.expander("Personaliza tu guión de webinar"):
464
- # Selector de fórmula (ahora dentro del acordeón)
465
- selected_webinar_formula_key = st.selectbox(
466
- "Selecciona un framework de webinar",
467
- options=list(webinar_formulas.keys()),
468
- key="webinar_formula"
469
- )
470
-
471
- # Nuevo campo para la idea creativa
472
- creative_idea = st.text_area(
473
- "Idea creativa (opcional)",
474
- placeholder="Introduce una idea o concepto creativo que quieras usar como tema central en tu webinar",
475
- help="Este concepto será el tema unificador a lo largo de tu webinar, haciéndolo más memorable y atractivo",
476
- key="webinar_creative_idea"
477
- )
478
-
479
- # Slider de creatividad (ya existente)
480
- webinar_script_temperature = st.slider("Creatividad", min_value=0.0, max_value=2.0, value=1.0, step=0.1, key="webinar_script_temp")
481
-
482
- selected_webinar_formula = webinar_formulas[selected_webinar_formula_key]
483
-
484
- # Usar la función generate_and_display para generar y mostrar el guión
485
- if submit_webinar_script:
486
- generate_and_display(
487
- col=col2,
488
- generator_func=generate_webinar_script,
489
- audience=webinar_script_audience,
490
- product=webinar_script_product,
491
- temperature=webinar_script_temperature,
492
- selected_formula=selected_webinar_formula,
493
- content_type="script",
494
- offer=webinar_script_offer if webinar_script_offer.strip() else None,
495
- creative_idea=creative_idea if creative_idea.strip() else None
496
- )
497
-
498
- # Segunda pestaña - Generador de Nombres de Webinar
499
- with tab2:
500
- tab2.subheader("Nombres de Webinar")
501
-
502
- # Crear columnas para la interfaz
503
- col1, col2 = tab2.columns([1, 2])
504
-
505
- # Columna de entrada
506
- with col1:
507
- # Inputs básicos
508
- webinar_names_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key="webinar_names_audience")
509
- webinar_names_product = st.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key="webinar_names_product")
510
-
511
- # Botón de generación (movido aquí, justo después de los campos principales)
512
- submit_webinar_names = st.button("GENERAR NOMBRES DE WEBINAR ▶▶", key="generate_webinar_names")
513
-
514
- # Opciones avanzadas en el acordeón
515
- with st.expander("Personaliza tus nombres de webinar"):
516
- # Selector de fórmula
517
- selected_name_formula_key = st.selectbox(
518
- "Selecciona una fórmula para tus nombres",
519
- options=list(webinar_name_formulas.keys()),
520
- key="webinar_name_formula"
521
- )
522
-
523
- # Selector de ángulo
524
- selected_angle = st.selectbox(
525
- "Selecciona un ángulo (opcional)",
526
- options=["NINGUNO"] + list(angles_webinar_names.keys()),
527
- key="webinar_name_angle"
528
- )
529
-
530
- # Número de nombres a generar
531
- number_of_names = st.slider("Número de nombres a generar", min_value=3, max_value=15, value=5, step=1, key="number_of_names")
532
-
533
- # Slider de creatividad
534
- webinar_names_temperature = st.slider("Creatividad", min_value=0.0, max_value=2.0, value=1.0, step=0.1, key="webinar_names_temp")
535
-
536
- selected_name_formula = webinar_name_formulas[selected_name_formula_key]
537
-
538
- # Usar la función generate_and_display para generar y mostrar los nombres
539
- if submit_webinar_names:
540
- generate_and_display(
541
- col=col2,
542
- generator_func=generate_webinar_names,
543
- audience=webinar_names_audience,
544
- product=webinar_names_product,
545
- temperature=webinar_names_temperature,
546
- selected_formula=selected_name_formula,
547
- content_type="names",
548
- number_of_names=number_of_names,
549
- selected_angle=selected_angle if selected_angle != "NINGUNO" else None
550
  )
 
1
+ from dotenv import load_dotenv
2
+ import streamlit as st
3
+ import os
4
+ import google.generativeai as genai
5
+ import random
6
+ import datetime
7
+ from streamlit import session_state as state
8
+ from formulas.webinar_formulas import webinar_formulas
9
+ from formulas.webinar_name_formulas import webinar_name_formulas
10
+ from formulas.angles_webinar_names import angles_webinar_names
11
+
12
+ # Cargar las variables de entorno
13
+ load_dotenv()
14
+
15
+ # Configurar la API de Google
16
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
17
+
18
+ # Función auxiliar para mostrar el contenido generado y los botones de descarga
19
+ def display_generated_content(col, generated_content, content_type):
20
+ timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
21
+
22
+ # Determinar el tipo de contenido para personalizar los botones y títulos
23
+ if content_type == "script":
24
+ download_label = "DESCARGAR GUIÓN DE WEBINAR ▶▶"
25
+ file_name = f"guion_webinar_{timestamp}.txt"
26
+ subheader_text = "Tu guión de webinar:"
27
+
28
+ # Mostrar botón de descarga superior para guiones
29
+ col.download_button(
30
+ label=download_label,
31
+ data=generated_content,
32
+ file_name=file_name,
33
+ mime="text/plain",
34
+ key=f"download_top_{content_type}"
35
+ )
36
+
37
+ # Mostrar el contenido generado
38
+ col.subheader(subheader_text)
39
+ col.markdown(generated_content)
40
+
41
+ # Mostrar botón de descarga inferior
42
+ col.download_button(
43
+ label=download_label,
44
+ data=generated_content,
45
+ file_name=file_name,
46
+ mime="text/plain",
47
+ key=f"download_bottom_{content_type}"
48
+ )
49
+ else: # nombres
50
+ subheader_text = "Tus nombres de webinar:"
51
+ file_name = f"nombres_webinar_{timestamp}.txt"
52
+ download_label = "DESCARGAR NOMBRES DE WEBINAR ▶▶"
53
+
54
+ # Contar el número de nombres generados (aproximadamente por el número de líneas)
55
+ num_names = len([line for line in generated_content.split('\n') if line.strip().startswith(('1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.', '10.', '11.', '12.', '13.', '14.', '15.'))])
56
+
57
+ # Determinar si hay más de 5 nombres para mostrar los botones de descarga
58
+ has_many_items = num_names > 5
59
+
60
+ # Para los nombres, NO usamos un contenedor div personalizado
61
+ # Simplemente mostramos el botón de descarga superior si hay muchos nombres
62
+ if has_many_items:
63
+ col.download_button(
64
+ label=download_label,
65
+ data=generated_content,
66
+ file_name=file_name,
67
+ mime="text/plain",
68
+ key=f"download_top_names",
69
+ help="Descargar todos los nombres generados"
70
+ )
71
+
72
+ # Mostrar el contenido generado
73
+ col.subheader(subheader_text)
74
+ col.markdown(generated_content)
75
+
76
+ # Mostrar botón de descarga inferior solo si hay más de 5 nombres
77
+ if has_many_items:
78
+ col.download_button(
79
+ label=download_label,
80
+ data=generated_content,
81
+ file_name=file_name,
82
+ mime="text/plain",
83
+ key=f"download_bottom_names",
84
+ help="Descargar todos los nombres generados"
85
+ )
86
+
87
+ # Implementar la función generate_and_display para reemplazar código duplicado
88
+ def generate_and_display(col, generator_func, audience, product, temperature, selected_formula, content_type, **kwargs):
89
+ if validate_inputs(audience, product):
90
+ try:
91
+ with col:
92
+ with st.spinner(f"Generando {'guión' if content_type == 'script' else 'nombres'} de webinar...", show_time=True):
93
+ # Llamar a la función generadora con los parámetros adecuados
94
+ generated_content = generator_func(
95
+ audience=audience,
96
+ topic=product,
97
+ temperature=temperature,
98
+ selected_formula=selected_formula,
99
+ **kwargs
100
+ )
101
+
102
+ # Mostrar el contenido generado usando la función auxiliar
103
+ display_generated_content(col, generated_content, content_type)
104
+
105
+ except ValueError as e:
106
+ col.error(f"Error: {str(e)}")
107
+ else:
108
+ col.error("Por favor, proporciona el público objetivo y el tema del webinar.")
109
+
110
+ # Función para crear la configuración del modelo (evita duplicación)
111
+ def create_model_config(temperature):
112
+ return {
113
+ "temperature": temperature,
114
+ "top_p": 0.65,
115
+ "top_k": 360,
116
+ "max_output_tokens": 8196,
117
+ }
118
+
119
+ # Función para inicializar el modelo
120
+ def initialize_model(temperature):
121
+ config = create_model_config(temperature)
122
+ return genai.GenerativeModel(
123
+ model_name="gemini-2.0-flash",
124
+ generation_config=config,
125
+ )
126
+
127
+ # Refactored model interaction function to reduce duplication
128
+ def generate_content(prompt_instructions, temperature):
129
+ model = initialize_model(temperature)
130
+ chat_session = model.start_chat(
131
+ history=[
132
+ {
133
+ "role": "user",
134
+ "parts": [prompt_instructions],
135
+ },
136
+ ]
137
+ )
138
+ response = chat_session.send_message("Generate the content following exactly the provided instructions. All content must be in Spanish.")
139
+ return response.text
140
+
141
+ # Función para generar nombres de webinars
142
+ # Refactorizar la función generate_webinar_names para que acepte los mismos parámetros que generate_webinar_script
143
+ def generate_webinar_names(audience, topic, temperature, selected_formula, number_of_names=5, selected_angle=None, **kwargs):
144
+ # Incluir las instrucciones del sistema en el prompt principal
145
+ system_prompt = """You are a world-class copywriter, with expertise in crafting compelling and disruptive webinar titles that immediately capture the audience's attention and drive registrations.
146
+
147
+ FORMAT RULES:
148
+ - Each webinar name must start with number and period
149
+ - One webinar name per line
150
+ - No explanations or categories
151
+ - Add a line break between each name
152
+ - Avoid unnecessary : symbols
153
+ - Each webinar name must be a complete, intriguing and creative title
154
+ - WRITE ALL WEBINAR NAMES IN SPANISH
155
+
156
+ FORMAT EXAMPLE:
157
+ 1. Nombre del Webinar 1.
158
+
159
+ 2. Nombre del Webinar 2.
160
+
161
+ 3. Nombre del Webinar 3.
162
+
163
+ 4. Nombre del Webinar 4.
164
+
165
+ 5. Nombre del Webinar 5.
166
+
167
+ IMPORTANT:
168
+ - Each webinar name must be unique, memorable and disruptive
169
+ - Create curiosity and intrigue with unexpected combinations
170
+ - Use creative language that stands out from typical webinar titles
171
+ - Incorporate pattern interrupts that make people stop scrolling
172
+ - Adapt speaking language from the audience
173
+ - Focus on transformative benefits with creative angles
174
+ - Follow the selected formula structure but add creative twists
175
+ - WRITE ALL WEBINAR NAMES IN SPANISH"""
176
+
177
+ # Iniciar el prompt con las instrucciones del sistema
178
+ webinar_names_instruction = f"{system_prompt}\n\n"
179
+
180
+ # Añadir instrucciones de ángulo solo si no es "NINGUNO" y se proporcionó un ángulo
181
+ if selected_angle and selected_angle != "NINGUNO":
182
+ webinar_names_instruction += f"""
183
+ MAIN ANGLE: {selected_angle}
184
+ SPECIFIC ANGLE INSTRUCTIONS:
185
+ {angles_webinar_names[selected_angle]["instruction"]}
186
+
187
+ IMPORTANT: The {selected_angle} angle should be applied as a "style layer" over the formula structure:
188
+ 1. Keep the base structure of the formula intact
189
+ 2. Apply the tone and style of the {selected_angle} angle
190
+ 3. Ensure that each element of the formula reflects the angle
191
+ 4. The angle affects "how" it is said, not "what" is said
192
+
193
+ SUCCESSFUL EXAMPLES OF THE {selected_angle} ANGLE:
194
+ """
195
+ for example in angles_webinar_names[selected_angle]["examples"]:
196
+ webinar_names_instruction += f"- {example}\n"
197
+
198
+ # Instrucciones específicas para la tarea
199
+ webinar_names_instruction += (
200
+ f"\nYour task is to create {number_of_names} irresistible, creative and disruptive webinar names for {audience} "
201
+ f"that instantly capture attention and generate registrations for a webinar about {topic}. "
202
+ f"Focus on awakening genuine curiosity, creating intrigue, and communicating the value they will get by registering."
203
+ f"\n\n"
204
+ f"IMPORTANT: Use these examples of the selected formula as inspiration, but make your titles more creative and disruptive. "
205
+ f"Each example represents a base structure to follow, but add unexpected elements and creative twists"
206
+ f":\n\n"
207
+ )
208
+
209
+ # Agregar ejemplos aleatorios de la fórmula (keeping examples in Spanish)
210
+ random_examples = random.sample(selected_formula['examples'], min(5, len(selected_formula['examples'])))
211
+ webinar_names_instruction += "EXAMPLES OF THE FORMULA TO FOLLOW (BUT MAKE YOURS MORE CREATIVE):\n"
212
+ for i, example in enumerate(random_examples, 1):
213
+ webinar_names_instruction += f"{i}. {example}\n"
214
+
215
+ # Instrucciones específicas (translated to English)
216
+ webinar_names_instruction += "\nSPECIFIC INSTRUCTIONS:\n"
217
+ webinar_names_instruction += "1. Use the same basic structure as the examples but add creative twists\n"
218
+ webinar_names_instruction += "2. Create curiosity gaps that make people want to learn more\n"
219
+ webinar_names_instruction += "3. Use unexpected word combinations that surprise the reader\n"
220
+ webinar_names_instruction += "4. Incorporate pattern interrupts that make people stop and think\n"
221
+ webinar_names_instruction += f"5. Adapt the content for {audience} while making titles more memorable and disruptive\n\n"
222
+ webinar_names_instruction += f"FORMULA TO FOLLOW (AS A BASE):\n{selected_formula['description']}\n\n"
223
+ webinar_names_instruction += f"""
224
+ CREATIVE TECHNIQUES TO APPLY:
225
+ 1. Use unexpected metaphors or analogies
226
+ 2. Create intriguing contrasts or paradoxes
227
+ 3. Challenge conventional wisdom with provocative statements
228
+ 4. Use power words that evoke emotion
229
+ 5. Create curiosity with incomplete loops or questions
230
+ 6. Use specific numbers or data points that seem unusual
231
+
232
+ GENERATE NOW:
233
+ Create {number_of_names} creative, disruptive webinar names that use the formula structure as a base but add unexpected creative elements to make them stand out.
234
+ """
235
+
236
+ # Enviar el mensaje al modelo
237
+ # Use the common generate_content function
238
+ return generate_content(webinar_names_instruction, temperature)
239
+
240
+ # Update the create_input_section function to include the product/offer field
241
+ def create_input_section(col, audience_key, product_key, formulas, formula_key, offer_key=None):
242
+ audience = col.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key=audience_key)
243
+ product = col.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key=product_key)
244
+
245
+ # Add the new product/offer field if a key is provided
246
+ offer = None
247
+ if offer_key:
248
+ offer = col.text_input("¿Cuál es tu producto u oferta?", placeholder="Ejemplo: Curso de marketing de afiliados", key=offer_key)
249
+
250
+ # Formula selection
251
+ formula_keys = list(formulas.keys())
252
+ selected_formula_key = col.selectbox(
253
+ "Selecciona un framework de webinar",
254
+ options=formula_keys,
255
+ key=formula_key
256
+ )
257
+
258
+ if offer_key:
259
+ return audience, product, selected_formula_key, offer
260
+ else:
261
+ return audience, product, selected_formula_key
262
+
263
+ # Update the generate_webinar_script function to include the offer parameter
264
+ def generate_webinar_script(audience, topic, temperature, selected_formula, offer=None, creative_idea=None):
265
+ model = initialize_model(temperature)
266
+
267
+ # Include offer in the system prompt if provided
268
+ offer_text = f" and selling {offer}" if offer else ""
269
+
270
+ # Incluir las instrucciones del sistema en el prompt principal
271
+ system_prompt = f"""You are a collaborative team of world-class experts working together to create an exceptional webinar script that converts audience into customers.
272
+
273
+ THE EXPERT TEAM:
274
+
275
+ 1. MASTER WEBINAR STRATEGIST:
276
+ - Expert in webinar frameworks and conversion strategies
277
+ - Trained in the Perfect Webinar methodology by Russell Brunson
278
+ - Ensures the script follows the selected framework structure precisely
279
+ - Focuses on strategic placement of key conversion elements
280
+
281
+ 2. ELITE DIRECT RESPONSE COPYWRITER:
282
+ - Trained by Gary Halbert, Gary Bencivenga, and David Ogilvy
283
+ - Creates compelling hooks, stories, and persuasive elements
284
+ - Crafts irresistible calls to action that drives conversions
285
+ - Ensures the language resonates with the target audience
286
+
287
+ 3. AUDIENCE PSYCHOLOGY SPECIALIST:
288
+ - Expert in understanding audience motivations and objections
289
+ - Creates content that builds genuine connection and trust
290
+ - Identifies and addresses hidden fears and desires
291
+ - Ensures the content feels personal and relevant
292
+
293
+ 4. STORYTELLING MASTER:
294
+ - Creates compelling narratives that illustrate key points
295
+ - Develops relatable examples and case studies
296
+ - Ensures stories support the transformation being offered
297
+ - Makes complex concepts accessible through narrative
298
+
299
+ 5. WEBINAR ENGAGEMENT EXPERT:
300
+ - Specializes in maintaining audience attention throughout
301
+ - Creates interactive elements and engagement hooks
302
+ - Develops compelling transitions between sections
303
+ - Ensures the webinar flows naturally and keeps interest high
304
+
305
+ FORMAT REQUIREMENTS:
306
+ - Create a complete webinar script with clear sections and subsections
307
+ - Include specific talking points for each section
308
+ - Write in a conversational, engaging tone
309
+ - Include persuasive elements and calls to action
310
+ - Follow the selected webinar framework structure exactly
311
+ - WRITE THE ENTIRE SCRIPT IN SPANISH
312
+ - Start directly with the webinar content without introductory text
313
+ - DO NOT include any explanatory text at the beginning like "Here's the webinar script..." or "I've created a webinar script..."
314
+
315
+ COLLABORATIVE PROCESS:
316
+ As a team of experts, you will:
317
+ 1. Analyze the framework '{selected_formula['description']}' to understand its core principles
318
+ 2. Identify how to best adapt this framework for {audience} learning about {topic}{offer_text}
319
+ 3. Create persuasive language that resonates with {audience}
320
+ 4. Ensure the script maintains engagement throughout
321
+ 5. Follow the exact structure provided in the framework"""
322
+
323
+ # Añadir instrucciones para la idea creativa si existe
324
+ if creative_idea:
325
+ system_prompt += f"""
326
+ CREATIVE CONCEPT:
327
+ Use the following creative concept as the central theme for the webinar:
328
+ "{creative_idea}"
329
+
330
+ CREATIVE CONCEPT INSTRUCTIONS:
331
+ 1. This concept should be the unifying theme across the entire webinar
332
+ 2. Use it as a metaphor or analogy throughout the presentation
333
+ 3. Develop different aspects of this concept in each section
334
+ 4. Make sure the concept naturally connects to the product benefits
335
+ 5. The concept should make the webinar more memorable and engaging
336
+ """
337
+
338
+ # Update the task instructions to include the offer
339
+ offer_instruction = f" and selling {offer}" if offer else ""
340
+
341
+ # Instrucciones específicas para la tarea
342
+ webinar_script_instruction = (
343
+ f"{system_prompt}\n\n"
344
+ f"\nYour task is to create a complete webinar script IN SPANISH for {audience} "
345
+ f"about {topic}{offer_instruction} that is persuasive and converts the audience into customers. "
346
+ f"The script must follow exactly the structure of the framework '{selected_formula['description']}' "
347
+ f"and must include all the necessary elements for a successful webinar."
348
+ f"\n\n"
349
+ )
350
+
351
+ # Estructura del webinar
352
+ webinar_script_instruction += "WEBINAR STRUCTURE TO FOLLOW:\n"
353
+ for i, step in enumerate(selected_formula['structure'], 1):
354
+ webinar_script_instruction += f"{i}. {step}\n"
355
+
356
+ # Ejemplos de webinars exitosos
357
+ webinar_script_instruction += "\n\nEXAMPLES OF SUCCESSFUL WEBINARS WITH THIS STRUCTURE:\n"
358
+ for i, example in enumerate(selected_formula['examples'], 1):
359
+ webinar_script_instruction += f"{i}. {example}\n"
360
+
361
+ # Instrucciones específicas - Reforzar el español
362
+ webinar_script_instruction += f"""
363
+ SPECIFIC INSTRUCTIONS:
364
+ 1. Create a complete script that follows exactly the provided structure
365
+ 2. Include persuasive elements and clear calls to action
366
+ 3. Adapt the language and examples specifically for {audience}
367
+ 4. Focus on the transformative benefits of {topic}
368
+ 5. Include relevant stories and examples that reinforce your points
369
+ 6. Use a conversational but professional tone
370
+ 7. Make sure each section fulfills its specific purpose in the framework
371
+ 8. IMPORTANT: Write the ENTIRE script in Spanish (neutral Latin American Spanish)
372
+ 9. DO NOT include any introductory text like "Here's the webinar script..." or "I've created a webinar script..."
373
+ 10. Start directly with the webinar title and content
374
+ 11. ALL section titles, headers, and content MUST be in Spanish
375
+ 12. Ensure ALL examples, stories, and calls to action are in Spanish
376
+
377
+ GENERATE NOW:
378
+ Create a complete webinar script following faithfully the structure of the selected framework, entirely in Spanish.
379
+ """
380
+
381
+ # Enviar el mensaje al modelo
382
+ chat_session = model.start_chat(
383
+ history=[
384
+ {
385
+ "role": "user",
386
+ "parts": [webinar_script_instruction],
387
+ },
388
+ ]
389
+ )
390
+ response = chat_session.send_message("Generate the webinar script IN NEUTRAL SPANISH following exactly the provided structure. All content must be in neutral Spanish (not Spain Spanish). Start directly with the webinar content without any introductory text.")
391
+
392
+ return response.text
393
+
394
+ # Función para validar entradas (evita duplicación)
395
+ def validate_inputs(audience, product):
396
+ has_audience = audience.strip() != ""
397
+ has_product = product.strip() != ""
398
+ return has_audience and has_product
399
+
400
+ # Update the load_css function comment to be more descriptive
401
+ def load_css():
402
+ css_path = "styles/styles.css"
403
+ if os.path.exists(css_path):
404
+ try:
405
+ with open(css_path, "r") as f:
406
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
407
+ except Exception as e:
408
+ st.warning(f"Error al cargar el archivo CSS: {str(e)}")
409
+ else:
410
+ st.warning(f"No se encontró el archivo CSS en {css_path}")
411
+
412
+ # Modify the page config section to include the CSS loading and remove menu
413
+ st.set_page_config(
414
+ page_title="Perfect Webinar Framework",
415
+ layout="wide",
416
+ initial_sidebar_state="expanded",
417
+ menu_items=None # This removes the three dots menu
418
+ )
419
+ load_css() # This will load the styles from styles.css
420
+
421
+ # Leer el contenido del archivo manual.md
422
+ with open("manual.md", "r", encoding="utf-8") as file:
423
+ manual_content = file.read()
424
+
425
+ # Mostrar el contenido del manual en el sidebar
426
+ st.sidebar.markdown(manual_content)
427
+
428
+ # Agregar título y subtítulo usando HTML
429
+ st.markdown("<h1 style='text-align: center;'>Perfect Webinar Framework</h1>", unsafe_allow_html=True)
430
+ st.markdown("<h3 style='text-align: center;'>Crea guiones y títulos de webinars persuasivos que convierten</h3>", unsafe_allow_html=True)
431
+
432
+ # Crear pestañas para la interfaz
433
+ tab1, tab2 = st.tabs(["Guiones de Webinar", "Nombres de Webinar"])
434
+
435
+ # Primera pestaña - Generador de Guiones de Webinar
436
+ with tab1:
437
+ tab1.subheader("Script Webinar")
438
+
439
+ # Crear columnas para la interfaz
440
+ col1, col2 = tab1.columns([1, 2])
441
+
442
+ # Columna de entrada usando la función reutilizable
443
+ with col1:
444
+ # Inputs básicos (fuera del acordeón)
445
+ webinar_script_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key="webinar_script_audience")
446
+ webinar_script_product = st.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key="webinar_script_product")
447
+ webinar_script_offer = st.text_input("¿Cuál es tu producto u oferta?", placeholder="Ejemplo: Curso de marketing de afiliados", key="webinar_script_offer")
448
+
449
+ # Botón de generación (movido aquí, justo después de los campos principales)
450
+ submit_webinar_script = st.button("GENERAR GUIÓN DE WEBINAR ▶▶", key="generate_webinar_script")
451
+
452
+ # Opciones avanzadas en el acordeón
453
+ with st.expander("Personaliza tu guión de webinar"):
454
+ # Selector de fórmula (ahora dentro del acordeón)
455
+ selected_webinar_formula_key = st.selectbox(
456
+ "Selecciona un framework de webinar",
457
+ options=list(webinar_formulas.keys()),
458
+ key="webinar_formula"
459
+ )
460
+
461
+ # Nuevo campo para la idea creativa
462
+ creative_idea = st.text_area(
463
+ "Idea creativa (opcional)",
464
+ placeholder="Introduce una idea o concepto creativo que quieras usar como tema central en tu webinar",
465
+ help="Este concepto será el tema unificador a lo largo de tu webinar, haciéndolo más memorable y atractivo",
466
+ key="webinar_creative_idea"
467
+ )
468
+
469
+ # Slider de creatividad (ya existente)
470
+ webinar_script_temperature = st.slider("Creatividad", min_value=0.0, max_value=2.0, value=1.0, step=0.1, key="webinar_script_temp")
471
+
472
+ selected_webinar_formula = webinar_formulas[selected_webinar_formula_key]
473
+
474
+ # Usar la función generate_and_display para generar y mostrar el guión
475
+ if submit_webinar_script:
476
+ generate_and_display(
477
+ col=col2,
478
+ generator_func=generate_webinar_script,
479
+ audience=webinar_script_audience,
480
+ product=webinar_script_product,
481
+ temperature=webinar_script_temperature,
482
+ selected_formula=selected_webinar_formula,
483
+ content_type="script",
484
+ offer=webinar_script_offer if webinar_script_offer.strip() else None,
485
+ creative_idea=creative_idea if creative_idea.strip() else None
486
+ )
487
+
488
+ # Segunda pestaña - Generador de Nombres de Webinar
489
+ with tab2:
490
+ tab2.subheader("Nombres de Webinar")
491
+
492
+ # Crear columnas para la interfaz
493
+ col1, col2 = tab2.columns([1, 2])
494
+
495
+ # Columna de entrada
496
+ with col1:
497
+ # Inputs básicos
498
+ webinar_names_audience = st.text_input("¿Quién es tu público objetivo?", placeholder="Ejemplo: Emprendedores digitales", key="webinar_names_audience")
499
+ webinar_names_product = st.text_input("¿Sobre qué tema es tu webinar?", placeholder="Ejemplo: Marketing de afiliados", key="webinar_names_product")
500
+
501
+ # Botón de generación (movido aquí, justo después de los campos principales)
502
+ submit_webinar_names = st.button("GENERAR NOMBRES DE WEBINAR ▶▶", key="generate_webinar_names")
503
+
504
+ # Opciones avanzadas en el acordeón
505
+ with st.expander("Personaliza tus nombres de webinar"):
506
+ # Selector de fórmula
507
+ selected_name_formula_key = st.selectbox(
508
+ "Selecciona una fórmula para tus nombres",
509
+ options=list(webinar_name_formulas.keys()),
510
+ key="webinar_name_formula"
511
+ )
512
+
513
+ # Selector de ángulo
514
+ selected_angle = st.selectbox(
515
+ "Selecciona un ángulo (opcional)",
516
+ options=["NINGUNO"] + list(angles_webinar_names.keys()),
517
+ key="webinar_name_angle"
518
+ )
519
+
520
+ # Número de nombres a generar
521
+ number_of_names = st.slider("Número de nombres a generar", min_value=3, max_value=15, value=5, step=1, key="number_of_names")
522
+
523
+ # Slider de creatividad
524
+ webinar_names_temperature = st.slider("Creatividad", min_value=0.0, max_value=2.0, value=1.0, step=0.1, key="webinar_names_temp")
525
+
526
+ selected_name_formula = webinar_name_formulas[selected_name_formula_key]
527
+
528
+ # Usar la función generate_and_display para generar y mostrar los nombres
529
+ if submit_webinar_names:
530
+ generate_and_display(
531
+ col=col2,
532
+ generator_func=generate_webinar_names,
533
+ audience=webinar_names_audience,
534
+ product=webinar_names_product,
535
+ temperature=webinar_names_temperature,
536
+ selected_formula=selected_name_formula,
537
+ content_type="names",
538
+ number_of_names=number_of_names,
539
+ selected_angle=selected_angle if selected_angle != "NINGUNO" else None
 
 
 
 
 
 
 
 
 
 
540
  )