25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
|
|
"""
|
||
|
|
会话表 — 独立于 chat_messages 管理会话元数据
|
||
|
|
"""
|
||
|
|
from sqlalchemy import Column, String, Text, Integer, DateTime, Boolean, ForeignKey, func
|
||
|
|
from sqlalchemy.dialects.mysql import CHAR
|
||
|
|
from app.core.database import Base
|
||
|
|
import uuid
|
||
|
|
|
||
|
|
|
||
|
|
class AgentSession(Base):
|
||
|
|
"""Agent 会话表"""
|
||
|
|
__tablename__ = "agent_sessions"
|
||
|
|
|
||
|
|
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="会话ID")
|
||
|
|
user_id = Column(CHAR(36), nullable=True, index=True, comment="用户ID")
|
||
|
|
workspace_id = Column(CHAR(36), ForeignKey("workspaces.id"), nullable=True, index=True, comment="工作区ID")
|
||
|
|
agent_id = Column(CHAR(36), nullable=True, index=True, comment="Agent ID")
|
||
|
|
title = Column(String(200), nullable=True, comment="会话标题")
|
||
|
|
is_pinned = Column(Boolean, default=False, comment="是否置顶")
|
||
|
|
created_at = Column(DateTime, default=func.now(), comment="创建时间")
|
||
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
|
||
|
|
|
||
|
|
def __repr__(self):
|
||
|
|
return f"<AgentSession(id={self.id}, title={self.title}, pinned={self.is_pinned})>"
|