session_model.py 1.1 KB

123456789101112131415161718192021222324252627
  1. import json
  2. from datetime import datetime
  3. from enum import IntEnum
  4. from sqlalchemy import Column, String, Enum as SQLAlchemyEnum, Integer, DateTime
  5. from app.models import AgentType, current_time
  6. from app.models.base_model import Base
  7. class SessionModel(Base):
  8. __tablename__ = "sessions"
  9. id = Column(String(255), primary_key=True)
  10. name = Column(String(255))
  11. agent_id = Column(String(255))
  12. agent_type = Column(SQLAlchemyEnum(AgentType), nullable=False) # 目前只存basic的,ragflow和bisheng的调接口获取
  13. create_date = Column(DateTime, default=current_time) # 创建时间,默认值为当前时区时间
  14. update_date = Column(DateTime, default=current_time, onupdate=current_time) # 更新时间,默认值为当前时区时间,更新时自动更新
  15. # to_dict 方法
  16. def to_dict(self):
  17. return {
  18. 'id': self.id,
  19. 'name': self.name,
  20. 'agent_type': self.agent_type,
  21. 'agent_id': self.agent_id,
  22. 'create_date': self.create_date,
  23. 'update_date': self.update_date,
  24. }