feat(audit): 增加审计日志与演示数据管理
This commit is contained in:
40
apps/audit/models.py
Normal file
40
apps/audit/models.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
Reference in New Issue
Block a user