naso / app.py
mgbam's picture
Update app.py
4726c28 verified
raw
history blame
12.9 kB
import streamlit as st
import json
import zipfile
import io
import time
import textwrap
import base64
from agents import TopicAgent, ContentAgent, SlideAgent, CodeAgent, DesignAgent, VoiceoverAgent
# Initialize agents
topic_agent = TopicAgent()
content_agent = ContentAgent()
slide_agent = SlideAgent()
code_agent = CodeAgent()
design_agent = DesignAgent()
voiceover_agent = VoiceoverAgent()
# =====================
# STREAMLIT APPLICATION
# =====================
st.set_page_config(
page_title="Workshop in a Box Pro",
layout="wide",
initial_sidebar_state="expanded",
page_icon="๐ŸŽ“"
)
# Custom CSS for premium styling
st.markdown("""
<style>
.stApp {
background: linear-gradient(135deg, #0f2027 0%, #203a43 100%);
color: #fff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.stTextInput>div>div>input {
background-color: rgba(255,255,255,0.1) !important;
color: white !important;
border: 1px solid #4CAF50;
border-radius: 8px;
}
.stButton>button {
background: linear-gradient(to right, #0d8bf2, #04befe) !important;
color: white !important;
border: none;
border-radius: 8px;
padding: 12px 30px;
font-size: 16px;
font-weight: bold;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: all 0.3s ease;
}
.stButton>button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}
.stDownloadButton>button {
background: linear-gradient(to right, #00c853, #64dd17) !important;
}
.stExpander {
background: rgba(15, 32, 39, 0.8) !important;
border-radius: 10px;
padding: 20px;
border: 1px solid #1e88e5;
box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.premium-badge {
background: linear-gradient(45deg, #ffd700, #ff9800);
color: #000;
padding: 3px 10px;
border-radius: 12px;
font-size: 0.8em;
font-weight: bold;
display: inline-block;
margin-left: 10px;
}
.section-header {
border-left: 4px solid #0d8bf2;
padding-left: 15px;
margin-top: 30px;
}
.testimonial {
background: rgba(255,255,255,0.05);
border-radius: 10px;
padding: 15px;
margin: 15px 0;
border-left: 4px solid #00c853;
}
.pricing-card {
background: rgba(255,255,255,0.05);
border-radius: 10px;
padding: 20px;
margin: 10px 0;
border: 1px solid #0d8bf2;
}
</style>
""", unsafe_allow_html=True)
# Header
col1, col2 = st.columns([1, 4])
with col1:
st.image("https://cdn-icons-png.flaticon.com/512/1995/1995485.png", width=80)
with col2:
st.title("๐Ÿค– Workshop in a Box Pro")
st.markdown("Generate Boardroom-Quality Corporate Training <span class='premium-badge'>PREMIUM</span>", unsafe_allow_html=True)
st.caption("Create $10K+ Value Workshops in Minutes")
# Initialize session state
if 'workshop_topic' not in st.session_state:
st.session_state.workshop_topic = "AI-Driven Business Transformation"
if 'generated' not in st.session_state:
st.session_state.generated = False
if 'generating' not in st.session_state:
st.session_state.generating = False
if 'voiceovers' not in st.session_state:
st.session_state.voiceovers = {}
if 'selected_voice' not in st.session_state:
st.session_state.selected_voice = "21m00Tcm4TlvDq8ikWAM" # Default voice ID
# Sidebar configuration
with st.sidebar:
st.header("โš™๏ธ Executive Workshop Configuration")
# Workshop topic input
st.session_state.workshop_topic = st.text_input(
"Workshop Focus",
st.session_state.workshop_topic,
help="Strategic business topic (e.g., 'AI for Financial Services Transformation')"
)
# Validate topic input
if st.session_state.workshop_topic.strip() == "":
st.warning("Please enter a strategic workshop focus")
st.stop()
duration = st.slider("Duration (hours)", 2.0, 8.0, 4.0, 0.5, help="Full-day or half-day workshop")
difficulty = st.selectbox("Audience Level",
["C-Suite", "Executives", "Directors", "Managers"])
include_code = st.checkbox("Include Technical Implementation", True)
include_design = st.checkbox("Generate Premium Visuals", True)
include_voiceover = st.checkbox("Generate Voiceovers", True)
# Voice selection
if include_voiceover:
st.subheader("๐ŸŽ™๏ธ Voice Selection")
voices = voiceover_agent.get_voices()
if voices:
selected_voice = st.selectbox(
"Choose a voice:",
options=[v['voice_id'] for v in voices],
format_func=lambda id: next((v['name'] for v in voices if v['voice_id'] == id), "Default")
st.session_state.selected_voice = selected_voice
elif voiceover_agent.api_key:
st.warning("Couldn't load voices. Using default voice.")
else:
st.warning("ElevenLabs API key not set. Voiceovers disabled.")
# Quality assurance checkbox
st.divider()
st.markdown("**Quality Assurance**")
premium_mode = st.checkbox("Enable Premium Mode", True,
help="Generate boardroom-quality content with real-world case studies")
if st.button("โœจ Generate Premium Workshop", type="primary", use_container_width=True):
st.session_state.generating = True
st.session_state.voiceovers = {} # Reset previous voiceovers
# Generation pipeline
if st.session_state.generating:
with st.spinner(f"๐Ÿš€ Creating your executive workshop on '{st.session_state.workshop_topic}'..."):
start_time = time.time()
# Agent pipeline
outline = topic_agent.generate_outline(st.session_state.workshop_topic, duration, difficulty)
content = content_agent.generate_content(outline)
slides = slide_agent.generate_slides(content)
code_labs = code_agent.generate_code(content) if include_code else None
design_url = design_agent.generate_design(slides) if include_design else None
# Generate voiceovers if enabled
voiceovers = {}
if include_voiceover and voiceover_agent.api_key:
for i, module in enumerate(content.get("modules", [])):
intro_text = f"Module {i+1}: {module['title']}. " + \
f"Key concepts: {', '.join(module.get('learning_points', [''])[:3])}"
audio_data = voiceover_agent.generate_voiceover(
intro_text,
st.session_state.selected_voice
)
if audio_data:
voiceovers[f"module_{i+1}_intro.mp3"] = audio_data
# Prepare download package
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, "a") as zip_file:
zip_file.writestr("executive_summary.json", json.dumps(outline, indent=2))
zip_file.writestr("workshop_content.json", json.dumps(content, indent=2))
zip_file.writestr("boardroom_slides.md", slides)
if code_labs:
zip_file.writestr("enterprise_solutions.ipynb", code_labs)
if design_url:
try:
img_data = requests.get(design_url).content
zip_file.writestr("slide_design.png", img_data)
except:
pass
# Add voiceovers to ZIP
for filename, audio_data in voiceovers.items():
zip_file.writestr(f"voiceovers/{filename}", audio_data)
# Store results
st.session_state.outline = outline
st.session_state.content = content
st.session_state.slides = slides
st.session_state.code_labs = code_labs
st.session_state.design_url = design_url
st.session_state.voiceovers = voiceovers
st.session_state.zip_buffer = zip_buffer
st.session_state.gen_time = round(time.time() - start_time, 2)
st.session_state.generated = True
st.session_state.generating = False
# Results display
if st.session_state.generated:
st.success(f"โœ… Executive workshop generated in {st.session_state.gen_time} seconds!")
# Download button
st.download_button(
label="๐Ÿ“ฅ Download Executive Package",
data=st.session_state.zip_buffer.getvalue(),
file_name=f"{st.session_state.workshop_topic.replace(' ', '_')}_workshop.zip",
mime="application/zip",
use_container_width=True
)
# Executive summary
with st.expander("๐Ÿ“Š Executive Overview", expanded=True):
st.subheader(st.session_state.outline.get("title", "Strategic Workshop"))
st.caption(f"Duration: {st.session_state.outline.get('duration', '4 hours')} | Level: {st.session_state.outline.get('difficulty', 'Executive')}")
st.markdown("**Business Value Proposition**")
if "learning_goals" in st.session_state.outline:
for goal in st.session_state.outline["learning_goals"]:
st.markdown(f"- {goal}")
st.markdown("**Key Deliverables**")
st.markdown("- Boardroom-ready presentation\n"
"- Implementation toolkit\n"
"- ROI calculation framework\n"
"- Enterprise integration guide")
# Workshop content
with st.expander("๐Ÿ“ Strategic Content Framework"):
if "modules" in st.session_state.content:
for module in st.session_state.content["modules"]:
st.subheader(module.get("title", "Business Module"))
st.markdown(module.get("script", ""))
st.markdown("**Executive Discussion Points**")
if "discussion_questions" in module:
for q in module["discussion_questions"]:
st.markdown(f"- **{q.get('question', '')}**")
st.caption(q.get("response", ""))
# Slide preview
with st.expander("๐Ÿ–ฅ๏ธ Boardroom Presentation Preview"):
st.markdown("```markdown\n" + textwrap.dedent(st.session_state.slides[:2000]) + "\n```")
# Technical implementation
if st.session_state.code_labs:
with st.expander("๐Ÿ’ป Enterprise Implementation Toolkit"):
st.code(st.session_state.code_labs)
# Design preview
if st.session_state.design_url:
with st.expander("๐ŸŽจ Premium Visual Design"):
try:
st.image(st.session_state.design_url, caption="Corporate Slide Design")
except:
st.warning("Design preview unavailable")
# Voiceover player
if st.session_state.voiceovers:
with st.expander("๐Ÿ”Š Voiceover Previews"):
for i, (filename, audio_bytes) in enumerate(st.session_state.voiceovers.items()):
module_num = filename.split("_")[1]
st.subheader(f"Module {module_num} Introduction")
st.audio(audio_bytes, format="audio/mp3")
# Executive engagement section
st.divider()
st.subheader("๐Ÿš€ Premium Corporate Offering")
st.markdown(f"""
### {st.session_state.workshop_topic} Executive Program
<div class="pricing-card">
<h4>Live Workshop</h4>
<h2>$15,000</h2>
<p>Full-day session with Q&A</p>
</div>
<div class="pricing-card">
<h4>On-Demand Course</h4>
<h2>$7,500</h2>
<p>Enterprise-wide access</p>
</div>
<div class="pricing-card">
<h4>Implementation Package</h4>
<h2>$12,500</h2>
<p>Technical integration support</p>
</div>
**Premium Features:**
- Customized to your industry vertical
- ROI guarantee
- 12-month support agreement
- Executive briefing package
""", unsafe_allow_html=True)
# Testimonials
st.divider()
st.subheader("๐Ÿ’ผ Executive Testimonials")
st.markdown("""
<div class="testimonial">
<p>"This platform helped us create a $50K training program in one afternoon. The ROI was immediate."</p>
<p><strong>โ€” Sarah Johnson, CLO at FinTech Global</strong></p>
</div>
<div class="testimonial">
<p>"The boardroom-quality materials impressed our clients and justified our premium pricing."</p>
<p><strong>โ€” Michael Chen, Partner at McKinsey & Company</strong></p>
</div>
""", unsafe_allow_html=True)
# CTA
st.divider()
col1, col2 = st.columns(2)
with col1:
st.link_button("๐Ÿ“… Book Strategy Session", "https://calendly.com/your-link", use_container_width=True)
with col2:
st.link_button("๐Ÿ’ผ Enterprise Solutions", "https://your-company.com/enterprise", use_container_width=True)
# Footer
st.divider()
st.markdown("""
<div style="text-align: center; padding: 20px; color: #aaa;">
Workshop in a Box Proยฎ | Enterprise-Grade AI Training Solutions | ยฉ 2025
</div>
""", unsafe_allow_html=True)