This commit is contained in:
2026-04-02 23:25:39 +03:30
parent 881f8efa4d
commit bd0d04256c
84 changed files with 2725 additions and 856 deletions
+16
View File
@@ -3,6 +3,8 @@ import uuid
from django.conf import settings
from django.db import models
from farm_hub.models import FarmHub
class Conversation(models.Model):
uuid = models.UUIDField(default=uuid.uuid4, unique=True, editable=False, db_index=True)
@@ -11,6 +13,13 @@ class Conversation(models.Model):
on_delete=models.CASCADE,
related_name="farm_ai_conversations",
)
farm = models.ForeignKey(
FarmHub,
on_delete=models.CASCADE,
related_name="ai_conversations",
null=True,
blank=True,
)
title = models.CharField(max_length=255, blank=True, default="")
farm_context = models.JSONField(default=dict, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
@@ -38,6 +47,13 @@ class Message(models.Model):
on_delete=models.CASCADE,
related_name="messages",
)
farm = models.ForeignKey(
FarmHub,
on_delete=models.CASCADE,
related_name="ai_messages",
null=True,
blank=True,
)
role = models.CharField(max_length=32, choices=ROLE_CHOICES)
content = models.TextField(blank=True, default="")
images = models.JSONField(default=list, blank=True)