Message.py 607 B

1234567891011121314151617
  1. from .Base import Base
  2. from datetime import datetime
  3. from sqlalchemy.orm import relationship
  4. from sqlalchemy import Column, Integer, ForeignKey, DateTime, Text
  5. class Message(Base):
  6. __tablename__ = "messages"
  7. id = Column(Integer, primary_key=True)
  8. conversation_id = Column(Integer, ForeignKey("conversations.id"), nullable=False)
  9. content = Column(Text, nullable=False)
  10. is_user = Column(Integer, nullable=False) # 1 for user message, 0 for LLM response
  11. created_at = Column(DateTime, default=datetime.now)
  12. conversation = relationship("Conversation", back_populates="messages")