from __future__ import annotations

from sqlalchemy import BigInteger, String, Text
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Mapped, mapped_column

from fastapi_common.fastapi_common_web.models import BaseModel


class LeauditRagMessage(BaseModel):
    __tablename__ = "rag_message"

    Id: Mapped[int] = mapped_column("id", BigInteger, primary_key=True, autoincrement=True)
    messageId: Mapped[str] = mapped_column("message_id", String(100), unique=True)
    conversationId: Mapped[str] = mapped_column("conversation_id", String(100))
    role: Mapped[str] = mapped_column(String(20))
    content: Mapped[str] = mapped_column(Text, default="")
    sources: Mapped[list] = mapped_column(JSONB, default=list)
    metadataJson: Mapped[dict] = mapped_column("metadata", JSONB, default=dict)
    feedback: Mapped[str | None] = mapped_column(String(20))
