tarruck's picture
Create app.py
cd10f0d verified
import gradio as gr
import json
import random
from datetime import datetime
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# Simulated database for demo purposes
USERS_DB = {}
PROGRESS_DB = {}
# Course curriculum structure
CURRICULUM = {
"beginner": {
"title": "AI Foundations to Agent Builder",
"duration": "80-100 hours",
"modules": [
{"name": "Introduction to AI and Agents", "duration": "5 hours"},
{"name": "Understanding Language Models", "duration": "8 hours"},
{"name": "Basic Prompt Engineering", "duration": "10 hours"},
{"name": "No-Code Agent Building", "duration": "15 hours"},
{"name": "Business Applications", "duration": "12 hours"},
{"name": "First Agent Project", "duration": "20 hours"},
{"name": "Deployment Basics", "duration": "10 hours"},
{"name": "Career Preparation", "duration": "10 hours"}
]
},
"intermediate": {
"title": "Agent Developer Professional",
"duration": "120-150 hours",
"modules": [
{"name": "Advanced Prompt Engineering", "duration": "15 hours"},
{"name": "Python for AI Agents", "duration": "20 hours"},
{"name": "LangChain Fundamentals", "duration": "15 hours"},
{"name": "Multi-Provider Integration", "duration": "20 hours"},
{"name": "Memory and Context Management", "duration": "15 hours"},
{"name": "Tool Creation and Integration", "duration": "20 hours"},
{"name": "Production Deployment", "duration": "15 hours"},
{"name": "Advanced Projects", "duration": "30 hours"}
]
},
"advanced": {
"title": "Enterprise AI Architect",
"duration": "180-220 hours",
"modules": [
{"name": "Multi-Agent Systems Design", "duration": "25 hours"},
{"name": "Custom Framework Development", "duration": "30 hours"},
{"name": "Scalable Architecture Patterns", "duration": "20 hours"},
{"name": "Security and Compliance", "duration": "15 hours"},
{"name": "Performance Optimization", "duration": "20 hours"},
{"name": "Industry Specialization", "duration": "30 hours"},
{"name": "Enterprise Integration", "duration": "25 hours"},
{"name": "Capstone Project", "duration": "35 hours"}
]
}
}
# Sample agent templates
AGENT_TEMPLATES = {
"customer_service": {
"name": "Customer Service Pro",
"description": "Handle customer inquiries with empathy and efficiency",
"code": """# Customer Service Agent
agent = AgentBuilder(
name="CustomerServicePro",
model="gpt-4",
system_prompt=\"\"\"You are a helpful customer service agent.
Be empathetic, solution-focused, and professional.
Always try to resolve issues on first contact.\"\"\",
tools=["order_lookup", "refund_process", "ticket_create"],
memory_type="conversation",
max_tokens=150
)
# Example usage
response = agent.process("I haven't received my order #12345")
print(response)"""
},
"data_analyst": {
"name": "Data Analyst Agent",
"description": "Automated data analysis and visualization",
"code": """# Data Analysis Agent
analyst = DataAnalystAgent(
name="DataInsightsPro",
model="gpt-4",
capabilities={
"data_sources": ["csv", "sql", "api"],
"analysis_types": ["descriptive", "predictive", "prescriptive"],
"visualizations": ["charts", "dashboards", "reports"]
},
auto_insights=True
)
# Analyze sales data
insights = analyst.analyze("sales_data.csv",
questions=["What are the top performing products?",
"Identify seasonal trends",
"Predict next quarter revenue"])"""
},
"content_creator": {
"name": "Content Creator Agent",
"description": "Generate engaging content for multiple platforms",
"code": """# Content Creation Agent
creator = ContentAgent(
name="ContentGenius",
model="claude-3-opus",
style_guide={
"tone": "professional yet engaging",
"format": "SEO-optimized",
"platforms": ["blog", "social", "email"]
},
fact_checking=True
)
# Generate blog post
post = creator.create(
type="blog_post",
topic="The Future of AI Agents",
keywords=["AI agents", "automation", "future of work"],
length=1000
)"""
}
}
def create_header():
return """
<div style="text-align: center; padding: 20px;">
<h1 style="color: #6366f1; font-size: 3em; margin-bottom: 10px;">🎓 AgenticAI Academy</h1>
<p style="font-size: 1.2em; color: #666;">Master AI Agent Development • From Beginner to Expert</p>
<p style="margin-top: 20px;">
<span style="background: #e0f2fe; color: #0369a1; padding: 5px 15px; border-radius: 20px; margin: 0 5px;">$32B Market by 2030</span>
<span style="background: #fef3c7; color: #d97706; padding: 5px 15px; border-radius: 20px; margin: 0 5px;">31.2% Annual Growth</span>
<span style="background: #fce7f3; color: #be185d; padding: 5px 15px; border-radius: 20px; margin: 0 5px;">$100K-250K+ Salaries</span>
</p>
</div>
"""
def register_user(name, email, experience_level, learning_goal):
"""Register a new user"""
if email in USERS_DB:
return "❌ Email already registered. Please login instead."
USERS_DB[email] = {
"name": name,
"experience_level": experience_level,
"learning_goal": learning_goal,
"registered": datetime.now().isoformat(),
"path": "beginner" if experience_level == "No coding experience" else "intermediate"
}
PROGRESS_DB[email] = {
"completed_modules": [],
"current_module": 0,
"total_hours": 0,
"projects": []
}
return f"✅ Welcome to AgenticAI Academy, {name}! Your {USERS_DB[email]['path']} learning path is ready."
def get_personalized_curriculum(email):
"""Get personalized curriculum based on user profile"""
if email not in USERS_DB:
return "Please register first to see your personalized curriculum."
user = USERS_DB[email]
path = user["path"]
curriculum = CURRICULUM[path]
progress = PROGRESS_DB.get(email, {})
completed = len(progress.get("completed_modules", []))
output = f"## 📚 Your Learning Path: {curriculum['title']}\n\n"
output += f"**Total Duration:** {curriculum['duration']}\n"
output += f"**Progress:** {completed}/{len(curriculum['modules'])} modules completed\n\n"
output += "### Modules:\n"
for i, module in enumerate(curriculum['modules']):
status = "✅" if i < completed else "⏳"
output += f"{i+1}. {status} **{module['name']}** ({module['duration']})\n"
return output
def generate_agent_code(agent_type, use_case, model_choice, include_memory, include_tools):
"""Generate custom agent code based on parameters"""
template = AGENT_TEMPLATES.get(agent_type, AGENT_TEMPLATES["customer_service"])
code = f"""# Generated {agent_type.replace('_', ' ').title()} Agent
# Use case: {use_case}
from agenticai import AgentBuilder, MemoryStore, ToolRegistry
# Initialize agent
agent = AgentBuilder(
name="{agent_type}_agent",
model="{model_choice}",
temperature=0.7
)
# Configure system prompt
agent.set_system_prompt(\"\"\"
{template['description']}
Specific use case: {use_case}
\"\"\")
"""
if include_memory:
code += """
# Add memory capabilities
agent.add_memory(
type="long_term",
store=MemoryStore(
vector_db="pinecone",
embedding_model="text-embedding-ada-002"
)
)
"""
if include_tools:
code += """
# Add tools
agent.add_tools([
"web_search",
"calculator",
"code_executor",
"file_handler"
])
"""
code += """
# Example usage
response = agent.process("Your query here")
print(response)
# Deploy agent
# agent.deploy(endpoint="/api/agent", port=8080)
"""
return code
def create_progress_visualization(email):
"""Create visual progress chart"""
if email not in PROGRESS_DB:
return None
progress = PROGRESS_DB[email]
user = USERS_DB.get(email, {})
path = user.get("path", "beginner")
curriculum = CURRICULUM[path]
# Create progress data
modules = [m["name"] for m in curriculum["modules"]]
completed = progress.get("completed_modules", [])
status = ["Completed" if i < len(completed) else "Pending" for i in range(len(modules))]
hours = [m["duration"].split()[0] for m in curriculum["modules"]]
# Create DataFrame
df = pd.DataFrame({
"Module": modules,
"Status": status,
"Hours": [int(h) for h in hours]
})
# Create Plotly figure
fig = px.bar(df, x="Hours", y="Module", orientation='h', color="Status",
color_discrete_map={"Completed": "#10b981", "Pending": "#e5e7eb"},
title="Your Learning Progress")
fig.update_layout(
showlegend=False,
xaxis_title="Duration (hours)",
yaxis_title="",
height=400
)
return fig
def simulate_agent_conversation(agent_type, user_input):
"""Simulate agent responses"""
responses = {
"customer_service": [
"I understand your concern. Let me look into that for you right away.",
"I've found your order #12345. It's currently in transit and should arrive within 2 days.",
"I apologize for the inconvenience. I'm processing a full refund for you now.",
"Is there anything else I can help you with today?"
],
"data_analyst": [
"I've analyzed your data and found some interesting patterns.",
"The top performing category shows 34% growth month-over-month.",
"Based on historical trends, I predict a 15% increase in Q2.",
"I've created a visualization to better illustrate these insights."
],
"content_creator": [
"I've drafted an engaging blog post optimized for your keywords.",
"The content includes relevant statistics and expert insights.",
"I've structured it with SEO-friendly headers and meta descriptions.",
"Would you like me to adjust the tone or add more sections?"
]
}
# Simulate processing
agent_responses = responses.get(agent_type, responses["customer_service"])
response = random.choice(agent_responses)
return f"**Agent Response:** {response}\n\n*This is a simulated response. In the full course, you'll build real agents that connect to actual AI models.*"
def create_market_stats():
"""Create market statistics visualization"""
# Market growth data
years = list(range(2024, 2031))
market_size = [5.88, 7.73, 10.16, 13.36, 17.57, 23.11, 30.39]
fig = go.Figure()
fig.add_trace(go.Scatter(
x=years,
y=market_size,
mode='lines+markers',
name='Market Size',
line=dict(color='#6366f1', width=3),
marker=dict(size=8)
))
fig.update_layout(
title="AI Education Market Growth (Billions USD)",
xaxis_title="Year",
yaxis_title="Market Size (Billions)",
showlegend=False,
height=400
)
return fig
# Create Gradio interface
with gr.Blocks(title="AgenticAI Academy", theme=gr.themes.Base()) as app:
gr.HTML(create_header())
with gr.Tabs():
# Registration Tab
with gr.TabItem("🚀 Get Started"):
with gr.Row():
with gr.Column():
gr.Markdown("""
### Start Your AI Agent Development Journey
Join thousands of professionals learning to build production-ready AI agents.
Our hands-on curriculum takes you from beginner to expert, with real projects
and industry certifications.
""")
name_input = gr.Textbox(label="Full Name", placeholder="John Doe")
email_input = gr.Textbox(label="Email", placeholder="[email protected]")
experience_level = gr.Radio(
label="Current Experience Level",
choices=["No coding experience", "Some programming knowledge", "Experienced developer"],
value="No coding experience"
)
learning_goal = gr.Dropdown(
label="Primary Learning Goal",
choices=[
"Career transition to AI",
"Add AI skills to current role",
"Build AI products/startups",
"Enterprise AI implementation"
],
value="Career transition to AI"
)
register_btn = gr.Button("Start Free Trial", variant="primary", size="lg")
registration_output = gr.Textbox(label="Registration Status", lines=2)
with gr.Column():
gr.Markdown("""
### 📊 Market Opportunity
The AI education market is experiencing explosive growth, creating unprecedented
opportunities for skilled professionals.
""")
market_chart = gr.Plot(value=create_market_stats())
gr.Markdown("""
### 💰 Earning Potential
- **Freelance:** $50-500/hour
- **Full-time:** $100K-250K+ annually
- **Consulting:** $1,000-5,000/day
- **Products:** Unlimited scaling potential
""")
register_btn.click(
register_user,
inputs=[name_input, email_input, experience_level, learning_goal],
outputs=registration_output
)
# Curriculum Tab
with gr.TabItem("📚 Curriculum"):
with gr.Row():
with gr.Column(scale=1):
curriculum_email = gr.Textbox(
label="Enter your email to see personalized curriculum",
placeholder="[email protected]"
)
show_curriculum_btn = gr.Button("Show My Curriculum", variant="primary")
with gr.Column(scale=2):
curriculum_output = gr.Markdown()
progress_chart = gr.Plot()
show_curriculum_btn.click(
get_personalized_curriculum,
inputs=[curriculum_email],
outputs=curriculum_output
).then(
create_progress_visualization,
inputs=[curriculum_email],
outputs=progress_chart
)
gr.Markdown("""
### 🎓 Available Learning Paths
#### Beginner Path: AI Foundations to Agent Builder (80-100 hours)
Perfect for non-technical professionals. Learn to build AI agents using visual tools
and no-code platforms. Focus on business applications and practical implementation.
#### Intermediate Path: Agent Developer Professional (120-150 hours)
For developers ready to add AI to their toolkit. Master Python-based agent development,
advanced prompt engineering, and multi-provider integration.
#### Advanced Path: Enterprise AI Architect (180-220 hours)
Design and deploy complex multi-agent systems. Learn scalable architectures,
security best practices, and industry-specific solutions.
""")
# Agent Builder Tab
with gr.TabItem("🔧 Agent Builder"):
gr.Markdown("""
### Build Your Custom AI Agent
Use our code generator to create a starting template for your AI agent.
In the full course, you'll learn to build and deploy these agents with real AI models.
""")
with gr.Row():
with gr.Column():
agent_type = gr.Dropdown(
label="Agent Type",
choices=["customer_service", "data_analyst", "content_creator"],
value="customer_service"
)
use_case = gr.Textbox(
label="Specific Use Case",
placeholder="E.g., E-commerce support, Financial analysis, Blog writing"
)
model_choice = gr.Dropdown(
label="AI Model",
choices=["gpt-4", "gpt-3.5-turbo", "claude-3-opus", "gemini-pro"],
value="gpt-4"
)
include_memory = gr.Checkbox(label="Include Memory System", value=True)
include_tools = gr.Checkbox(label="Include External Tools", value=True)
generate_btn = gr.Button("Generate Agent Code", variant="primary")
with gr.Column():
code_output = gr.Code(label="Generated Agent Code", language="python")
generate_btn.click(
generate_agent_code,
inputs=[agent_type, use_case, model_choice, include_memory, include_tools],
outputs=code_output
)
# Interactive Demo Tab
with gr.TabItem("🤖 Try an Agent"):
gr.Markdown("""
### Interactive Agent Demo
Experience what AI agents can do. This is a simulation - in the course,
you'll build real agents that connect to actual AI models.
""")
with gr.Row():
with gr.Column():
demo_agent_type = gr.Radio(
label="Select Agent Type",
choices=["customer_service", "data_analyst", "content_creator"],
value="customer_service"
)
user_input = gr.Textbox(
label="Your Message",
placeholder="Type your message to the agent...",
lines=3
)
send_btn = gr.Button("Send Message", variant="primary")
with gr.Column():
agent_response = gr.Markdown(label="Agent Response")
send_btn.click(
simulate_agent_conversation,
inputs=[demo_agent_type, user_input],
outputs=agent_response
)
# Resources Tab
with gr.TabItem("📖 Resources"):
gr.Markdown("""
### 🎯 Free Resources to Get Started
#### 📺 Video Tutorials
- [Introduction to AI Agents](https://youtube.com/agenticai) (30 min)
- [Your First Prompt Engineering](https://youtube.com/agenticai) (45 min)
- [Building with No-Code Tools](https://youtube.com/agenticai) (60 min)
#### 📄 Documentation
- [AI Agent Fundamentals Guide](https://docs.agenticai.academy)
- [Prompt Engineering Best Practices](https://docs.agenticai.academy/prompts)
- [API Integration Handbook](https://docs.agenticai.academy/apis)
#### 💬 Community
- [Discord Server](https://discord.gg/agenticai) - 5,000+ members
- [GitHub Repository](https://github.com/agenticai-academy)
- [LinkedIn Group](https://linkedin.com/groups/agenticai)
#### 🏆 Success Stories
- **Sarah M.**: Marketing Manager → AI Consultant ($150K → $225K)
- **James L.**: Developer → AI Agency Owner ($30K/month revenue)
- **Tech Corp**: Trained 50 developers, saved $2M through automation
#### 🎓 Certifications
1. **Certified AI Agent Practitioner** - Entry level certification
2. **Certified AI Agent Developer** - Professional certification
3. **Certified Enterprise AI Architect** - Advanced certification
#### 💰 Pricing
- **Starter**: $35/month - Core curriculum access
- **Professional**: $60/month - Full features + certification
- **Enterprise**: Custom pricing - Team features + support
### 📞 Contact
- Email: [email protected]
- Schedule Demo: [Book a Call](https://calendly.com/agenticai)
""")
# Launch the app
if __name__ == "__main__":
app.launch()