Update agents/agents.py
Browse files- agents/agents.py +385 -378
agents/agents.py
CHANGED
|
@@ -1,402 +1,409 @@
|
|
|
|
|
| 1 |
import json
|
| 2 |
-
import
|
|
|
|
|
|
|
|
|
|
| 3 |
import requests
|
| 4 |
-
from
|
| 5 |
-
from openai import OpenAI
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
response = openai_client.chat.completions.create(
|
| 21 |
-
model="gpt-4-turbo",
|
| 22 |
-
messages=[
|
| 23 |
-
{
|
| 24 |
-
"role": "system",
|
| 25 |
-
"content": (
|
| 26 |
-
"You are an expert corporate trainer with 20+ years of experience creating "
|
| 27 |
-
"high-value workshops for Fortune 500 companies. Create a professional workshop outline that "
|
| 28 |
-
"includes: 1) Clear learning objectives, 2) Practical real-world exercises, "
|
| 29 |
-
"3) Industry case studies, 4) Measurable outcomes. Format as JSON."
|
| 30 |
-
)
|
| 31 |
-
},
|
| 32 |
-
{
|
| 33 |
-
"role": "user",
|
| 34 |
-
"content": (
|
| 35 |
-
f"Create a comprehensive {duration}-hour {difficulty} workshop outline on '{topic}' for corporate executives. "
|
| 36 |
-
"Structure: title, duration, difficulty, learning_goals (3-5 bullet points), "
|
| 37 |
-
"modules (5-7 modules). Each module should have: title, duration, learning_points (3 bullet points), "
|
| 38 |
-
"case_study (real company example), exercises (2 practical exercises)."
|
| 39 |
-
)
|
| 40 |
-
}
|
| 41 |
-
],
|
| 42 |
-
temperature=0.3,
|
| 43 |
-
max_tokens=1500,
|
| 44 |
-
response_format={"type": "json_object"}
|
| 45 |
-
)
|
| 46 |
-
return json.loads(response.choices[0].message.content)
|
| 47 |
-
except Exception as e:
|
| 48 |
-
return self._mock_outline(topic, duration, difficulty)
|
| 49 |
-
|
| 50 |
-
def _mock_outline(self, topic, duration, difficulty):
|
| 51 |
-
return {
|
| 52 |
-
"title": f"Mastering {topic} for Business Impact",
|
| 53 |
-
"duration": f"{duration} hours",
|
| 54 |
-
"difficulty": difficulty,
|
| 55 |
-
"learning_goals": [
|
| 56 |
-
"Apply advanced techniques to real business challenges",
|
| 57 |
-
"Measure ROI of prompt engineering initiatives",
|
| 58 |
-
"Develop organizational prompt engineering standards",
|
| 59 |
-
"Implement ethical AI governance frameworks"
|
| 60 |
-
],
|
| 61 |
-
"modules": [
|
| 62 |
-
{
|
| 63 |
-
"title": "Strategic Foundations",
|
| 64 |
-
"duration": "45 min",
|
| 65 |
-
"learning_points": [
|
| 66 |
-
"Business value assessment framework",
|
| 67 |
-
"ROI calculation models",
|
| 68 |
-
"Stakeholder alignment strategies"
|
| 69 |
-
],
|
| 70 |
-
"case_study": "How JPMorgan reduced operational costs by 37% with prompt optimization",
|
| 71 |
-
"exercises": [
|
| 72 |
-
"Calculate potential ROI for your organization",
|
| 73 |
-
"Develop stakeholder communication plan"
|
| 74 |
-
]
|
| 75 |
-
},
|
| 76 |
-
{
|
| 77 |
-
"title": "Advanced Pattern Engineering",
|
| 78 |
-
"duration": "60 min",
|
| 79 |
-
"learning_points": [
|
| 80 |
-
"Chain-of-thought implementations",
|
| 81 |
-
"Self-correcting prompt architectures",
|
| 82 |
-
"Domain-specific pattern libraries"
|
| 83 |
-
],
|
| 84 |
-
"case_study": "McKinsey's knowledge management transformation",
|
| 85 |
-
"exercises": [
|
| 86 |
-
"Design pattern library for your industry",
|
| 87 |
-
"Implement self-correction workflow"
|
| 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 |
-
"role": "user",
|
| 193 |
-
"content": (
|
| 194 |
-
f"Create a boardroom-quality slide deck for: {json.dumps(content)}. "
|
| 195 |
-
"Structure: Title slide, module slides (objective, 3 key points, case study, exercise), "
|
| 196 |
-
"summary slide. Include placeholders for data visualization."
|
| 197 |
-
)
|
| 198 |
-
}
|
| 199 |
-
],
|
| 200 |
-
temperature=0.2,
|
| 201 |
-
max_tokens=2500
|
| 202 |
-
)
|
| 203 |
-
return response.choices[0].message.content
|
| 204 |
-
except Exception as e:
|
| 205 |
-
return self._professional_slides(content)
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
#
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
| 234 |
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
model="gpt-4-turbo",
|
| 266 |
-
messages=[
|
| 267 |
-
{
|
| 268 |
-
"role": "system",
|
| 269 |
-
"content": (
|
| 270 |
-
"You are an enterprise solutions architect. Create professional-grade code labs with: "
|
| 271 |
-
"1) Production-ready patterns 2) Comprehensive documentation "
|
| 272 |
-
"3) Enterprise security practices 4) Scalable architectures. "
|
| 273 |
-
"Use Python with the latest best practices."
|
| 274 |
-
)
|
| 275 |
-
},
|
| 276 |
-
{
|
| 277 |
-
"role": "user",
|
| 278 |
-
"content": (
|
| 279 |
-
f"Create a professional code lab for: {json.dumps(content)}. "
|
| 280 |
-
"Include: Setup instructions, business solution patterns, "
|
| 281 |
-
"enterprise integration examples, and security best practices."
|
| 282 |
-
)
|
| 283 |
-
}
|
| 284 |
-
],
|
| 285 |
-
temperature=0.3,
|
| 286 |
-
max_tokens=2500
|
| 287 |
-
)
|
| 288 |
-
return response.choices[0].message.content
|
| 289 |
-
except Exception as e:
|
| 290 |
-
return self._professional_code(content)
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
class PromptOptimizer:
|
| 297 |
-
def __init__(self, model="gpt-4-turbo"):
|
| 298 |
-
self.model = model
|
| 299 |
-
self.pattern_library = {{
|
| 300 |
-
"financial_analysis": "Extract key metrics from financial reports",
|
| 301 |
-
"customer_service": "Resolve tier-2 support tickets"
|
| 302 |
-
}}
|
| 303 |
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
|
|
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
# Example usage
|
| 312 |
-
optimizer = PromptOptimizer()
|
| 313 |
-
print(optimizer.calculate_roi(500000, 0.35)) # $175,000 savings
|
| 314 |
-
|
| 315 |
-
Security Best Practices
|
| 316 |
-
python
|
| 317 |
-
def secure_prompt_handling(user_input):
|
| 318 |
-
# Implement OWASP security standards
|
| 319 |
-
sanitized = sanitize_input(user_input)
|
| 320 |
-
validate_business_context(sanitized)
|
| 321 |
-
return apply_enterprise_guardrails(sanitized)
|
| 322 |
-
|
| 323 |
-
Integration Pattern: CRM System
|
| 324 |
-
python
|
| 325 |
-
def integrate_with_salesforce(prompt, salesforce_data):
|
| 326 |
-
# Enterprise integration example
|
| 327 |
-
enriched_prompt = f"{{prompt}} using {{salesforce_data}}"
|
| 328 |
-
return call_ai_api(enriched_prompt)
|
| 329 |
-
"""
|
| 330 |
-
|
| 331 |
-
class DesignAgent:
|
| 332 |
-
def generate_design(self, slide_content):
|
| 333 |
-
if not openai_client:
|
| 334 |
-
return None
|
| 335 |
-
|
| 336 |
-
try:
|
| 337 |
-
response = openai_client.images.generate(
|
| 338 |
-
model="dall-e-3",
|
| 339 |
-
prompt=(
|
| 340 |
-
f"Professional corporate slide background for '{slide_content[:200]}' workshop. "
|
| 341 |
-
"Modern business style, clean lines, premium gradient, boardroom appropriate. "
|
| 342 |
-
"Include abstract technology elements in corporate colors."
|
| 343 |
-
),
|
| 344 |
-
n=1,
|
| 345 |
-
size="1024x1024"
|
| 346 |
-
)
|
| 347 |
-
return response.data[0].url
|
| 348 |
-
except Exception as e:
|
| 349 |
-
return None
|
| 350 |
-
|
| 351 |
-
class VoiceoverAgent:
|
| 352 |
-
def __init__(self):
|
| 353 |
-
self.api_key = ELEVENLABS_API_KEY
|
| 354 |
-
self.voice_id = "21m00Tcm4TlvDq8ikWAM" # Default voice ID
|
| 355 |
-
self.model = "eleven_monolingual_v1"
|
| 356 |
-
|
| 357 |
-
def generate_voiceover(self, text, voice_id=None):
|
| 358 |
-
if not self.api_key:
|
| 359 |
-
return None
|
| 360 |
-
|
| 361 |
-
try:
|
| 362 |
-
voice = voice_id if voice_id else self.voice_id
|
| 363 |
-
|
| 364 |
-
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice}"
|
| 365 |
-
headers = {
|
| 366 |
-
"Accept": "audio/mpeg",
|
| 367 |
-
"Content-Type": "application/json",
|
| 368 |
-
"xi-api-key": self.api_key
|
| 369 |
-
}
|
| 370 |
-
data = {
|
| 371 |
-
"text": text,
|
| 372 |
-
"model_id": self.model,
|
| 373 |
-
"voice_settings": {
|
| 374 |
-
"stability": 0.7,
|
| 375 |
-
"similarity_boost": 0.8,
|
| 376 |
-
"style": 0.5,
|
| 377 |
-
"use_speaker_boost": True
|
| 378 |
-
}
|
| 379 |
-
}
|
| 380 |
-
response = requests.post(url, json=data, headers=headers)
|
| 381 |
-
|
| 382 |
-
if response.status_code == 200:
|
| 383 |
-
return response.content
|
| 384 |
-
return None
|
| 385 |
-
except Exception as e:
|
| 386 |
-
return None
|
| 387 |
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
headers = {"xi-api-key": self.api_key}
|
| 395 |
-
response = requests.get(url, headers=headers)
|
| 396 |
-
|
| 397 |
-
if response.status_code == 200:
|
| 398 |
-
return response.json().get("voices", [])
|
| 399 |
-
return []
|
| 400 |
-
except Exception as e:
|
| 401 |
-
return []
|
| 402 |
-
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import json
|
| 3 |
+
import zipfile
|
| 4 |
+
import io
|
| 5 |
+
import time
|
| 6 |
+
import textwrap
|
| 7 |
import requests
|
| 8 |
+
from agents import TopicAgent, ContentAgent, SlideAgent, CodeAgent, DesignAgent, VoiceoverAgent
|
|
|
|
| 9 |
|
| 10 |
+
# Initialize agents
|
| 11 |
+
topic_agent = TopicAgent()
|
| 12 |
+
content_agent = ContentAgent()
|
| 13 |
+
slide_agent = SlideAgent()
|
| 14 |
+
code_agent = CodeAgent()
|
| 15 |
+
design_agent = DesignAgent()
|
| 16 |
+
voiceover_agent = VoiceoverAgent()
|
| 17 |
|
| 18 |
+
# =====================
|
| 19 |
+
# STREAMLIT APPLICATION
|
| 20 |
+
# =====================
|
| 21 |
|
| 22 |
+
st.set_page_config(
|
| 23 |
+
page_title="Workshop in a Box Pro",
|
| 24 |
+
layout="wide",
|
| 25 |
+
initial_sidebar_state="expanded",
|
| 26 |
+
page_icon="🎓"
|
| 27 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Custom CSS for premium styling
|
| 30 |
+
st.markdown("""
|
| 31 |
+
<style>
|
| 32 |
+
.stApp {
|
| 33 |
+
background: linear-gradient(135deg, #0f2027 0%, #203a43 100%);
|
| 34 |
+
color: #fff;
|
| 35 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 36 |
+
}
|
| 37 |
+
.stTextInput>div>div>input {
|
| 38 |
+
background-color: rgba(255,255,255,0.1) !important;
|
| 39 |
+
color: white !important;
|
| 40 |
+
border: 1px solid #4CAF50;
|
| 41 |
+
border-radius: 8px;
|
| 42 |
+
}
|
| 43 |
+
.stButton>button {
|
| 44 |
+
background: linear-gradient(to right, #0d8bf2, #04befe) !important;
|
| 45 |
+
color: white !important;
|
| 46 |
+
border: none;
|
| 47 |
+
border-radius: 8px;
|
| 48 |
+
padding: 12px 30px;
|
| 49 |
+
font-size: 16px;
|
| 50 |
+
font-weight: bold;
|
| 51 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 52 |
+
transition: all 0.3s ease;
|
| 53 |
+
}
|
| 54 |
+
.stButton>button:hover {
|
| 55 |
+
transform: translateY(-2px);
|
| 56 |
+
box-shadow: 0 6px 8px rgba(0,0,0,0.15);
|
| 57 |
+
}
|
| 58 |
+
.stDownloadButton>button {
|
| 59 |
+
background: linear-gradient(to right, #00c853, #64dd17) !important;
|
| 60 |
+
}
|
| 61 |
+
.stExpander {
|
| 62 |
+
background: rgba(15, 32, 39, 0.8) !important;
|
| 63 |
+
border-radius: 10px;
|
| 64 |
+
padding: 20px;
|
| 65 |
+
border: 1px solid #1e88e5;
|
| 66 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.25);
|
| 67 |
+
}
|
| 68 |
+
.premium-badge {
|
| 69 |
+
background: linear-gradient(45deg, #ffd700, #ff9800);
|
| 70 |
+
color: #000;
|
| 71 |
+
padding: 3px 10px;
|
| 72 |
+
border-radius: 12px;
|
| 73 |
+
font-size: 0.8em;
|
| 74 |
+
font-weight: bold;
|
| 75 |
+
display: inline-block;
|
| 76 |
+
margin-left: 10px;
|
| 77 |
+
}
|
| 78 |
+
.section-header {
|
| 79 |
+
border-left: 4px solid #0d8bf2;
|
| 80 |
+
padding-left: 15px;
|
| 81 |
+
margin-top: 30px;
|
| 82 |
+
}
|
| 83 |
+
.testimonial {
|
| 84 |
+
background: rgba(255,255,255,0.05);
|
| 85 |
+
border-radius: 10px;
|
| 86 |
+
padding: 15px;
|
| 87 |
+
margin: 15px 0;
|
| 88 |
+
border-left: 4px solid #00c853;
|
| 89 |
+
}
|
| 90 |
+
.pricing-card {
|
| 91 |
+
background: rgba(255,255,255,0.05);
|
| 92 |
+
border-radius: 10px;
|
| 93 |
+
padding: 20px;
|
| 94 |
+
margin: 10px 0;
|
| 95 |
+
border: 1px solid #0d8bf2;
|
| 96 |
+
}
|
| 97 |
+
.executive-summary {
|
| 98 |
+
background: linear-gradient(to right, #1a2980, #26d0ce);
|
| 99 |
+
padding: 25px;
|
| 100 |
+
border-radius: 15px;
|
| 101 |
+
margin-bottom: 25px;
|
| 102 |
+
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
|
| 103 |
+
}
|
| 104 |
+
.sidebar-section {
|
| 105 |
+
padding: 15px;
|
| 106 |
+
background: rgba(255,255,255,0.05);
|
| 107 |
+
border-radius: 10px;
|
| 108 |
+
margin-bottom: 15px;
|
| 109 |
+
}
|
| 110 |
+
</style>
|
| 111 |
+
""", unsafe_allow_html=True)
|
| 112 |
+
|
| 113 |
+
# Header
|
| 114 |
+
col1, col2 = st.columns([1, 4])
|
| 115 |
+
with col1:
|
| 116 |
+
st.image("https://cdn-icons-png.flaticon.com/512/1995/1995485.png", width=80)
|
| 117 |
+
with col2:
|
| 118 |
+
st.title("🤖 Workshop in a Box Pro")
|
| 119 |
+
st.markdown("Generate Boardroom-Quality Corporate Training <span class='premium-badge'>PREMIUM</span>", unsafe_allow_html=True)
|
| 120 |
+
st.caption("Create $10K+ Value Workshops in Minutes")
|
| 121 |
|
| 122 |
+
# Initialize session state
|
| 123 |
+
if 'workshop_topic' not in st.session_state:
|
| 124 |
+
st.session_state.workshop_topic = "AI-Driven Business Transformation"
|
| 125 |
+
if 'generated' not in st.session_state:
|
| 126 |
+
st.session_state.generated = False
|
| 127 |
+
if 'generating' not in st.session_state:
|
| 128 |
+
st.session_state.generating = False
|
| 129 |
+
if 'voiceovers' not in st.session_state:
|
| 130 |
+
st.session_state.voiceovers = {}
|
| 131 |
+
if 'selected_voice' not in st.session_state:
|
| 132 |
+
st.session_state.selected_voice = "21m00Tcm4TlvDq8ikWAM" # Default voice ID
|
| 133 |
+
|
| 134 |
+
# Sidebar configuration
|
| 135 |
+
with st.sidebar:
|
| 136 |
+
st.header("⚙️ Executive Workshop Configuration")
|
| 137 |
+
|
| 138 |
+
# Create container for better organization
|
| 139 |
+
with st.container():
|
| 140 |
+
st.markdown("<div class='sidebar-section'>", unsafe_allow_html=True)
|
| 141 |
+
|
| 142 |
+
# Workshop topic input
|
| 143 |
+
topic = st.text_input(
|
| 144 |
+
"Workshop Focus",
|
| 145 |
+
st.session_state.workshop_topic,
|
| 146 |
+
key="topic_input",
|
| 147 |
+
help="Strategic business topic (e.g., 'AI for Financial Services Transformation')"
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
# Update session state only if input changes
|
| 151 |
+
if topic != st.session_state.workshop_topic:
|
| 152 |
+
st.session_state.workshop_topic = topic
|
| 153 |
+
|
| 154 |
+
# Validate topic input
|
| 155 |
+
if st.session_state.workshop_topic.strip() == "":
|
| 156 |
+
st.warning("Please enter a strategic workshop focus")
|
| 157 |
+
|
| 158 |
+
duration = st.slider("Duration (hours)", 2.0, 8.0, 4.0, 0.5,
|
| 159 |
+
help="Full-day or half-day workshop")
|
| 160 |
+
difficulty = st.selectbox("Audience Level",
|
| 161 |
+
["C-Suite", "Executives", "Directors", "Managers"])
|
| 162 |
+
|
| 163 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 164 |
+
|
| 165 |
+
# Advanced options section
|
| 166 |
+
with st.container():
|
| 167 |
+
st.markdown("<div class='sidebar-section'>", unsafe_allow_html=True)
|
| 168 |
+
st.subheader("Advanced Options")
|
| 169 |
+
include_code = st.checkbox("Include Technical Implementation", True)
|
| 170 |
+
include_design = st.checkbox("Generate Premium Visuals", True)
|
| 171 |
+
include_voiceover = st.checkbox("Generate Voiceovers", True)
|
| 172 |
+
|
| 173 |
+
# Voice selection
|
| 174 |
+
if include_voiceover:
|
| 175 |
+
voices = voiceover_agent.get_voices()
|
| 176 |
|
| 177 |
+
if voices:
|
| 178 |
+
selected_voice = st.selectbox(
|
| 179 |
+
"Choose a voice:",
|
| 180 |
+
options=[v['voice_id'] for v in voices],
|
| 181 |
+
format_func=lambda id: next((v['name'] for v in voices if v['voice_id'] == id), "Default"),
|
| 182 |
+
key="voice_select"
|
| 183 |
+
)
|
| 184 |
+
st.session_state.selected_voice = selected_voice
|
| 185 |
+
elif voiceover_agent.api_key:
|
| 186 |
+
st.warning("Couldn't load voices. Using default voice.")
|
| 187 |
+
else:
|
| 188 |
+
st.warning("ElevenLabs API key not set. Voiceovers disabled.")
|
| 189 |
+
|
| 190 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
+
# Quality assurance section
|
| 193 |
+
with st.container():
|
| 194 |
+
st.markdown("<div class='sidebar-section'>", unsafe_allow_html=True)
|
| 195 |
+
st.subheader("Quality Assurance")
|
| 196 |
+
premium_mode = st.checkbox("Enable Premium Mode", True,
|
| 197 |
+
help="Generate boardroom-quality content with real-world case studies")
|
| 198 |
+
|
| 199 |
+
if st.button("✨ Generate Premium Workshop", type="primary", use_container_width=True):
|
| 200 |
+
if st.session_state.workshop_topic.strip() == "":
|
| 201 |
+
st.error("Please enter a workshop focus")
|
| 202 |
+
else:
|
| 203 |
+
st.session_state.generating = True
|
| 204 |
+
st.session_state.voiceovers = {} # Reset previous voiceovers
|
| 205 |
+
|
| 206 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 207 |
|
| 208 |
+
# Generation pipeline
|
| 209 |
+
if st.session_state.generating:
|
| 210 |
+
with st.spinner(f"🚀 Creating your executive workshop on '{st.session_state.workshop_topic}'..."):
|
| 211 |
+
start_time = time.time()
|
| 212 |
+
|
| 213 |
+
# Agent pipeline
|
| 214 |
+
outline = topic_agent.generate_outline(st.session_state.workshop_topic, duration, difficulty)
|
| 215 |
+
content = content_agent.generate_content(outline)
|
| 216 |
+
slides = slide_agent.generate_slides(content)
|
| 217 |
+
code_labs = code_agent.generate_code(content) if include_code else None
|
| 218 |
+
design_url = design_agent.generate_design(slides) if include_design else None
|
| 219 |
+
|
| 220 |
+
# Generate voiceovers if enabled
|
| 221 |
+
voiceovers = {}
|
| 222 |
+
if include_voiceover and voiceover_agent.api_key:
|
| 223 |
+
for i, module in enumerate(content.get("modules", [])):
|
| 224 |
+
intro_text = f"Module {i+1}: {module['title']}. " + \
|
| 225 |
+
f"Key concepts: {', '.join(module.get('learning_points', [''])[:3])}"
|
| 226 |
+
audio_data = voiceover_agent.generate_voiceover(
|
| 227 |
+
intro_text,
|
| 228 |
+
st.session_state.selected_voice
|
| 229 |
+
)
|
| 230 |
+
if audio_data:
|
| 231 |
+
voiceovers[f"module_{i+1}_intro.mp3"] = audio_data
|
| 232 |
+
|
| 233 |
+
# Prepare download package
|
| 234 |
+
zip_buffer = io.BytesIO()
|
| 235 |
+
with zipfile.ZipFile(zip_buffer, "a", zipfile.ZIP_DEFLATED) as zip_file:
|
| 236 |
+
zip_file.writestr("executive_summary.json", json.dumps(outline, indent=2))
|
| 237 |
+
zip_file.writestr("workshop_content.json", json.dumps(content, indent=2))
|
| 238 |
+
zip_file.writestr("boardroom_slides.md", slides)
|
| 239 |
+
if code_labs:
|
| 240 |
+
zip_file.writestr("enterprise_solutions.ipynb", code_labs)
|
| 241 |
+
if design_url:
|
| 242 |
+
try:
|
| 243 |
+
img_data = requests.get(design_url).content
|
| 244 |
+
zip_file.writestr("slide_design.png", img_data)
|
| 245 |
+
except Exception as e:
|
| 246 |
+
st.error(f"Design download error: {str(e)}")
|
| 247 |
+
# Add voiceovers to ZIP
|
| 248 |
+
for filename, audio_data in voiceovers.items():
|
| 249 |
+
zip_file.writestr(f"voiceovers/{filename}", audio_data)
|
| 250 |
+
|
| 251 |
+
# Store results
|
| 252 |
+
st.session_state.outline = outline
|
| 253 |
+
st.session_state.content = content
|
| 254 |
+
st.session_state.slides = slides
|
| 255 |
+
st.session_state.code_labs = code_labs
|
| 256 |
+
st.session_state.design_url = design_url
|
| 257 |
+
st.session_state.voiceovers = voiceovers
|
| 258 |
+
st.session_state.zip_buffer = zip_buffer
|
| 259 |
+
st.session_state.gen_time = round(time.time() - start_time, 2)
|
| 260 |
+
st.session_state.generated = True
|
| 261 |
+
st.session_state.generating = False
|
| 262 |
|
| 263 |
+
# Results display
|
| 264 |
+
if st.session_state.generated:
|
| 265 |
+
st.success(f"✅ Executive workshop generated in {st.session_state.gen_time} seconds!")
|
| 266 |
+
|
| 267 |
+
# Download button
|
| 268 |
+
st.download_button(
|
| 269 |
+
label="📥 Download Executive Package",
|
| 270 |
+
data=st.session_state.zip_buffer.getvalue(),
|
| 271 |
+
file_name=f"{st.session_state.workshop_topic.replace(' ', '_')}_workshop.zip",
|
| 272 |
+
mime="application/zip",
|
| 273 |
+
use_container_width=True
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
+
# Executive summary
|
| 277 |
+
with st.expander("📊 Executive Overview", expanded=True):
|
| 278 |
+
st.markdown(f"<div class='executive-summary'>", unsafe_allow_html=True)
|
| 279 |
+
st.subheader(st.session_state.outline.get("title", "Strategic Workshop"))
|
| 280 |
+
st.caption(f"Duration: {st.session_state.outline.get('duration', '4 hours')} | Level: {st.session_state.outline.get('difficulty', 'Executive')}")
|
| 281 |
+
|
| 282 |
+
st.markdown("**Business Value Proposition**")
|
| 283 |
+
if "learning_goals" in st.session_state.outline:
|
| 284 |
+
for goal in st.session_state.outline["learning_goals"]:
|
| 285 |
+
st.markdown(f"- {goal}")
|
| 286 |
+
|
| 287 |
+
st.markdown("**Key Deliverables**")
|
| 288 |
+
st.markdown("- Boardroom-ready presentation\n"
|
| 289 |
+
"- Implementation toolkit\n"
|
| 290 |
+
"- ROI calculation framework\n"
|
| 291 |
+
"- Enterprise integration guide")
|
| 292 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 293 |
|
| 294 |
+
# Workshop content
|
| 295 |
+
with st.expander("📝 Strategic Content Framework"):
|
| 296 |
+
if "modules" in st.session_state.content:
|
| 297 |
+
for module in st.session_state.content["modules"]:
|
| 298 |
+
st.subheader(module.get("title", "Business Module"))
|
| 299 |
+
st.markdown(module.get("script", ""))
|
| 300 |
+
|
| 301 |
+
st.markdown("**Executive Discussion Points**")
|
| 302 |
+
if "discussion_questions" in module:
|
| 303 |
+
for q in module["discussion_questions"]:
|
| 304 |
+
st.markdown(f"- **{q.get('question', '')}**")
|
| 305 |
+
st.caption(q.get("response", ""))
|
| 306 |
|
| 307 |
+
# Slide preview
|
| 308 |
+
with st.expander("🖥️ Boardroom Presentation Preview"):
|
| 309 |
+
st.markdown("```markdown\n" + textwrap.dedent(st.session_state.slides[:2000]) + "\n```")
|
| 310 |
|
| 311 |
+
# Technical implementation
|
| 312 |
+
if st.session_state.code_labs:
|
| 313 |
+
with st.expander("💻 Enterprise Implementation Toolkit"):
|
| 314 |
+
st.code(st.session_state.code_labs)
|
| 315 |
|
| 316 |
+
# Design preview
|
| 317 |
+
if st.session_state.design_url:
|
| 318 |
+
with st.expander("🎨 Premium Visual Design"):
|
| 319 |
+
try:
|
| 320 |
+
st.image(st.session_state.design_url, caption="Corporate Slide Design")
|
| 321 |
+
except:
|
| 322 |
+
st.warning("Design preview unavailable")
|
| 323 |
+
|
| 324 |
+
# Voiceover player
|
| 325 |
+
if st.session_state.voiceovers:
|
| 326 |
+
with st.expander("🔊 Voiceover Previews"):
|
| 327 |
+
for i, (filename, audio_bytes) in enumerate(st.session_state.voiceovers.items()):
|
| 328 |
+
module_num = filename.split("_")[1]
|
| 329 |
+
st.subheader(f"Module {module_num} Introduction")
|
| 330 |
+
st.audio(audio_bytes, format="audio/mp3")
|
| 331 |
|
| 332 |
+
# Executive engagement section
|
| 333 |
+
st.divider()
|
| 334 |
+
st.subheader("🚀 Premium Corporate Offering")
|
| 335 |
+
st.markdown(f"""
|
| 336 |
+
### {st.session_state.workshop_topic} Executive Program
|
| 337 |
+
<div class="pricing-card">
|
| 338 |
+
<h4>Live Workshop</h4>
|
| 339 |
+
<h2>$15,000</h2>
|
| 340 |
+
<p>Full-day session with Q&A</p>
|
| 341 |
+
</div>
|
| 342 |
+
<div class="pricing-card">
|
| 343 |
+
<h4>On-Demand Course</h4>
|
| 344 |
+
<h2>$7,500</h2>
|
| 345 |
+
<p>Enterprise-wide access</p>
|
| 346 |
+
</div>
|
| 347 |
+
<div class="pricing-card">
|
| 348 |
+
<h4>Implementation Package</h4>
|
| 349 |
+
<h2>$12,500</h2>
|
| 350 |
+
<p>Technical integration support</p>
|
| 351 |
+
</div>
|
| 352 |
|
| 353 |
+
**Premium Features:**
|
| 354 |
+
- Customized to your industry vertical
|
| 355 |
+
- ROI guarantee
|
| 356 |
+
- 12-month support agreement
|
| 357 |
+
- Executive briefing package
|
| 358 |
+
""", unsafe_allow_html=True)
|
| 359 |
|
| 360 |
+
# Testimonials
|
| 361 |
+
st.divider()
|
| 362 |
+
st.subheader("💼 Executive Testimonials")
|
| 363 |
+
st.markdown("""
|
| 364 |
+
<div class="testimonial">
|
| 365 |
+
<p>"This platform helped us create a $50K training program in one afternoon. The ROI was immediate."</p>
|
| 366 |
+
<p><strong>— Sarah Johnson, CLO at FinTech Global</strong></p>
|
| 367 |
+
</div>
|
| 368 |
+
<div class="testimonial">
|
| 369 |
+
<p>"The boardroom-quality materials impressed our clients and justified our premium pricing."</p>
|
| 370 |
+
<p><strong>— Michael Chen, Partner at McKinsey & Company</strong></p>
|
| 371 |
+
</div>
|
| 372 |
+
""", unsafe_allow_html=True)
|
| 373 |
|
| 374 |
+
# CTA
|
| 375 |
+
st.divider()
|
| 376 |
+
col1, col2 = st.columns(2)
|
| 377 |
+
with col1:
|
| 378 |
+
st.link_button("📅 Book Strategy Session", "https://calendly.com/your-link", use_container_width=True)
|
| 379 |
+
with col2:
|
| 380 |
+
st.link_button("💼 Enterprise Solutions", "https://your-company.com/enterprise", use_container_width=True)
|
| 381 |
|
| 382 |
+
# Footer
|
| 383 |
+
st.divider()
|
| 384 |
+
st.markdown("""
|
| 385 |
+
<div style="text-align: center; padding: 20px; color: #aaa;">
|
| 386 |
+
Workshop in a Box Pro® | Enterprise-Grade AI Training Solutions | © 2025
|
| 387 |
+
</div>
|
| 388 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
+
# Debug info
|
| 391 |
+
with st.sidebar:
|
| 392 |
+
st.divider()
|
| 393 |
+
st.subheader("System Status")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
|
| 395 |
+
if hasattr(voiceover_agent, 'api_key') and voiceover_agent.api_key:
|
| 396 |
+
st.success("ElevenLabs API Key Found")
|
| 397 |
+
elif include_voiceover:
|
| 398 |
+
st.warning("ElevenLabs API key not set")
|
| 399 |
|
| 400 |
+
st.info(f"""
|
| 401 |
+
**Current Workshop:**
|
| 402 |
+
{st.session_state.workshop_topic}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
|
| 404 |
+
**Premium Features:**
|
| 405 |
+
- AI-generated voiceovers
|
| 406 |
+
- Professional slide designs
|
| 407 |
+
- Fortune 500 case studies
|
| 408 |
+
- Practical code labs
|
| 409 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|