feat(demo): 初始化审核智能体演示基线
This commit is contained in:
44
review_agent/models.py
Normal file
44
review_agent/models.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Conversation(models.Model):
|
||||
"""Stores a user's review-agent conversation shell."""
|
||||
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="review_conversations",
|
||||
)
|
||||
title = models.CharField(max_length=120, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-updated_at", "-id"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.title or f"对话 {self.pk}"
|
||||
|
||||
|
||||
class Message(models.Model):
|
||||
"""Stores one user or assistant message in a conversation."""
|
||||
|
||||
class Role(models.TextChoices):
|
||||
USER = "user", "用户"
|
||||
ASSISTANT = "assistant", "助手"
|
||||
|
||||
conversation = models.ForeignKey(
|
||||
Conversation,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="messages",
|
||||
)
|
||||
role = models.CharField(max_length=20, choices=Role.choices)
|
||||
content = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["created_at", "id"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.get_role_display()} - {self.conversation_id}"
|
||||
Reference in New Issue
Block a user