File size: 1,897 Bytes
7f2cf0c
 
12d0925
 
 
 
 
 
 
 
 
 
 
61b3ce7
12d0925
 
 
7f2cf0c
 
12d0925
7f2cf0c
12d0925
7f2cf0c
 
 
 
 
 
 
 
 
 
61b3ce7
7f2cf0c
 
12d0925
7f2cf0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django.contrib.auth.models import User

class UserProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
    global_bio = models.TextField(default='A friendly tutor')
    global_language = models.CharField(max_length=100, default='English')
    global_mcp_tools = ArrayField(
        models.CharField(max_length=200), 
        default=list, 
        blank=True
    )
    global_timer = models.IntegerField(default=10) # in seconds
    
    def __str__(self):
        return f"Profile of {self.user.username}"

class ChatSession(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='chats')
    chat_name = models.CharField(max_length=255, default='Nuova Chat')

    language = models.CharField(max_length=100, default='English')
    character_bio = models.TextField(default='A friendly tutor')
    summary = models.TextField(blank=True, null=True)
    mcp_tools = ArrayField(
        models.CharField(max_length=200), 
        default=list, 
        blank=True
    )
    telegram_thread_id = models.BigIntegerField(null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    reply_timer = models.IntegerField(default=10) # in seconds

    def __str__(self):
        return f"{self.chat_name} ({self.user.username})"

    class Meta:
        db_table = 'chat_sessions'

class PendingMessage(models.Model):
    chat = models.ForeignKey(ChatSession, on_delete=models.CASCADE, related_name='messages')
    content = models.TextField()
    is_user = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{'User' if self.is_user else 'AI'} on {self.chat.chat_name}"

    class Meta:
        db_table = 'pending_messages'