Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
import json
|
| 4 |
import zipfile
|
|
@@ -6,16 +5,22 @@ import io
|
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
import openai
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
|
| 11 |
# Load environment variables
|
| 12 |
load_dotenv()
|
| 13 |
|
| 14 |
# Initialize OpenAI API key
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
# Combined agent classes
|
| 19 |
class TopicAgent:
|
| 20 |
def generate_outline(self, topic, duration, difficulty):
|
| 21 |
if not openai.api_key:
|
|
@@ -25,16 +30,27 @@ class TopicAgent:
|
|
| 25 |
response = openai.ChatCompletion.create(
|
| 26 |
model="gpt-4",
|
| 27 |
messages=[
|
| 28 |
-
{
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
-
return json.loads(response.choices[0].message
|
| 37 |
-
except:
|
|
|
|
| 38 |
return self._mock_outline(topic, duration, difficulty)
|
| 39 |
|
| 40 |
def _mock_outline(self, topic, duration, difficulty):
|
|
@@ -43,28 +59,38 @@ class TopicAgent:
|
|
| 43 |
"duration": f"{duration} hours",
|
| 44 |
"difficulty": difficulty,
|
| 45 |
"goals": [
|
| 46 |
-
|
| 47 |
-
"Develop
|
| 48 |
-
"
|
| 49 |
-
"
|
| 50 |
],
|
| 51 |
"modules": [
|
| 52 |
{
|
| 53 |
-
"title":
|
| 54 |
-
"duration": "
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"
|
| 58 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
]
|
| 60 |
},
|
| 61 |
{
|
| 62 |
-
"title":
|
| 63 |
-
"duration": "
|
| 64 |
-
"
|
| 65 |
-
"
|
| 66 |
-
"
|
| 67 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
]
|
| 69 |
}
|
| 70 |
]
|
|
@@ -79,16 +105,27 @@ class ContentAgent:
|
|
| 79 |
response = openai.ChatCompletion.create(
|
| 80 |
model="gpt-4",
|
| 81 |
messages=[
|
| 82 |
-
{
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
)
|
| 90 |
-
return json.loads(response.choices[0].message
|
| 91 |
-
except:
|
|
|
|
| 92 |
return self._mock_content(outline)
|
| 93 |
|
| 94 |
def _mock_content(self, outline):
|
|
@@ -96,118 +133,348 @@ class ContentAgent:
|
|
| 96 |
"workshop_title": f"Mastering {outline['topic']}",
|
| 97 |
"modules": [
|
| 98 |
{
|
| 99 |
-
"title":
|
| 100 |
-
"script":
|
| 101 |
-
"speaker_notes":
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
"quiz": [
|
| 104 |
{
|
| 105 |
-
"question":
|
| 106 |
-
"options": ["
|
| 107 |
-
"answer": "
|
|
|
|
| 108 |
}
|
| 109 |
-
]
|
| 110 |
-
|
|
|
|
| 111 |
]
|
| 112 |
}
|
| 113 |
|
| 114 |
class SlideAgent:
|
| 115 |
def generate_slides(self, content):
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
class CodeAgent:
|
| 127 |
def generate_code(self, content):
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
# Initialize agents
|
| 134 |
topic_agent = TopicAgent()
|
| 135 |
content_agent = ContentAgent()
|
| 136 |
slide_agent = SlideAgent()
|
| 137 |
code_agent = CodeAgent()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
#
|
| 140 |
-
st.
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
# Sidebar configuration
|
| 145 |
with st.sidebar:
|
| 146 |
-
st.header("Configuration")
|
| 147 |
workshop_topic = st.text_input("Workshop Topic", "Advanced Prompt Engineering")
|
| 148 |
-
duration = st.slider("Duration (hours)", 1.0, 8.0,
|
| 149 |
-
difficulty = st.selectbox("Difficulty
|
|
|
|
| 150 |
include_code = st.checkbox("Include Code Labs", True)
|
|
|
|
| 151 |
|
| 152 |
-
if st.button("β¨ Generate Workshop", type="primary"):
|
| 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 |
# Results display
|
| 178 |
-
if
|
| 179 |
-
st.success(f"
|
| 180 |
|
| 181 |
# Download button
|
| 182 |
st.download_button(
|
| 183 |
label="π₯ Download Workshop Package",
|
| 184 |
data=st.session_state.zip_buffer.getvalue(),
|
| 185 |
file_name=f"{workshop_topic.replace(' ', '_')}_workshop.zip",
|
| 186 |
-
mime="application/zip"
|
|
|
|
| 187 |
)
|
| 188 |
|
| 189 |
# Preview sections
|
| 190 |
-
with st.expander("Workshop Outline"):
|
| 191 |
st.json(st.session_state.outline)
|
| 192 |
|
| 193 |
-
with st.expander("Content Script"):
|
| 194 |
st.write(st.session_state.content)
|
| 195 |
|
| 196 |
-
with st.expander("Slide Deck Preview"):
|
| 197 |
-
st.markdown(st.session_state.slides)
|
| 198 |
|
| 199 |
if st.session_state.code_labs:
|
| 200 |
-
with st.expander("Code Labs"):
|
| 201 |
st.code(st.session_state.code_labs)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
-
# Sales
|
| 204 |
st.divider()
|
| 205 |
-
st.subheader("Ready to
|
| 206 |
-
st.
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
import zipfile
|
|
|
|
| 5 |
import time
|
| 6 |
import os
|
| 7 |
import openai
|
| 8 |
+
import requests
|
| 9 |
+
from PIL import Image
|
| 10 |
+
import base64
|
| 11 |
+
import textwrap
|
| 12 |
from dotenv import load_dotenv
|
| 13 |
|
| 14 |
# Load environment variables
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
# Initialize OpenAI API key
|
| 18 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 19 |
+
|
| 20 |
+
# =============================
|
| 21 |
+
# ENHANCED AGENT IMPLEMENTATION
|
| 22 |
+
# =============================
|
| 23 |
|
|
|
|
| 24 |
class TopicAgent:
|
| 25 |
def generate_outline(self, topic, duration, difficulty):
|
| 26 |
if not openai.api_key:
|
|
|
|
| 30 |
response = openai.ChatCompletion.create(
|
| 31 |
model="gpt-4",
|
| 32 |
messages=[
|
| 33 |
+
{
|
| 34 |
+
"role": "system",
|
| 35 |
+
"content": "You're an expert corporate trainer creating comprehensive AI workshop outlines."
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"role": "user",
|
| 39 |
+
"content": (
|
| 40 |
+
f"Create a detailed {duration}-hour {difficulty} workshop outline on {topic}. "
|
| 41 |
+
"Include: 4-6 modules with specific learning objectives, hands-on exercises, "
|
| 42 |
+
"and real-world case studies. Format as JSON with keys: "
|
| 43 |
+
"{'topic', 'duration', 'difficulty', 'goals', 'modules': ["
|
| 44 |
+
"{'title', 'duration', 'learning_objectives', 'case_study', 'exercises'}]}"
|
| 45 |
+
)
|
| 46 |
+
}
|
| 47 |
+
],
|
| 48 |
+
temperature=0.3,
|
| 49 |
+
max_tokens=1500
|
| 50 |
)
|
| 51 |
+
return json.loads(response.choices[0].message['content'])
|
| 52 |
+
except Exception as e:
|
| 53 |
+
st.error(f"Outline generation error: {str(e)}")
|
| 54 |
return self._mock_outline(topic, duration, difficulty)
|
| 55 |
|
| 56 |
def _mock_outline(self, topic, duration, difficulty):
|
|
|
|
| 59 |
"duration": f"{duration} hours",
|
| 60 |
"difficulty": difficulty,
|
| 61 |
"goals": [
|
| 62 |
+
"Master core concepts and advanced techniques",
|
| 63 |
+
"Develop practical implementation skills",
|
| 64 |
+
"Learn industry best practices and case studies",
|
| 65 |
+
"Build confidence in real-world applications"
|
| 66 |
],
|
| 67 |
"modules": [
|
| 68 |
{
|
| 69 |
+
"title": "Foundations of Prompt Engineering",
|
| 70 |
+
"duration": "90 min",
|
| 71 |
+
"learning_objectives": [
|
| 72 |
+
"Understand prompt components and structure",
|
| 73 |
+
"Learn prompt patterns and anti-patterns",
|
| 74 |
+
"Master zero-shot and few-shot prompting"
|
| 75 |
+
],
|
| 76 |
+
"case_study": "How Anthropic improved customer support with prompt engineering",
|
| 77 |
+
"exercises": [
|
| 78 |
+
"Craft effective prompts for different scenarios",
|
| 79 |
+
"Optimize prompts for specific AI models"
|
| 80 |
]
|
| 81 |
},
|
| 82 |
{
|
| 83 |
+
"title": "Advanced Techniques & Strategies",
|
| 84 |
+
"duration": "120 min",
|
| 85 |
+
"learning_objectives": [
|
| 86 |
+
"Implement chain-of-thought prompting",
|
| 87 |
+
"Use meta-prompts for complex tasks",
|
| 88 |
+
"Apply self-consistency methods"
|
| 89 |
+
],
|
| 90 |
+
"case_study": "OpenAI's approach to prompt engineering in GPT-4",
|
| 91 |
+
"exercises": [
|
| 92 |
+
"Design prompts for multi-step reasoning",
|
| 93 |
+
"Create self-correcting prompt systems"
|
| 94 |
]
|
| 95 |
}
|
| 96 |
]
|
|
|
|
| 105 |
response = openai.ChatCompletion.create(
|
| 106 |
model="gpt-4",
|
| 107 |
messages=[
|
| 108 |
+
{
|
| 109 |
+
"role": "system",
|
| 110 |
+
"content": "You're a corporate training content developer creating detailed workshop materials."
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"role": "user",
|
| 114 |
+
"content": (
|
| 115 |
+
f"Expand this workshop outline into comprehensive content: {json.dumps(outline)}. "
|
| 116 |
+
"For each module, include: detailed script (3-5 paragraphs), speaker notes (bullet points), "
|
| 117 |
+
"3 quiz questions with explanations, and exercise instructions. Format as JSON with keys: "
|
| 118 |
+
"{'workshop_title', 'modules': [{'title', 'script', 'speaker_notes', 'quiz': ["
|
| 119 |
+
"{'question', 'options', 'answer', 'explanation'}], 'exercise_instructions'}]}"
|
| 120 |
+
)
|
| 121 |
+
}
|
| 122 |
+
],
|
| 123 |
+
temperature=0.4,
|
| 124 |
+
max_tokens=2000
|
| 125 |
)
|
| 126 |
+
return json.loads(response.choices[0].message['content'])
|
| 127 |
+
except Exception as e:
|
| 128 |
+
st.error(f"Content generation error: {str(e)}")
|
| 129 |
return self._mock_content(outline)
|
| 130 |
|
| 131 |
def _mock_content(self, outline):
|
|
|
|
| 133 |
"workshop_title": f"Mastering {outline['topic']}",
|
| 134 |
"modules": [
|
| 135 |
{
|
| 136 |
+
"title": "Foundations of Prompt Engineering",
|
| 137 |
+
"script": "This module introduces the core concepts of effective prompt engineering...",
|
| 138 |
+
"speaker_notes": [
|
| 139 |
+
"Emphasize the importance of clear instructions",
|
| 140 |
+
"Show examples of good vs bad prompts",
|
| 141 |
+
"Discuss token limitations and their impact"
|
| 142 |
+
],
|
| 143 |
"quiz": [
|
| 144 |
{
|
| 145 |
+
"question": "What's the most important element of a good prompt?",
|
| 146 |
+
"options": ["Length", "Specificity", "Complexity", "Creativity"],
|
| 147 |
+
"answer": "Specificity",
|
| 148 |
+
"explanation": "Specific prompts yield more accurate and relevant responses"
|
| 149 |
}
|
| 150 |
+
],
|
| 151 |
+
"exercise_instructions": "Create a prompt that extracts key insights from a financial report..."
|
| 152 |
+
}
|
| 153 |
]
|
| 154 |
}
|
| 155 |
|
| 156 |
class SlideAgent:
|
| 157 |
def generate_slides(self, content):
|
| 158 |
+
if not openai.api_key:
|
| 159 |
+
return self._mock_slides(content)
|
| 160 |
+
|
| 161 |
+
try:
|
| 162 |
+
response = openai.ChatCompletion.create(
|
| 163 |
+
model="gpt-4",
|
| 164 |
+
messages=[
|
| 165 |
+
{
|
| 166 |
+
"role": "system",
|
| 167 |
+
"content": "You create professional slide decks in Markdown format using Marp syntax."
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"role": "user",
|
| 171 |
+
"content": (
|
| 172 |
+
f"Create a slide deck for this workshop content: {json.dumps(content)}. "
|
| 173 |
+
"Use Marp Markdown format with themes and visual elements. "
|
| 174 |
+
"Include: title slide, module slides with key points, case studies, "
|
| 175 |
+
"exercise instructions, and summary slides. Make it visually appealing."
|
| 176 |
+
)
|
| 177 |
+
}
|
| 178 |
+
],
|
| 179 |
+
temperature=0.2,
|
| 180 |
+
max_tokens=2500
|
| 181 |
+
)
|
| 182 |
+
return response.choices[0].message['content']
|
| 183 |
+
except Exception as e:
|
| 184 |
+
st.error(f"Slide generation error: {str(e)}")
|
| 185 |
+
return self._mock_slides(content)
|
| 186 |
+
|
| 187 |
+
def _mock_slides(self, content):
|
| 188 |
+
return f"""---
|
| 189 |
+
marp: true
|
| 190 |
+
theme: gaia
|
| 191 |
+
backgroundColor: #fff
|
| 192 |
+
backgroundImage: url('https://marp.app/assets/hero-background.svg')
|
| 193 |
+
---
|
| 194 |
+
|
| 195 |
+
# {content['workshop_title']}
|
| 196 |
+
## Comprehensive Corporate Training Program
|
| 197 |
+
|
| 198 |
+
---
|
| 199 |
+
|
| 200 |
+
## Module 1: Foundations of Prompt Engineering
|
| 201 |
+

|
| 202 |
+
|
| 203 |
+
- Core concepts and principles
|
| 204 |
+
- Patterns and anti-patterns
|
| 205 |
+
- Practical implementation techniques
|
| 206 |
+
|
| 207 |
+
---
|
| 208 |
+
|
| 209 |
+
## Case Study
|
| 210 |
+
### Anthropic's Customer Support Implementation
|
| 211 |
+
- 40% faster resolution times
|
| 212 |
+
- 25% reduction in training costs
|
| 213 |
+
- 92% customer satisfaction
|
| 214 |
+
|
| 215 |
+
---
|
| 216 |
+
|
| 217 |
+
## Exercises
|
| 218 |
+
1. Craft effective prompts for different scenarios
|
| 219 |
+
2. Optimize prompts for specific AI models
|
| 220 |
+
3. Analyze and refine prompt performance
|
| 221 |
+
|
| 222 |
+
"""
|
| 223 |
|
| 224 |
class CodeAgent:
|
| 225 |
def generate_code(self, content):
|
| 226 |
+
if not openai.api_key:
|
| 227 |
+
return self._mock_code(content)
|
| 228 |
+
|
| 229 |
+
try:
|
| 230 |
+
response = openai.ChatCompletion.create(
|
| 231 |
+
model="gpt-4",
|
| 232 |
+
messages=[
|
| 233 |
+
{
|
| 234 |
+
"role": "system",
|
| 235 |
+
"content": "You create practical code labs for technical workshops."
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"role": "user",
|
| 239 |
+
"content": (
|
| 240 |
+
f"Create a Jupyter notebook with code exercises for this workshop: {json.dumps(content)}. "
|
| 241 |
+
"Include: setup instructions, practical exercises with solutions, "
|
| 242 |
+
"and real-world implementation examples. Use Python with popular AI libraries."
|
| 243 |
+
)
|
| 244 |
+
}
|
| 245 |
+
],
|
| 246 |
+
temperature=0.3,
|
| 247 |
+
max_tokens=2000
|
| 248 |
+
)
|
| 249 |
+
return response.choices[0].message['content']
|
| 250 |
+
except Exception as e:
|
| 251 |
+
st.error(f"Code generation error: {str(e)}")
|
| 252 |
+
return self._mock_code(content)
|
| 253 |
+
|
| 254 |
+
def _mock_code(self, content):
|
| 255 |
+
return f"""# {content['workshop_title']} - Code Labs
|
| 256 |
+
|
| 257 |
+
import openai
|
| 258 |
+
import pandas as pd
|
| 259 |
+
|
| 260 |
+
## Exercise 1: Basic Prompt Engineering
|
| 261 |
+
def generate_response(prompt):
|
| 262 |
+
response = openai.ChatCompletion.create(
|
| 263 |
+
model="gpt-4",
|
| 264 |
+
messages=[{{"role": "user", "content": prompt}}]
|
| 265 |
+
)
|
| 266 |
+
return response.choices[0].message['content']
|
| 267 |
+
|
| 268 |
+
# Test your function
|
| 269 |
+
print(generate_response("Explain quantum computing in simple terms"))
|
| 270 |
+
|
| 271 |
+
## Exercise 2: Advanced Prompt Patterns
|
| 272 |
+
# TODO: Implement chain-of-thought prompting
|
| 273 |
+
# TODO: Create meta-prompts for complex tasks
|
| 274 |
+
|
| 275 |
+
## Real-World Implementation
|
| 276 |
+
# TODO: Build a customer support question classifier
|
| 277 |
+
"""
|
| 278 |
+
|
| 279 |
+
class DesignAgent:
|
| 280 |
+
def generate_design(self, slide_content):
|
| 281 |
+
if not openai.api_key:
|
| 282 |
+
return None
|
| 283 |
+
|
| 284 |
+
try:
|
| 285 |
+
response = openai.Image.create(
|
| 286 |
+
prompt=f"Create a professional slide background for a corporate AI workshop about: {slide_content[:500]}",
|
| 287 |
+
n=1,
|
| 288 |
+
size="1024x1024"
|
| 289 |
+
)
|
| 290 |
+
return response['data'][0]['url']
|
| 291 |
+
except Exception as e:
|
| 292 |
+
st.error(f"Design generation error: {str(e)}")
|
| 293 |
+
return None
|
| 294 |
|
| 295 |
# Initialize agents
|
| 296 |
topic_agent = TopicAgent()
|
| 297 |
content_agent = ContentAgent()
|
| 298 |
slide_agent = SlideAgent()
|
| 299 |
code_agent = CodeAgent()
|
| 300 |
+
design_agent = DesignAgent()
|
| 301 |
+
|
| 302 |
+
# =====================
|
| 303 |
+
# STREAMLIT APPLICATION
|
| 304 |
+
# =====================
|
| 305 |
+
|
| 306 |
+
st.set_page_config(
|
| 307 |
+
page_title="Workshop in a Box Pro",
|
| 308 |
+
layout="wide",
|
| 309 |
+
initial_sidebar_state="expanded"
|
| 310 |
+
)
|
| 311 |
|
| 312 |
+
# Custom CSS
|
| 313 |
+
st.markdown("""
|
| 314 |
+
<style>
|
| 315 |
+
.stApp {
|
| 316 |
+
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
| 317 |
+
color: #fff;
|
| 318 |
+
}
|
| 319 |
+
.stTextInput>div>div>input, .stSlider>div>div>div>div {
|
| 320 |
+
background-color: rgba(255,255,255,0.1) !important;
|
| 321 |
+
color: white !important;
|
| 322 |
+
}
|
| 323 |
+
.stButton>button {
|
| 324 |
+
background: linear-gradient(to right, #00b09b, #96c93d) !important;
|
| 325 |
+
color: white !important;
|
| 326 |
+
border: none;
|
| 327 |
+
border-radius: 30px;
|
| 328 |
+
padding: 10px 25px;
|
| 329 |
+
font-size: 16px;
|
| 330 |
+
font-weight: bold;
|
| 331 |
+
}
|
| 332 |
+
.stDownloadButton>button {
|
| 333 |
+
background: linear-gradient(to right, #ff5e62, #ff9966) !important;
|
| 334 |
+
}
|
| 335 |
+
.stExpander {
|
| 336 |
+
background-color: rgba(0,0,0,0.2) !important;
|
| 337 |
+
border-radius: 10px;
|
| 338 |
+
padding: 15px;
|
| 339 |
+
}
|
| 340 |
+
</style>
|
| 341 |
+
""", unsafe_allow_html=True)
|
| 342 |
+
|
| 343 |
+
# Header
|
| 344 |
+
col1, col2 = st.columns([1, 3])
|
| 345 |
+
with col1:
|
| 346 |
+
st.image("https://cdn-icons-png.flaticon.com/512/1995/1995485.png", width=100)
|
| 347 |
+
with col2:
|
| 348 |
+
st.title("π€ Workshop in a Box Pro")
|
| 349 |
+
st.caption("Generate Premium Corporate AI Training Workshops in Minutes")
|
| 350 |
|
| 351 |
# Sidebar configuration
|
| 352 |
with st.sidebar:
|
| 353 |
+
st.header("βοΈ Workshop Configuration")
|
| 354 |
workshop_topic = st.text_input("Workshop Topic", "Advanced Prompt Engineering")
|
| 355 |
+
duration = st.slider("Duration (hours)", 1.0, 8.0, 3.0, 0.5)
|
| 356 |
+
difficulty = st.selectbox("Difficulty Level",
|
| 357 |
+
["Beginner", "Intermediate", "Advanced", "Expert"])
|
| 358 |
include_code = st.checkbox("Include Code Labs", True)
|
| 359 |
+
include_design = st.checkbox("Generate Visual Designs", True)
|
| 360 |
|
| 361 |
+
if st.button("β¨ Generate Workshop", type="primary", use_container_width=True):
|
| 362 |
+
st.session_state.generating = True
|
| 363 |
+
|
| 364 |
+
# Generation pipeline
|
| 365 |
+
if hasattr(st.session_state, 'generating'):
|
| 366 |
+
with st.spinner("π Creating your premium workshop materials..."):
|
| 367 |
+
start_time = time.time()
|
| 368 |
+
|
| 369 |
+
# Agent pipeline
|
| 370 |
+
outline = topic_agent.generate_outline(workshop_topic, duration, difficulty)
|
| 371 |
+
content = content_agent.generate_content(outline)
|
| 372 |
+
slides = slide_agent.generate_slides(content)
|
| 373 |
+
code_labs = code_agent.generate_code(content) if include_code else None
|
| 374 |
+
design_url = design_agent.generate_design(slides) if include_design else None
|
| 375 |
+
|
| 376 |
+
# Prepare download package
|
| 377 |
+
zip_buffer = io.BytesIO()
|
| 378 |
+
with zipfile.ZipFile(zip_buffer, "a") as zip_file:
|
| 379 |
+
zip_file.writestr("outline.json", json.dumps(outline, indent=2))
|
| 380 |
+
zip_file.writestr("content.json", json.dumps(content, indent=2))
|
| 381 |
+
zip_file.writestr("slides.md", slides)
|
| 382 |
+
if code_labs:
|
| 383 |
+
zip_file.writestr("code_labs.ipynb", code_labs)
|
| 384 |
+
if design_url:
|
| 385 |
+
try:
|
| 386 |
+
img_data = requests.get(design_url).content
|
| 387 |
+
zip_file.writestr("slide_design.png", img_data)
|
| 388 |
+
except:
|
| 389 |
+
pass
|
| 390 |
+
|
| 391 |
+
# Store results
|
| 392 |
+
st.session_state.outline = outline
|
| 393 |
+
st.session_state.content = content
|
| 394 |
+
st.session_state.slides = slides
|
| 395 |
+
st.session_state.code_labs = code_labs
|
| 396 |
+
st.session_state.design_url = design_url
|
| 397 |
+
st.session_state.zip_buffer = zip_buffer
|
| 398 |
+
st.session_state.gen_time = round(time.time() - start_time, 2)
|
| 399 |
+
st.session_state.generated = True
|
| 400 |
+
st.session_state.generating = False
|
| 401 |
|
| 402 |
# Results display
|
| 403 |
+
if hasattr(st.session_state, 'generated'):
|
| 404 |
+
st.success(f"β
Premium workshop materials generated in {st.session_state.gen_time} seconds!")
|
| 405 |
|
| 406 |
# Download button
|
| 407 |
st.download_button(
|
| 408 |
label="π₯ Download Workshop Package",
|
| 409 |
data=st.session_state.zip_buffer.getvalue(),
|
| 410 |
file_name=f"{workshop_topic.replace(' ', '_')}_workshop.zip",
|
| 411 |
+
mime="application/zip",
|
| 412 |
+
use_container_width=True
|
| 413 |
)
|
| 414 |
|
| 415 |
# Preview sections
|
| 416 |
+
with st.expander("π Workshop Outline", expanded=True):
|
| 417 |
st.json(st.session_state.outline)
|
| 418 |
|
| 419 |
+
with st.expander("π Content Script"):
|
| 420 |
st.write(st.session_state.content)
|
| 421 |
|
| 422 |
+
with st.expander("π₯οΈ Slide Deck Preview"):
|
| 423 |
+
st.markdown("```markdown\n" + textwrap.dedent(st.session_state.slides[:2000]) + "\n```")
|
| 424 |
|
| 425 |
if st.session_state.code_labs:
|
| 426 |
+
with st.expander("π» Code Labs"):
|
| 427 |
st.code(st.session_state.code_labs)
|
| 428 |
+
|
| 429 |
+
if st.session_state.design_url:
|
| 430 |
+
with st.expander("π¨ Generated Design"):
|
| 431 |
+
st.image(st.session_state.design_url, caption="Custom Slide Design")
|
| 432 |
|
| 433 |
+
# Sales and booking section
|
| 434 |
st.divider()
|
| 435 |
+
st.subheader("π Ready to Deliver This Workshop?")
|
| 436 |
+
st.markdown("""
|
| 437 |
+
### Premium Corporate Training Package
|
| 438 |
+
- **Live Workshop Delivery**: $10,000 per session
|
| 439 |
+
- **On-Demand Course**: $5,000 (unlimited access)
|
| 440 |
+
- **Pilot Program**: $1,000 refundable deposit
|
| 441 |
+
|
| 442 |
+
β¨ **All inclusive**: Customization, materials, and follow-up support
|
| 443 |
+
""")
|
| 444 |
+
|
| 445 |
+
col1, col2 = st.columns(2)
|
| 446 |
+
with col1:
|
| 447 |
+
st.link_button("π
Book a Live Workshop", "https://calendly.com/your-link",
|
| 448 |
+
use_container_width=True)
|
| 449 |
+
with col2:
|
| 450 |
+
st.link_button("π³ Purchase On-Demand Course", "https://your-store.com",
|
| 451 |
+
use_container_width=True)
|
| 452 |
+
|
| 453 |
+
# Debug info
|
| 454 |
+
with st.sidebar:
|
| 455 |
+
st.divider()
|
| 456 |
+
if openai.api_key:
|
| 457 |
+
st.success("OpenAI API Connected")
|
| 458 |
+
else:
|
| 459 |
+
st.warning("OpenAI API not set - using enhanced mock data")
|
| 460 |
+
|
| 461 |
+
st.info("""
|
| 462 |
+
**Premium Features:**
|
| 463 |
+
- AI-generated slide designs
|
| 464 |
+
- Real-world case studies
|
| 465 |
+
- Practical code labs
|
| 466 |
+
- Professional templates
|
| 467 |
+
""")
|
| 468 |
+
|
| 469 |
+
# How it works section
|
| 470 |
+
st.divider()
|
| 471 |
+
st.subheader("π‘ How It Works")
|
| 472 |
+
st.markdown("""
|
| 473 |
+
1. **Configure** your workshop topic and parameters
|
| 474 |
+
2. **Generate** premium training materials in seconds
|
| 475 |
+
3. **Customize** the content to your specific needs
|
| 476 |
+
4. **Deliver** high-value corporate training at $10K/session
|
| 477 |
+
5. **Reuse** the materials for unlimited revenue
|
| 478 |
+
|
| 479 |
+
*"Created 3 workshops in 15 minutes and booked $30K in contracts"* - Sarah T., AI Training Consultant
|
| 480 |
+
""")
|