Files
DEMO-AGENT/apps/audit/models.py

41 lines
1.5 KiB
Python

from django.db import models
class AgentAuditLog(models.Model):
STATUS_SUCCESS = "success"
STATUS_FAILED = "failed"
scenario_id = models.CharField(max_length=100, db_index=True)
scenario_name = models.CharField(max_length=200, blank=True)
user_input = models.TextField()
retrieved_chunks = models.JSONField(default=list, blank=True)
tool_calls = models.JSONField(default=list, blank=True)
structured_output = models.JSONField(default=dict, blank=True)
final_answer = models.TextField(blank=True)
raw_output = models.TextField(blank=True)
model_name = models.CharField(max_length=100, blank=True)
latency_ms = models.PositiveIntegerField(default=0)
status = models.CharField(max_length=20, default=STATUS_SUCCESS, db_index=True)
error_message = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
class Meta:
ordering = ["-created_at"]
def __str__(self) -> str:
return f"{self.scenario_name or self.scenario_id} #{self.pk}"
class DemoBusinessRecord(models.Model):
scenario_id = models.CharField(max_length=100, db_index=True)
record_type = models.CharField(max_length=100, db_index=True)
title = models.CharField(max_length=255)
payload = models.JSONField(default=dict, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ["-created_at"]
def __str__(self) -> str:
return self.title