| 1234567891011121314151617181920 |
- from sqlalchemy import Integer, String, Text
- from sqlalchemy.dialects.sqlite import JSON
- from sqlalchemy.orm import Mapped, mapped_column
- from core_db import AuditMixin, Base, TenantMixin, VersionMixin
- from core_shared import JSONValue
- class KnowledgeChunk(TenantMixin, AuditMixin, VersionMixin, Base):
- __tablename__ = "knowledge_chunk"
- knowledge_base_id: Mapped[str] = mapped_column(String(36), index=True)
- document_id: Mapped[str] = mapped_column(String(36), index=True)
- chunk_index: Mapped[int] = mapped_column(Integer)
- content_text: Mapped[str] = mapped_column(Text)
- token_count: Mapped[int] = mapped_column(Integer, default=0)
- embedding_model: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
- embedding_json: Mapped[list[float] | None] = mapped_column(JSON, nullable=True)
- embedding_vector: Mapped[str | None] = mapped_column(Text, nullable=True)
- metadata_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True)
|