message.py 784 B

1234567891011121314151617
  1. from core_db import AuditMixin, Base, EntityMixin, VersionMixin
  2. from sqlalchemy import Integer, String, Text
  3. from sqlalchemy.dialects.sqlite import JSON
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. class Message(EntityMixin, AuditMixin, VersionMixin, Base):
  6. __tablename__ = "message"
  7. session_id: Mapped[str] = mapped_column(String(36), index=True)
  8. turn_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  9. role: Mapped[str] = mapped_column(String(32))
  10. content_type: Mapped[str] = mapped_column(String(32))
  11. content_text: Mapped[str | None] = mapped_column(Text, nullable=True)
  12. content_json: Mapped[dict | None] = mapped_column(JSON, nullable=True)
  13. token_count: Mapped[int | None] = mapped_column(Integer, nullable=True)