forked from hesabix/arc
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from adapters.db.session import Base
|
|
|
|
|
|
class AIChatAttachment(Base):
|
|
"""پیوست متنی گفتوگو — متن استخراجشده برای context مدل."""
|
|
|
|
__tablename__ = "ai_chat_attachments"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
session_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("ai_chat_sessions.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
user_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
filename: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
mime_type: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
|
extracted_text: Mapped[str] = mapped_column(Text, nullable=False)
|
|
char_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
|
|
|
session = relationship("AIChatSession", back_populates="attachments")
|