mirror of
https://github.com/thecyberlearn/quantum-ai-v2.git
synced 2026-08-18 16:32:58 +00:00
- Add is_locked field to Agent model with migration - Create stable-working-agents branch and v1.0-working tag - Export working agents and user data to backups/ - Implement freeze_agents command to lock/unlock agents - Create restore_working_state command for one-click restoration - Lock current 3 working agents (Social Ads, Job Posting, PDF Summarizer) - Add lock status to admin interface Safe house established! All working agents are now protected. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
from django.db import models
|
|
import uuid
|
|
|
|
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 class or emoji")
|
|
is_active = models.BooleanField(default=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['name']
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
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)
|
|
short_description = models.CharField(max_length=300)
|
|
description = models.TextField()
|
|
category = models.ForeignKey(AgentCategory, on_delete=models.CASCADE, related_name='agents')
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
|
form_schema = models.JSONField(help_text="JSON schema for agent input form")
|
|
webhook_url = models.URLField(help_text="n8n webhook URL for execution")
|
|
is_active = models.BooleanField(default=True)
|
|
is_locked = models.BooleanField(default=False, help_text="Lock agent to prevent modifications")
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ['name']
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class AgentExecution(models.Model):
|
|
STATUS_CHOICES = [
|
|
('pending', 'Pending'),
|
|
('running', 'Running'),
|
|
('completed', 'Completed'),
|
|
('failed', 'Failed'),
|
|
]
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
agent = models.ForeignKey(Agent, on_delete=models.CASCADE, related_name='executions')
|
|
user = models.ForeignKey('authentication.User', on_delete=models.CASCADE)
|
|
input_data = models.JSONField()
|
|
output_data = models.JSONField(null=True, blank=True)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
|
|
fee_charged = models.DecimalField(max_digits=10, decimal_places=2)
|
|
webhook_response = models.JSONField(null=True, blank=True)
|
|
error_message = models.TextField(blank=True)
|
|
execution_time = models.DurationField(null=True, blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
completed_at = models.DateTimeField(null=True, blank=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"{self.agent.name} - {self.user.email} - {self.status}"
|