tmp
zhaoqingang
2025-01-07 7666bdbabfb929f98e94310dbe99eabb435898a2
app/models/v2/session_model.py
@@ -5,7 +5,7 @@
import pytz
from pydantic import BaseModel
from sqlalchemy import Column, String, Enum as SQLAlchemyEnum, Integer, DateTime, JSON, TEXT
from sqlalchemy import Column, String, Integer, DateTime, JSON, TEXT, Index
from app.models.agent_model import AgentType
# from app.models import current_time
@@ -16,16 +16,24 @@
    return datetime.now(tz)
class SessionModel(Base):
    __tablename__ = "sessions"
    id = Column(String(255), primary_key=True)
    __tablename__ = "chat_sessions"
    __table_args__ = (
        Index('idx_username', 'username'),
    )
    id = Column(Integer, primary_key=True)
    name = Column(String(255))
    agent_id = Column(String(255))
    agent_type = Column(SQLAlchemyEnum(AgentType), nullable=False)  # 目前只存basic的,ragflow和bisheng的调接口获取
    agent_type = Column(Integer)  # 目前只存basic的,ragflow和bisheng的调接口获取
    create_date = Column(DateTime, default=current_time)  # 创建时间,默认值为当前时区时间
    update_date = Column(DateTime, default=current_time, onupdate=current_time)  # 更新时间,默认值为当前时区时间,更新时自动更新
    update_date = Column(DateTime, default=current_time, onupdate=current_time, index=True)  # 更新时间,默认值为当前时区时间,更新时自动更新
    tenant_id = Column(Integer)  # 创建人
    message = Column(TEXT)  # 说明
    reference = Column(TEXT)  # 说明
    conversation_id = Column(String(64))
    session_id = Column(String(36), index=True)
    chat_mode = Column(Integer)
    # to_dict 方法
    def to_dict(self):
@@ -63,3 +71,4 @@
class ChatDialogData(BaseModel):
    sessionId: Optional[str] = ""
    question: str
    chatId: str