mgbam commited on
Commit
2594e34
Β·
verified Β·
1 Parent(s): 8d9233d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +148 -94
app.py CHANGED
@@ -104,6 +104,10 @@ st.markdown("""
104
  .stAlert {
105
  border-radius: 10px;
106
  }
 
 
 
 
107
  </style>
108
  """, unsafe_allow_html=True)
109
 
@@ -127,8 +131,18 @@ if 'voiceovers' not in st.session_state:
127
  st.session_state.voiceovers = {}
128
  if 'selected_voice' not in st.session_state:
129
  st.session_state.selected_voice = "21m00Tcm4TlvDq8ikWAM" # Default voice ID
130
- if 'show_config' not in st.session_state:
131
- st.session_state.show_config = False
 
 
 
 
 
 
 
 
 
 
132
 
133
  # Sidebar configuration
134
  with st.sidebar:
@@ -140,63 +154,105 @@ with st.sidebar:
140
  st.session_state.workshop_topic,
141
  help="Strategic business topic (e.g., 'AI for Financial Services Transformation')"
142
  )
143
-
144
- # Only show config if topic is provided
145
- if st.session_state.workshop_topic.strip() == "":
146
- st.warning("Please enter a strategic workshop focus to continue")
147
- else:
148
- st.session_state.show_config = True
149
-
150
- if st.session_state.show_config:
151
- duration = st.slider("Duration (hours)", 2.0, 8.0, 4.0, 0.5, help="Full-day or half-day workshop")
152
- difficulty = st.selectbox("Audience Level",
153
- ["C-Suite", "Executives", "Directors", "Managers"])
154
- include_code = st.checkbox("Include Technical Implementation", True)
155
- include_design = st.checkbox("Generate Premium Visuals", True)
156
- include_voiceover = st.checkbox("Generate Voiceovers", True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
- # Voice selection
159
- if include_voiceover:
160
- st.subheader("πŸŽ™οΈ Voice Selection")
161
- voices = voiceover_agent.get_voices()
162
-
163
- if voices:
164
- selected_voice = st.selectbox(
165
- "Choose a voice:",
166
- options=[v['voice_id'] for v in voices],
167
- format_func=lambda id: next((v['name'] for v in voices if v['voice_id'] == id), "Default")
168
- )
169
- st.session_state.selected_voice = selected_voice
170
- elif voiceover_agent.api_key:
171
- st.warning("Couldn't load voices. Using default voice.")
172
- else:
173
- st.warning("ElevenLabs API key not set. Voiceovers disabled.")
174
 
175
- # Quality assurance checkbox
176
- st.divider()
177
- st.markdown("**Quality Assurance**")
178
- premium_mode = st.checkbox("Enable Premium Mode", True,
179
- help="Generate boardroom-quality content with real-world case studies")
 
 
 
 
180
 
181
- if st.button("✨ Generate Premium Workshop", type="primary", use_container_width=True):
182
- st.session_state.generating = True
183
- st.session_state.voiceovers = {} # Reset previous voiceovers
 
 
 
 
 
 
 
184
 
185
  # Generation pipeline
186
- if st.session_state.generating and st.session_state.show_config:
187
  with st.spinner(f"πŸš€ Creating your executive workshop on '{st.session_state.workshop_topic}'..."):
188
  start_time = time.time()
189
 
190
  # Agent pipeline
191
- outline = topic_agent.generate_outline(st.session_state.workshop_topic, duration, difficulty)
 
 
 
 
192
  content = content_agent.generate_content(outline)
193
  slides = slide_agent.generate_slides(content)
194
- code_labs = code_agent.generate_code(content) if include_code else None
195
- design_url = design_agent.generate_design(slides) if include_design else None
196
 
197
  # Generate voiceovers if enabled
198
  voiceovers = {}
199
- if include_voiceover and voiceover_agent.api_key:
200
  for i, module in enumerate(content.get("modules", [])):
201
  intro_text = f"Module {i+1}: {module['title']}. " + \
202
  f"Key concepts: {', '.join(module.get('learning_points', [''])[:3])}"
@@ -238,7 +294,7 @@ if st.session_state.generating and st.session_state.show_config:
238
  st.session_state.generating = False
239
 
240
  # Results display
241
- if st.session_state.generated and st.session_state.show_config:
242
  st.success(f"βœ… Executive workshop generated in {st.session_state.gen_time} seconds!")
243
 
244
  # Download button
@@ -307,33 +363,32 @@ if st.session_state.generated and st.session_state.show_config:
307
  st.audio(audio_bytes, format="audio/mp3")
308
 
309
  # Executive engagement section
310
- if st.session_state.show_config:
311
- st.divider()
312
- st.subheader("πŸš€ Premium Corporate Offering")
313
- st.markdown(f"""
314
- ### {st.session_state.workshop_topic} Executive Program
315
- <div class="pricing-card">
316
- <h4>Live Workshop</h4>
317
- <h2>$15,000</h2>
318
- <p>Full-day session with Q&A</p>
319
- </div>
320
- <div class="pricing-card">
321
- <h4>On-Demand Course</h4>
322
- <h2>$7,500</h2>
323
- <p>Enterprise-wide access</p>
324
- </div>
325
- <div class="pricing-card">
326
- <h4>Implementation Package</h4>
327
- <h2>$12,500</h2>
328
- <p>Technical integration support</p>
329
- </div>
330
 
331
- **Premium Features:**
332
- - Customized to your industry vertical
333
- - ROI guarantee
334
- - 12-month support agreement
335
- - Executive briefing package
336
- """, unsafe_allow_html=True)
337
 
338
  # Testimonials
339
  st.divider()
@@ -367,25 +422,24 @@ st.markdown("""
367
 
368
  # Debug info
369
  with st.sidebar:
370
- if st.session_state.show_config:
371
- st.divider()
372
- if hasattr(topic_agent, 'openai_client') and topic_agent.openai_client:
373
- st.success("OpenAI API Connected")
374
- else:
375
- st.warning("OpenAI API not set - using enhanced mock data")
376
-
377
- if voiceover_agent.api_key:
378
- st.success("ElevenLabs API Key Found")
379
- elif include_voiceover:
380
- st.warning("ElevenLabs API key not set")
381
-
382
- st.info(f"""
383
- **Current Workshop:**
384
- {st.session_state.workshop_topic}
385
-
386
- **Premium Features:**
387
- - AI-generated voiceovers
388
- - Professional slide designs
389
- - Real-world case studies
390
- - Practical code labs
391
- """)
 
104
  .stAlert {
105
  border-radius: 10px;
106
  }
107
+ .disabled-widget {
108
+ opacity: 0.6;
109
+ pointer-events: none;
110
+ }
111
  </style>
112
  """, unsafe_allow_html=True)
113
 
 
131
  st.session_state.voiceovers = {}
132
  if 'selected_voice' not in st.session_state:
133
  st.session_state.selected_voice = "21m00Tcm4TlvDq8ikWAM" # Default voice ID
134
+ if 'duration' not in st.session_state:
135
+ st.session_state.duration = 4.0
136
+ if 'difficulty' not in st.session_state:
137
+ st.session_state.difficulty = "C-Suite"
138
+ if 'include_code' not in st.session_state:
139
+ st.session_state.include_code = True
140
+ if 'include_design' not in st.session_state:
141
+ st.session_state.include_design = True
142
+ if 'include_voiceover' not in st.session_state:
143
+ st.session_state.include_voiceover = True
144
+ if 'premium_mode' not in st.session_state:
145
+ st.session_state.premium_mode = True
146
 
147
  # Sidebar configuration
148
  with st.sidebar:
 
154
  st.session_state.workshop_topic,
155
  help="Strategic business topic (e.g., 'AI for Financial Services Transformation')"
156
  )
