Files
2026-04-07 16:05:05 +08:00

35 lines
1011 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from .base import BaseModel
from . import db
class Conversation(BaseModel):
__tablename__ = "conversations"
workspace_id = db.Column(
db.BigInteger,
db.ForeignKey("workspaces.id"),
nullable=False,
comment="工作空间ID",
)
agent_id = db.Column(
db.BigInteger, db.ForeignKey("agents.id"), nullable=False, comment="Agent ID"
)
title = db.Column(db.String(200), nullable=True, comment="会话标题")
channel = db.Column(
db.String(50),
default="web",
nullable=False,
comment="渠道(web, dingtalk, feishu, telegram, discord",
)
channel_user_id = db.Column(db.String(100), nullable=True, comment="渠道用户ID")
status = db.Column(
db.String(20),
default="active",
nullable=False,
comment="状态(active, archived, deleted",
)
messages = db.relationship(
"Message", backref="conversation", lazy=True, cascade="all, delete-orphan"
)