Files
ai-contract-platform/backend/app/models/knowledge_base_document.py
T
2026-04-24 13:44:17 +08:00

23 lines
1.1 KiB
Python

from datetime import datetime, timezone
from typing import Optional
from sqlalchemy import DateTime, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.db import Base
class KnowledgeBaseDocument(Base):
__tablename__ = "knowledge_base_documents"
id: Mapped[str] = mapped_column(String(64), primary_key=True)
knowledge_base_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
tenant_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
file_name: Mapped[str] = mapped_column(String(255), nullable=False)
mime_type: Mapped[Optional[str]] = mapped_column(String(120), nullable=True)
file_size: Mapped[int] = mapped_column(Integer, default=0)
status: Mapped[str] = mapped_column(String(32), default="indexed")
content_excerpt: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), index=True)