1234567891011121314151617 |
- from .Base import Base
- from datetime import datetime
- from sqlalchemy.orm import relationship
- from sqlalchemy import Column, Integer, ForeignKey, DateTime, Text
- class Message(Base):
- __tablename__ = "messages"
- id = Column(Integer, primary_key=True)
- conversation_id = Column(Integer, ForeignKey("conversations.id"), nullable=False)
- content = Column(Text, nullable=False)
- is_user = Column(Integer, nullable=False) # 1 for user message, 0 for LLM response
- created_at = Column(DateTime, default=datetime.now)
- conversation = relationship("Conversation", back_populates="messages")
|