diff --git a/agents/__init__.py b/agents/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/agents/admin.py b/agents/admin.py new file mode 100644 index 0000000..e14c94e --- /dev/null +++ b/agents/admin.py @@ -0,0 +1,112 @@ +from django.contrib import admin +from django.utils.html import format_html +from .models import AgentCategory, Agent, AgentExecution + + +@admin.register(AgentCategory) +class AgentCategoryAdmin(admin.ModelAdmin): + list_display = ('name', 'slug', 'agent_count', 'is_active', 'sort_order', 'created_at') + list_filter = ('is_active', 'created_at') + search_fields = ('name', 'description') + prepopulated_fields = {'slug': ('name',)} + ordering = ('sort_order', 'name') + + def agent_count(self, obj): + return obj.agents.filter(is_active=True).count() + agent_count.short_description = 'Active Agents' + + +@admin.register(Agent) +class AgentAdmin(admin.ModelAdmin): + list_display = ('name', 'category', 'price', 'usage_count', 'is_active', 'is_featured', 'created_at') + list_filter = ('category', 'is_active', 'is_featured', 'created_at') + search_fields = ('name', 'description', 'short_description') + prepopulated_fields = {'slug': ('name',)} + ordering = ('-is_featured', '-usage_count', 'name') + + fieldsets = ( + ('Basic Information', { + 'fields': ('name', 'slug', 'category', 'price', 'icon') + }), + ('Descriptions', { + 'fields': ('short_description', 'description') + }), + ('Form Configuration', { + 'fields': ('form_schema',), + 'classes': ('collapse',), + 'description': 'JSON schema defining the form fields for this agent' + }), + ('n8n Integration', { + 'fields': ('n8n_webhook_url', 'result_format'), + 'classes': ('collapse',) + }), + ('Status & Settings', { + 'fields': ('is_active', 'is_featured') + }), + ('Statistics', { + 'fields': ('usage_count',), + 'classes': ('collapse',) + }) + ) + + readonly_fields = ('usage_count',) + + def get_form(self, request, obj=None, **kwargs): + form = super().get_form(request, obj, **kwargs) + # Add help text for form_schema field + if 'form_schema' in form.base_fields: + form.base_fields['form_schema'].help_text = format_html(''' +
JSON schema example:
+{
+ "fields": [
+ {
+ "name": "description",
+ "type": "textarea",
+ "label": "Content Description",
+ "required": true,
+ "placeholder": "Describe what you want to generate..."
+ },
+ {
+ "name": "language",
+ "type": "select",
+ "label": "Language",
+ "options": ["English", "Arabic"],
+ "required": true
+ }
+ ]
+}
+ ''')
+ return form
+
+
+@admin.register(AgentExecution)
+class AgentExecutionAdmin(admin.ModelAdmin):
+ list_display = ('user', 'agent', 'status', 'price_paid', 'created_at', 'completed_at')
+ list_filter = ('status', 'agent', 'created_at')
+ search_fields = ('user__email', 'agent__name')
+ ordering = ('-created_at',)
+
+ fieldsets = (
+ ('Execution Info', {
+ 'fields': ('user', 'agent', 'status', 'price_paid')
+ }),
+ ('Input Data', {
+ 'fields': ('input_data',),
+ 'classes': ('collapse',)
+ }),
+ ('Output Data', {
+ 'fields': ('output_data', 'error_message'),
+ 'classes': ('collapse',)
+ }),
+ ('Timestamps', {
+ 'fields': ('created_at', 'updated_at', 'completed_at'),
+ 'classes': ('collapse',)
+ })
+ )
+
+ readonly_fields = ('created_at', 'updated_at')
+
+ def get_readonly_fields(self, request, obj=None):
+ if obj: # Editing existing object
+ return self.readonly_fields + ('user', 'agent', 'price_paid')
+ return self.readonly_fields
diff --git a/agents/apps.py b/agents/apps.py
new file mode 100644
index 0000000..49cb5b7
--- /dev/null
+++ b/agents/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class AgentsConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'agents'
diff --git a/agents/management/__init__.py b/agents/management/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/agents/management/commands/__init__.py b/agents/management/commands/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/agents/management/commands/create_sample_agents.py b/agents/management/commands/create_sample_agents.py
new file mode 100644
index 0000000..359ae34
--- /dev/null
+++ b/agents/management/commands/create_sample_agents.py
@@ -0,0 +1,373 @@
+from django.core.management.base import BaseCommand
+from agents.models import AgentCategory, Agent
+
+
+class Command(BaseCommand):
+ help = 'Create sample agents for testing the marketplace'
+
+ def handle(self, *args, **options):
+ self.stdout.write('Creating sample agents...')
+
+ # Create categories
+ categories_data = [
+ {
+ 'name': 'Content Creation',
+ 'slug': 'content-creation',
+ 'description': 'AI agents for creating various types of content',
+ 'icon': 'βοΈ'
+ },
+ {
+ 'name': 'Business & Marketing',
+ 'slug': 'business-marketing',
+ 'description': 'AI agents for business and marketing tasks',
+ 'icon': 'π'
+ },
+ {
+ 'name': 'Data & Analytics',
+ 'slug': 'data-analytics',
+ 'description': 'AI agents for data analysis and insights',
+ 'icon': 'π'
+ },
+ {
+ 'name': 'HR & Recruitment',
+ 'slug': 'hr-recruitment',
+ 'description': 'AI agents for human resources and recruitment',
+ 'icon': 'π₯'
+ }
+ ]
+
+ categories = {}
+ for cat_data in categories_data:
+ category, created = AgentCategory.objects.get_or_create(
+ slug=cat_data['slug'],
+ defaults=cat_data
+ )
+ categories[cat_data['slug']] = category
+ if created:
+ self.stdout.write(f'Created category: {category.name}')
+
+ # Create sample agents
+ agents_data = [
+ {
+ 'name': 'Professional Job Posting Creator',
+ 'slug': 'job-posting-creator',
+ 'short_description': 'Create professional, attractive job postings that attract top talent',
+ 'description': 'This AI agent helps you craft compelling job postings that stand out in the competitive talent market. It analyzes your requirements and creates comprehensive job descriptions with proper formatting, compelling language, and industry best practices.',
+ 'category': categories['hr-recruitment'],
+ 'price': 25.00,
+ 'icon': 'πΌ',
+ 'is_featured': True,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/job-posting-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'position_title',
+ 'label': 'Position Title',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Senior Full Stack Developer'
+ },
+ {
+ 'name': 'company_name',
+ 'label': 'Company Name',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Quantum Technologies Inc.'
+ },
+ {
+ 'name': 'job_description',
+ 'label': 'Job Description',
+ 'type': 'textarea',
+ 'required': True,
+ 'placeholder': 'Describe the role, responsibilities, and requirements...'
+ },
+ {
+ 'name': 'seniority_level',
+ 'label': 'Seniority Level',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Entry Level', 'Mid Level', 'Senior', 'Executive']
+ },
+ {
+ 'name': 'contract_type',
+ 'label': 'Contract Type',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Full-time', 'Part-time', 'Contract', 'Internship', 'Freelance']
+ },
+ {
+ 'name': 'location',
+ 'label': 'Location',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Dubai, UAE (Remote)'
+ },
+ {
+ 'name': 'language',
+ 'label': 'Language',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['English', 'Arabic', 'Spanish', 'French', 'German']
+ }
+ ]
+ }
+ },
+ {
+ 'name': 'Social Media Ad Creator',
+ 'slug': 'social-media-ad-creator',
+ 'short_description': 'Generate compelling social media advertisements for multiple platforms',
+ 'description': 'Transform your product or service into engaging social media advertisements. This agent creates platform-specific ad copy, suggests visuals, and optimizes for maximum engagement and conversions across Facebook, Instagram, LinkedIn, and Twitter.',
+ 'category': categories['business-marketing'],
+ 'price': 35.00,
+ 'icon': 'π±',
+ 'is_featured': True,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/social-ads-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'product_service',
+ 'label': 'Product/Service Name',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Premium Fitness App'
+ },
+ {
+ 'name': 'target_audience',
+ 'label': 'Target Audience',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Fitness enthusiasts aged 25-40'
+ },
+ {
+ 'name': 'key_benefits',
+ 'label': 'Key Benefits/Features',
+ 'type': 'textarea',
+ 'required': True,
+ 'placeholder': 'List the main benefits and features...'
+ },
+ {
+ 'name': 'platform',
+ 'label': 'Social Media Platform',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Facebook', 'Instagram', 'LinkedIn', 'Twitter', 'TikTok', 'All Platforms']
+ },
+ {
+ 'name': 'ad_objective',
+ 'label': 'Campaign Objective',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Brand Awareness', 'Lead Generation', 'Sales/Conversions', 'Traffic', 'Engagement']
+ }
+ ]
+ }
+ },
+ {
+ 'name': 'Business Data Analyzer',
+ 'slug': 'business-data-analyzer',
+ 'short_description': 'Analyze business data and generate actionable insights with visualizations',
+ 'description': 'Upload your business data and get comprehensive analysis with actionable insights. This agent processes various data formats, identifies trends, creates visualizations, and provides strategic recommendations to improve your business performance.',
+ 'category': categories['data-analytics'],
+ 'price': 45.00,
+ 'icon': 'π',
+ 'is_featured': False,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/data-analyzer-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'data_type',
+ 'label': 'Data Type',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Sales Data', 'Customer Data', 'Financial Data', 'Marketing Data', 'Operational Data']
+ },
+ {
+ 'name': 'data_description',
+ 'label': 'Data Description',
+ 'type': 'textarea',
+ 'required': True,
+ 'placeholder': 'Describe your data and what insights you are looking for...'
+ },
+ {
+ 'name': 'time_period',
+ 'label': 'Time Period',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Last Month', 'Last Quarter', 'Last 6 Months', 'Last Year', 'Custom Range']
+ },
+ {
+ 'name': 'analysis_focus',
+ 'label': 'Analysis Focus',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Trends & Patterns', 'Performance Metrics', 'Comparative Analysis', 'Predictive Insights', 'All Areas']
+ }
+ ]
+ }
+ },
+ {
+ 'name': 'Blog Content Generator',
+ 'slug': 'blog-content-generator',
+ 'short_description': 'Create SEO-optimized blog posts and articles on any topic',
+ 'description': 'Generate high-quality, SEO-optimized blog content that engages your audience and drives traffic. This agent researches topics, creates outlines, writes compelling content, and suggests relevant keywords and meta descriptions.',
+ 'category': categories['content-creation'],
+ 'price': 30.00,
+ 'icon': 'π',
+ 'is_featured': False,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/blog-generator-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'topic',
+ 'label': 'Blog Topic',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Future of Artificial Intelligence in Healthcare'
+ },
+ {
+ 'name': 'target_keywords',
+ 'label': 'Target Keywords',
+ 'type': 'text',
+ 'required': False,
+ 'placeholder': 'e.g., AI healthcare, medical AI, healthcare technology'
+ },
+ {
+ 'name': 'word_count',
+ 'label': 'Target Word Count',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['500-800 words', '800-1200 words', '1200-1800 words', '1800+ words']
+ },
+ {
+ 'name': 'tone',
+ 'label': 'Writing Tone',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Professional', 'Conversational', 'Academic', 'Casual', 'Technical']
+ },
+ {
+ 'name': 'audience',
+ 'label': 'Target Audience',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'e.g., Healthcare professionals, Tech enthusiasts, General readers'
+ }
+ ]
+ }
+ },
+ {
+ 'name': 'Email Marketing Campaign Creator',
+ 'slug': 'email-campaign-creator',
+ 'short_description': 'Design and write effective email marketing campaigns that convert',
+ 'description': 'Create compelling email marketing campaigns that drive engagement and conversions. This agent designs email sequences, writes persuasive copy, suggests subject lines, and optimizes for deliverability and click-through rates.',
+ 'category': categories['business-marketing'],
+ 'price': 40.00,
+ 'icon': 'π§',
+ 'is_featured': False,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/email-campaign-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'campaign_goal',
+ 'label': 'Campaign Goal',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Product Launch', 'Lead Nurturing', 'Customer Retention', 'Sales Promotion', 'Event Promotion']
+ },
+ {
+ 'name': 'product_service',
+ 'label': 'Product/Service',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'What are you promoting?'
+ },
+ {
+ 'name': 'target_audience',
+ 'label': 'Target Audience',
+ 'type': 'text',
+ 'required': True,
+ 'placeholder': 'Describe your email subscribers/target audience'
+ },
+ {
+ 'name': 'email_count',
+ 'label': 'Number of Emails',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Single Email', '3-Email Series', '5-Email Series', '7-Email Series']
+ },
+ {
+ 'name': 'brand_voice',
+ 'label': 'Brand Voice',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Professional', 'Friendly', 'Authoritative', 'Playful', 'Luxury']
+ }
+ ]
+ }
+ },
+ {
+ 'name': 'Resume & CV Optimizer',
+ 'slug': 'resume-cv-optimizer',
+ 'short_description': 'Optimize resumes and CVs for specific job applications and ATS systems',
+ 'description': 'Transform your resume into a powerful job-winning tool. This agent analyzes job descriptions, optimizes your resume for ATS systems, suggests improvements, and tailors content to match specific positions and industries.',
+ 'category': categories['hr-recruitment'],
+ 'price': 20.00,
+ 'icon': 'π',
+ 'is_featured': False,
+ 'n8n_webhook_url': 'http://localhost:5678/webhook/resume-optimizer-webhook',
+ 'form_schema': {
+ 'fields': [
+ {
+ 'name': 'current_resume',
+ 'label': 'Current Resume Content',
+ 'type': 'textarea',
+ 'required': True,
+ 'placeholder': 'Paste your current resume content here...'
+ },
+ {
+ 'name': 'job_description',
+ 'label': 'Target Job Description',
+ 'type': 'textarea',
+ 'required': True,
+ 'placeholder': 'Paste the job description you are applying for...'
+ },
+ {
+ 'name': 'industry',
+ 'label': 'Industry',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Technology', 'Finance', 'Healthcare', 'Marketing', 'Sales', 'Education', 'Engineering', 'Other']
+ },
+ {
+ 'name': 'experience_level',
+ 'label': 'Experience Level',
+ 'type': 'select',
+ 'required': True,
+ 'options': ['Entry Level (0-2 years)', 'Mid Level (3-5 years)', 'Senior (6-10 years)', 'Executive (10+ years)']
+ }
+ ]
+ }
+ }
+ ]
+
+ # Create agents
+ for agent_data in agents_data:
+ agent, created = Agent.objects.get_or_create(
+ slug=agent_data['slug'],
+ defaults=agent_data
+ )
+ if created:
+ self.stdout.write(f'Created agent: {agent.name}')
+ else:
+ # Update existing agent with new data
+ for key, value in agent_data.items():
+ if key != 'slug':
+ setattr(agent, key, value)
+ agent.save()
+ self.stdout.write(f'Updated agent: {agent.name}')
+
+ self.stdout.write(
+ self.style.SUCCESS(
+ f'Successfully created/updated {len(categories_data)} categories and {len(agents_data)} agents'
+ )
+ )
\ No newline at end of file
diff --git a/agents/migrations/0001_initial.py b/agents/migrations/0001_initial.py
new file mode 100644
index 0000000..1bcedad
--- /dev/null
+++ b/agents/migrations/0001_initial.py
@@ -0,0 +1,79 @@
+# Generated by Django 5.0.8 on 2025-07-30 10:09
+
+import django.db.models.deletion
+import uuid
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='AgentCategory',
+ fields=[
+ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ('name', models.CharField(max_length=100)),
+ ('slug', models.SlugField(unique=True)),
+ ('description', models.TextField(blank=True)),
+ ('icon', models.CharField(blank=True, help_text='Icon name or emoji', max_length=50)),
+ ('is_active', models.BooleanField(default=True)),
+ ('sort_order', models.IntegerField(default=0)),
+ ('created_at', models.DateTimeField(auto_now_add=True)),
+ ('updated_at', models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ 'verbose_name_plural': 'Agent Categories',
+ 'ordering': ['sort_order', 'name'],
+ },
+ ),
+ migrations.CreateModel(
+ name='Agent',
+ fields=[
+ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ('name', models.CharField(max_length=200)),
+ ('slug', models.SlugField(unique=True)),
+ ('description', models.TextField()),
+ ('short_description', models.CharField(help_text='Brief description for cards', max_length=255)),
+ ('price', models.DecimalField(decimal_places=2, help_text='Price in AED', max_digits=10)),
+ ('icon', models.CharField(blank=True, help_text='Icon name or emoji', max_length=50)),
+ ('form_schema', models.JSONField(default=dict, help_text='JSON schema defining the form fields for this agent')),
+ ('n8n_webhook_url', models.URLField(help_text='n8n webhook URL for this agent')),
+ ('result_format', models.JSONField(blank=True, default=dict, help_text='Configuration for formatting the response from n8n')),
+ ('is_active', models.BooleanField(default=True)),
+ ('is_featured', models.BooleanField(default=False)),
+ ('usage_count', models.IntegerField(default=0)),
+ ('created_at', models.DateTimeField(auto_now_add=True)),
+ ('updated_at', models.DateTimeField(auto_now=True)),
+ ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='agents', to='agents.agentcategory')),
+ ],
+ options={
+ 'ordering': ['-is_featured', '-usage_count', 'name'],
+ },
+ ),
+ migrations.CreateModel(
+ name='AgentExecution',
+ fields=[
+ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
+ ('input_data', models.JSONField(help_text='Form data submitted by user')),
+ ('output_data', models.JSONField(blank=True, help_text='Response from n8n workflow', null=True)),
+ ('price_paid', models.DecimalField(decimal_places=2, max_digits=10)),
+ ('status', models.CharField(choices=[('pending', 'Pending'), ('processing', 'Processing'), ('success', 'Success'), ('failed', 'Failed')], default='pending', max_length=20)),
+ ('error_message', models.TextField(blank=True, null=True)),
+ ('created_at', models.DateTimeField(auto_now_add=True)),
+ ('updated_at', models.DateTimeField(auto_now=True)),
+ ('completed_at', models.DateTimeField(blank=True, null=True)),
+ ('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='executions', to='agents.agent')),
+ ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='agent_executions', to=settings.AUTH_USER_MODEL)),
+ ],
+ options={
+ 'ordering': ['-created_at'],
+ },
+ ),
+ ]
diff --git a/agents/migrations/__init__.py b/agents/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/agents/models.py b/agents/models.py
new file mode 100644
index 0000000..ae5fbab
--- /dev/null
+++ b/agents/models.py
@@ -0,0 +1,113 @@
+import uuid
+from django.db import models
+from django.conf import settings
+from django.utils.text import slugify
+from decimal import Decimal
+
+
+class AgentCategory(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
+ name = models.CharField(max_length=100)
+ slug = models.SlugField(unique=True)
+ description = models.TextField(blank=True)
+ icon = models.CharField(max_length=50, blank=True, help_text="Icon name or emoji")
+ is_active = models.BooleanField(default=True)
+ sort_order = models.IntegerField(default=0)
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
+
+ class Meta:
+ ordering = ['sort_order', 'name']
+ verbose_name_plural = 'Agent Categories'
+
+ def __str__(self):
+ return self.name
+
+ def save(self, *args, **kwargs):
+ if not self.slug:
+ self.slug = slugify(self.name)
+ super().save(*args, **kwargs)
+
+
+class Agent(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
+ name = models.CharField(max_length=200)
+ slug = models.SlugField(unique=True)
+ description = models.TextField()
+ short_description = models.CharField(max_length=255, help_text="Brief description for cards")
+ category = models.ForeignKey(AgentCategory, on_delete=models.CASCADE, related_name='agents')
+ price = models.DecimalField(max_digits=10, decimal_places=2, help_text="Price in AED")
+ icon = models.CharField(max_length=50, blank=True, help_text="Icon name or emoji")
+
+ # Dynamic form configuration
+ form_schema = models.JSONField(
+ default=dict,
+ help_text="JSON schema defining the form fields for this agent"
+ )
+
+ # n8n integration
+ n8n_webhook_url = models.URLField(help_text="n8n webhook URL for this agent")
+
+ # Response configuration
+ result_format = models.JSONField(
+ default=dict,
+ blank=True,
+ help_text="Configuration for formatting the response from n8n"
+ )
+
+ # Status and metadata
+ is_active = models.BooleanField(default=True)
+ is_featured = models.BooleanField(default=False)
+ usage_count = models.IntegerField(default=0)
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
+
+ class Meta:
+ ordering = ['-is_featured', '-usage_count', 'name']
+
+ def __str__(self):
+ return self.name
+
+ def save(self, *args, **kwargs):
+ if not self.slug:
+ self.slug = slugify(self.name)
+ super().save(*args, **kwargs)
+
+ def increment_usage(self):
+ self.usage_count += 1
+ self.save(update_fields=['usage_count'])
+
+
+class AgentExecution(models.Model):
+ STATUS_CHOICES = [
+ ('pending', 'Pending'),
+ ('processing', 'Processing'),
+ ('success', 'Success'),
+ ('failed', 'Failed'),
+ ]
+
+ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='agent_executions')
+ agent = models.ForeignKey(Agent, on_delete=models.CASCADE, related_name='executions')
+
+ # Execution data
+ input_data = models.JSONField(help_text="Form data submitted by user")
+ output_data = models.JSONField(null=True, blank=True, help_text="Response from n8n workflow")
+
+ # Billing
+ price_paid = models.DecimalField(max_digits=10, decimal_places=2)
+
+ # Status tracking
+ status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
+ error_message = models.TextField(null=True, blank=True)
+
+ # Timestamps
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
+ completed_at = models.DateTimeField(null=True, blank=True)
+
+ class Meta:
+ ordering = ['-created_at']
+
+ def __str__(self):
+ return f"{self.user.email} - {self.agent.name} - {self.status}"
diff --git a/agents/tests.py b/agents/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/agents/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/agents/urls.py b/agents/urls.py
new file mode 100644
index 0000000..c74422e
--- /dev/null
+++ b/agents/urls.py
@@ -0,0 +1,13 @@
+from django.urls import path
+from . import views
+
+urlpatterns = [
+ # Agent execution endpoints
+ path('execute/', views.execute_agent, name='execute_agent'),
+ path('executions/', views.get_agent_executions, name='agent_executions'),
+ path('executions/{{ agent.short_description }}
+Discover and use powerful AI agents to automate your tasks
+{{ agents.count }} agent{{ agents.count|pluralize }} found
+{{ agent.short_description }}
+ +Try adjusting your search criteria or browse all categories.
+ View All Agents ++ Secure, pay-per-use workflow automation platform. + Top up your wallet, trigger powerful n8n workflows, and monitor your usageβall with a sleek, minimal interface. +
+ +Sign up with your email and create a secure account in seconds.
+Add funds to your wallet using our secure Stripe integration.
+Execute powerful n8n workflows with custom data. Pay only $0.10 per execution.
+Track all your transactions and workflow executions in real-time.
+Token-based authentication with email verification and secure password handling.
+Secure payment processing with Stripe Checkout for wallet top-ups.
+Trigger powerful automation workflows with custom JSON data.
+Comprehensive logging of all transactions and workflow executions.
+Full administrative interface for monitoring users and system health.
+Clean, minimal interface that works perfectly on all devices.
+Don't have an account?
+ Create Account +Join NetCop AI Agent and start automating your workflows.
+Already have an account?
+ Sign In +Loading transactions...
++ Execute n8n workflows with custom data. Each execution costs $0.10. +
+Loading workflow history...
+