157
+
158
+ # Check if topic is empty
159
+ topic_empty = st.session_state.workshop_topic.strip() == ""
160
+
161
+ # Show warning if topic is empty
162
+ if topic_empty:
163
+ st.warning("Please enter a strategic workshop focus to enable configuration")
164
+
165
+ # Always show config controls but disable when topic is empty
166
+ st.session_state.duration = st.slider(
167
+ "Duration (hours)",
168
+ 2.0, 8.0, st.session_state.duration, 0.5,
169
+ help="Full-day or half-day workshop",
170
+ disabled=topic_empty
171
+ )
172
+
173
+ st.session_state.difficulty = st.selectbox(
174
+ "Audience Level",
175
+ ["C-Suite", "Executives", "Directors", "Managers"],
176
+ index=["C-Suite", "Executives", "Directors", "Managers"].index(st.session_state.difficulty),
177
+ disabled=topic_empty
178
+ )
179
+
180
+ st.session_state.include_code = st.checkbox(
181
+ "Include Technical Implementation",
182
+ st.session_state.include_code,
183
+ disabled=topic_empty
184
+ )
185
+
186
+ st.session_state.include_design = st.checkbox(
187
+ "Generate Premium Visuals",
188
+ st.session_state.include_design,
189
+ disabled=topic_empty
190
+ )
191
+
192
+ st.session_state.include_voiceover = st.checkbox(
193
+ "Generate Voiceovers",
194
+ st.session_state.include_voiceover,
195
+ disabled=topic_empty
196
+ )
197
+
198
+ # Voice selection
199
+ if st.session_state.include_voiceover and not topic_empty:
200
+ st.subheader("πŸŽ™οΈ Voice Selection")
201
+ voices = voiceover_agent.get_voices()
202
 
