mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 08:52:58 +00:00
✨ Add Lean Six Sigma Expert agent with Railway integration
- Add Business Consulting category to Railway config - Create System 2 direct access agent with JotForm integration - Add dedicated template with full-screen iframe layout - Implement view functions for payment processing and form display - Update marketplace template with special Try Now routing - Add URL routes for agent access and display pages - Create JSON config for Railway deployment compatibility - Ensure identical database state between local and production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
62f3dd2592
commit
2aea35f2d9
16
agents/configs/agents/lean-six-sigma-expert.json
Normal file
16
agents/configs/agents/lean-six-sigma-expert.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"slug": "lean-six-sigma-expert",
|
||||
"name": "Lean Six Sigma Expert",
|
||||
"short_description": "Get expert guidance on Lean Six Sigma methodologies and process improvement strategies",
|
||||
"description": "Optimize your business processes with expert Lean Six Sigma consultation. Our AI-powered expert provides comprehensive guidance on process improvement, waste reduction, quality enhancement, and operational excellence. Get personalized recommendations for implementing Lean Six Sigma methodologies in your organization.",
|
||||
"category": "consulting",
|
||||
"price": 0.0,
|
||||
"agent_type": "form",
|
||||
"system_type": "direct_access",
|
||||
"form_schema": {
|
||||
"fields": []
|
||||
},
|
||||
"webhook_url": "https://agent.jotform.com/01987b8843ae71129342f62a93d2c605efad",
|
||||
"access_url_name": "agents:direct_access_handler",
|
||||
"display_url_name": "agents:direct_access_display"
|
||||
}
|
||||
@ -28,5 +28,11 @@
|
||||
"name": "Marketing & Advertising",
|
||||
"description": "AI-powered marketing tools and advertising solutions",
|
||||
"icon": "📢"
|
||||
},
|
||||
{
|
||||
"slug": "consulting",
|
||||
"name": "Business Consulting",
|
||||
"description": "Professional business consultation and strategy services",
|
||||
"icon": "💼"
|
||||
}
|
||||
]
|
||||
60
agents/management/commands/create_lean_six_sigma_agent.py
Normal file
60
agents/management/commands/create_lean_six_sigma_agent.py
Normal file
@ -0,0 +1,60 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from agents.models import AgentCategory, Agent
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Create Lean Six Sigma Expert agent with JotForm integration'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Create Business Consulting category
|
||||
consulting_category, created = AgentCategory.objects.get_or_create(
|
||||
slug='consulting',
|
||||
defaults={
|
||||
'name': 'Business Consulting',
|
||||
'description': 'Professional business consultation and strategy services',
|
||||
'icon': '💼'
|
||||
}
|
||||
)
|
||||
|
||||
if created:
|
||||
self.stdout.write(self.style.SUCCESS(f'Created category: {consulting_category.name}'))
|
||||
else:
|
||||
self.stdout.write(f'Category already exists: {consulting_category.name}')
|
||||
|
||||
# Create Lean Six Sigma Expert agent
|
||||
lean_six_sigma_agent, created = Agent.objects.get_or_create(
|
||||
slug='lean-six-sigma-expert',
|
||||
defaults={
|
||||
'name': 'Lean Six Sigma Expert',
|
||||
'short_description': 'Get expert guidance on Lean Six Sigma methodologies and process improvement strategies',
|
||||
'description': 'Optimize your business processes with expert Lean Six Sigma consultation. Our AI-powered expert provides comprehensive guidance on process improvement, waste reduction, quality enhancement, and operational excellence. Get personalized recommendations for implementing Lean Six Sigma methodologies in your organization.',
|
||||
'category': consulting_category,
|
||||
'price': 0.0,
|
||||
'agent_type': 'form',
|
||||
'form_schema': {
|
||||
'fields': [] # Empty since we're using JotForm directly
|
||||
},
|
||||
'webhook_url': 'https://agent.jotform.com/01987b8843ae71129342f62a93d2c605efad',
|
||||
'access_url_name': 'agents:direct_access_handler',
|
||||
'display_url_name': 'agents:direct_access_display'
|
||||
}
|
||||
)
|
||||
|
||||
if created:
|
||||
self.stdout.write(self.style.SUCCESS(f'Created agent: {lean_six_sigma_agent.name}'))
|
||||
self.stdout.write(f' 📝 Description: {lean_six_sigma_agent.short_description}')
|
||||
self.stdout.write(f' 💰 Price: {lean_six_sigma_agent.price} AED')
|
||||
self.stdout.write(f' 🔗 JotForm URL: {lean_six_sigma_agent.webhook_url}')
|
||||
self.stdout.write(f' 📂 Category: {lean_six_sigma_agent.category.name}')
|
||||
else:
|
||||
self.stdout.write(f'Agent already exists: {lean_six_sigma_agent.name}')
|
||||
|
||||
self.stdout.write('')
|
||||
self.stdout.write(self.style.SUCCESS('✅ Lean Six Sigma Expert setup completed successfully'))
|
||||
self.stdout.write('')
|
||||
self.stdout.write('🚀 Next steps:')
|
||||
self.stdout.write(' 1. Agent will appear in the Business Consulting category')
|
||||
self.stdout.write(' 2. Users get free access to JotForm Lean Six Sigma consultation')
|
||||
self.stdout.write(' 3. Visit /agents/lean-six-sigma-expert/ to test the interface')
|
||||
self.stdout.write('')
|
||||
self.stdout.write(f'Agent ID: {lean_six_sigma_agent.id}')
|
||||
self.stdout.write(f'Agent Slug: {lean_six_sigma_agent.slug}')
|
||||
@ -82,6 +82,10 @@
|
||||
<a href="{% url 'agents:ai_brand_strategist_access' %}" class="try-btn">
|
||||
Try Now →
|
||||
</a>
|
||||
{% elif agent.slug == 'lean-six-sigma-expert' %}
|
||||
<a href="{% url 'agents:lean_six_sigma_expert_access' %}" class="try-btn">
|
||||
Try Now →
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'agents:detail' agent.slug %}" class="try-btn">Try Now →</a>
|
||||
{% endif %}
|
||||
@ -94,6 +98,10 @@
|
||||
<a href="{% url 'authentication:login' %}?next={% url 'agents:ai_brand_strategist_access' %}" class="try-btn login-required" style="width: 100%;">
|
||||
🔐 Login to Try
|
||||
</a>
|
||||
{% elif agent.slug == 'lean-six-sigma-expert' %}
|
||||
<a href="{% url 'authentication:login' %}?next={% url 'agents:lean_six_sigma_expert_access' %}" class="try-btn login-required" style="width: 100%;">
|
||||
🔐 Login to Try
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'authentication:login' %}?next={% url 'agents:detail' agent.slug %}" class="try-btn login-required" style="width: 100%;">
|
||||
🔐 Login to Try
|
||||
|
||||
@ -12,6 +12,8 @@ urlpatterns = [
|
||||
path('career-navigator/access/', views.career_navigator_access, name='career_navigator_access'),
|
||||
path('ai-brand-strategist/', views.ai_brand_strategist_view, name='ai_brand_strategist'),
|
||||
path('ai-brand-strategist/access/', views.ai_brand_strategist_access, name='ai_brand_strategist_access'),
|
||||
path('lean-six-sigma-expert/', views.lean_six_sigma_expert_view, name='lean_six_sigma_expert'),
|
||||
path('lean-six-sigma-expert/access/', views.lean_six_sigma_expert_access, name='lean_six_sigma_expert_access'),
|
||||
|
||||
# API endpoints - specific URLs first to avoid slug conflicts
|
||||
path('api/execute/', views.execute_agent, name='execute_agent'),
|
||||
|
||||
@ -1147,3 +1147,99 @@ def direct_access_display(request, slug):
|
||||
# For now, redirect directly to external form
|
||||
# Future: Can render iframe template or custom display logic
|
||||
return redirect(agent.webhook_url)
|
||||
|
||||
|
||||
def lean_six_sigma_expert_view(request):
|
||||
"""Display the Lean Six Sigma Expert form page"""
|
||||
if not request.user.is_authenticated:
|
||||
# Clear all existing messages before adding login message
|
||||
storage = messages.get_messages(request)
|
||||
for _ in storage:
|
||||
pass # Consume all messages
|
||||
# Add login message to session for after login redirect
|
||||
request.session['post_login_message'] = 'Please complete your login to access the Lean Six Sigma Expert.'
|
||||
return redirect('authentication:login')
|
||||
|
||||
# Get the Lean Six Sigma Expert agent
|
||||
try:
|
||||
agent = Agent.objects.get(slug='lean-six-sigma-expert', is_active=True)
|
||||
except Agent.DoesNotExist:
|
||||
messages.error(request, 'Lean Six Sigma Expert is currently unavailable.')
|
||||
return redirect('agents:marketplace')
|
||||
|
||||
# Check if user has a recent execution (within last 2 hours) or just redirect to payment
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
|
||||
recent_execution = AgentExecution.objects.filter(
|
||||
agent=agent,
|
||||
user=request.user,
|
||||
status='completed',
|
||||
created_at__gte=timezone.now() - timedelta(hours=2)
|
||||
).first()
|
||||
|
||||
if not recent_execution:
|
||||
messages.info(request, 'Please click "Try Now" to access your Lean Six Sigma Expert consultation.')
|
||||
return redirect('agents:marketplace')
|
||||
|
||||
context = {
|
||||
'agent': agent,
|
||||
'form_url': agent.webhook_url,
|
||||
'user_balance': request.user.wallet_balance,
|
||||
'execution': recent_execution
|
||||
}
|
||||
|
||||
return render(request, 'lean_six_sigma_expert.html', context)
|
||||
|
||||
|
||||
def lean_six_sigma_expert_access(request):
|
||||
"""Handle Try Now button click - charge wallet and redirect to form"""
|
||||
if not request.user.is_authenticated:
|
||||
# Clear all existing messages before adding login message
|
||||
storage = messages.get_messages(request)
|
||||
for _ in storage:
|
||||
pass # Consume all messages
|
||||
# Add login message to session for after login redirect
|
||||
request.session['post_login_message'] = 'Please complete your login to access the Lean Six Sigma Expert.'
|
||||
return redirect('authentication:login')
|
||||
|
||||
# Get the Lean Six Sigma Expert agent
|
||||
try:
|
||||
agent = Agent.objects.get(slug='lean-six-sigma-expert', is_active=True)
|
||||
except Agent.DoesNotExist:
|
||||
messages.error(request, 'Lean Six Sigma Expert is currently unavailable.')
|
||||
return redirect('agents:marketplace')
|
||||
|
||||
# Check if user has sufficient balance
|
||||
if not request.user.has_sufficient_balance(agent.price):
|
||||
messages.error(request, f'Insufficient balance! You need {agent.price} AED to access the Lean Six Sigma Expert.')
|
||||
return redirect('wallet:wallet')
|
||||
|
||||
# Deduct fee from user wallet
|
||||
success = request.user.deduct_balance(
|
||||
agent.price,
|
||||
f'{agent.name} - Direct Access',
|
||||
agent.slug
|
||||
)
|
||||
|
||||
if not success:
|
||||
messages.error(request, 'Failed to process payment. Please try again.')
|
||||
return redirect('agents:marketplace')
|
||||
|
||||
# Create execution record for tracking
|
||||
execution = AgentExecution.objects.create(
|
||||
agent=agent,
|
||||
user=request.user,
|
||||
input_data={'action': 'direct_access', 'source': 'try_now_button'},
|
||||
fee_charged=agent.price,
|
||||
status='completed',
|
||||
output_data={
|
||||
'type': 'direct_access',
|
||||
'message': f'Direct access granted to {agent.name}',
|
||||
'access_method': 'try_now_button'
|
||||
},
|
||||
completed_at=timezone.now()
|
||||
)
|
||||
|
||||
# Redirect directly to form - no message needed
|
||||
return redirect('agents:lean_six_sigma_expert')
|
||||
|
||||
43
templates/lean_six_sigma_expert.html
Normal file
43
templates/lean_six_sigma_expert.html
Normal file
@ -0,0 +1,43 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Lean Six Sigma Expert - Quantum Tasks AI{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
/* Override main-container for full-width iframe */
|
||||
.main-container {
|
||||
max-width: none;
|
||||
padding: 0;
|
||||
height: calc(100vh - 80px); /* Account for header height */
|
||||
}
|
||||
|
||||
.iframe-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.iframe-container iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Hide footer for this page */
|
||||
.footer {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="iframe-container">
|
||||
<iframe
|
||||
src="{{ form_url }}"
|
||||
frameborder="0"
|
||||
scrolling="auto"
|
||||
title="Lean Six Sigma Expert">
|
||||
</iframe>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
Reference in New Issue
Block a user