knowledge_document.py 1.0 KB

123456789101112131415161718192021
  1. from datetime import datetime
  2. from core_db import AuditMixin, Base, EntityMixin
  3. from core_shared import JSONValue
  4. from sqlalchemy import DateTime, String, Text
  5. from sqlalchemy import JSON
  6. from sqlalchemy.orm import Mapped, mapped_column
  7. class KnowledgeDocument(EntityMixin, AuditMixin, Base):
  8. __tablename__ = "knowledge_document"
  9. knowledge_base_id: Mapped[str] = mapped_column(String(36), index=True)
  10. title: Mapped[str] = mapped_column(String(256))
  11. source_type: Mapped[str] = mapped_column(String(32), default="text", index=True)
  12. source_uri: Mapped[str | None] = mapped_column(String(512), nullable=True)
  13. status: Mapped[str] = mapped_column(String(32), default="draft", index=True)
  14. content_text: Mapped[str] = mapped_column(Text)
  15. content_hash: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
  16. metadata_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True)
  17. indexed_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)