203
+ if voices:
204
+ selected_voice = st.selectbox(
205
+ "Choose a voice:",
206
+ options=[v['voice_id'] for v in voices],
207
+ format_func=lambda id: next((v['name'] for v in voices if v['voice_id'] == id), "Default"),
208
+ key="voice_select"
209
+ )
210
+ st.session_state.selected_voice = selected_voice
211
+ elif voiceover_agent.api_key:
212
+ st.warning("Couldn't load voices. Using default voice.")
213
+ else:
214
+ st.warning("ElevenLabs API key not set. Voiceovers disabled.")
 
 
 
 
215
 
216
+ # Quality assurance checkbox
217
+ st.divider()
218
+ st.markdown("**Quality Assurance**")
219
+ st.session_state.premium_mode = st.checkbox(
220
+ "Enable Premium Mode",
221
+ st.session_state.premium_mode,
222
+ help="Generate boardroom-quality content with real-world case studies",
223
+ disabled=topic_empty
224
+ )
225
 
226
+ # Generate button - disabled when topic is empty
227
+ generate_disabled = topic_empty or st.session_state.generating
228
+ if st.button(
229
+ "✨ Generate Premium Workshop",
230
+ type="primary",
231
+ use_container_width=True,
232
+ disabled=generate_disabled
233
+ ):
234
+ st.session_state.generating = True
235
+ st.session_state.voiceovers = {} # Reset previous voiceovers
236
 
237
  # Generation pipeline
238
+ if st.session_state.generating and not topic_empty:
239
  with st.spinner(f"πŸš€ Creating your executive workshop on '{st.session_state.workshop_topic}'..."):
240
  start_time = time.time()
241
 
242
  # Agent pipeline
243
+ outline = topic_agent.generate_outline(
244
+ st.session_state.workshop_topic,
245
+ st.session_state.duration,
246
+ st.session_state.difficulty
247
+ )
248
  content = content_agent.generate_content(outline)
249
  slides = slide_agent.generate_slides(content)
250
+ code_labs = code_agent.generate_code(content) if st.session_state.include_code else None
251
+ design_url = design_agent.generate_design(slides) if st.session_state.include_design else None
252
 
253
  # Generate voiceovers if enabled
254
  voiceovers = {}
255
+ if st.session_state.include_voiceover and voiceover_agent.api_key:
256
  for i, module in enumerate(content.get("modules", [])):
257
  intro_text = f"Module {i+1}: {module['title']}. " + \
258
  f"Key concepts: {', '.join(module.get('learning_points', [''])[:3])}"
 
294
  st.session_state.generating = False
295
 
296
  # Results display
297
+ if st.session_state.generated and not topic_empty:
298
  st.success(f"βœ… Executive workshop generated in {st.session_state.gen_time} seconds!")
299
 
300
  # Download button
 
363
  st.audio(audio_bytes, format="audio/mp3")
364
 
365
  # Executive engagement section
366
+ st.divider()
367
+ st.subheader("πŸš€ Premium Corporate Offering")
368
+ st.markdown(f"""
369
+ ### {st.session_state.workshop_topic} Executive Program
370
+ <div class="pricing-card">
371
+ <h4>Live Workshop</h4>
372
+ <h2>$15,000</h2>
373
+ <p>Full-day session with Q&A</p>
374
+ </div>
375
+ <div class="pricing-card">
376
+ <h4>On-Demand Course</h4>
377
+ <h2>$7,500</h2>
378
+ <p>Enterprise-wide access</p>
379
+ </div>
380
+ <div class="pricing-card">
381
+ <h4>Implementation Package</h4>
382
+ <h2>$12,500</h2>
383
+ <p>Technical integration support</p>
384
+ </div>
 
385
 
386
+ **Premium Features:**
387
+ - Customized to your industry vertical
388
+ - ROI guarantee
389
+ - 12-month support agreement
390
+ - Executive briefing package
391
+ """, unsafe_allow_html=True)
392
 
393
  # Testimonials
394
  st.divider()
 
422
 
423
  # Debug info
424
  with st.sidebar:
425
+ st.divider()
426
+ if hasattr(topic_agent, 'openai_client') and topic_agent.openai_client:
427
+ st.success("OpenAI API Connected")
428
+ else:
429
+ st.warning("OpenAI API not set - using enhanced mock data")
430
+
431
+ if voiceover_agent.api_key:
432
+ st.success("ElevenLabs API Key Found")
433
+ elif st.session_state.include_voiceover:
434
+ st.warning("ElevenLabs API key not set")
435
+
436
+ st.info(f"""
437
+ **Current Workshop:**
438
+ {st.session_state.workshop_topic}
439
+
440
+ **Premium Features:**
441
+ - AI-generated voiceovers
442
+ - Professional slide designs
443
+ - Real-world case studies
444
+ - Practical code labs
445
+ """)