Spaces:
Running

File size: 827 Bytes
e023141
 
 
 
 
1f68699
 
 
 
 
e023141
 
1f68699
e023141
 
 
 
1f68699
e023141
 
 
1f68699
82abf63
 
1f68699
 
 
 
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
"""
Nova Help Chat - Database Model
Stores chat history per tenant for the Nova AI helper
"""

from sqlmodel import SQLModel, Field
from typing import Optional
from datetime import datetime
from uuid import UUID, uuid4
from enum import Enum


class NovaMessageRole(str, Enum):
    USER = "user"
    NOVA = "nova"


class NovaMessage(SQLModel, table=True):
    """Stores Nova help chat messages per tenant."""
    __tablename__ = "nova_messages"

    id: UUID = Field(default_factory=uuid4, primary_key=True)
    tenant_id: UUID = Field(foreign_key="tenants.id", index=True)
    user_id: Optional[UUID] = Field(default=None, foreign_key="users.id")
    role: NovaMessageRole
    content: str
    current_page: Optional[str] = Field(default=None, max_length=255)
    created_at: datetime = Field(default_factory=datetime.utcnow)