WIP-CHECKPOINT[auth-refactor]: 固化工程师崩溃前部分成果 + 同树其他未提交WIP(仅源码,不含密钥/二进制)-- 待重激活工程师续作
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
# =============================================================================
|
||||
# 企微IT智能服务台 — 会话标注模型
|
||||
# =============================================================================
|
||||
# 说明:对应数据库 conversation_annotations 表
|
||||
# 存储坐席对AI回复的标注数据,用于模型优化
|
||||
# =============================================================================
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Index, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class ConversationAnnotation(Base):
|
||||
"""会话标注模型 — 对应 conversation_annotations 表。
|
||||
|
||||
存储坐席对AI回复的标注数据,用于持续优化AI能力。
|
||||
|
||||
Attributes:
|
||||
id: 标注ID(UUID)
|
||||
conversation_id: 会话ID
|
||||
agent_id: 坐席ID
|
||||
message_id: 被标注的消息ID(AI回复)
|
||||
feedback: 反馈类型(useful=有用/useless=无用)
|
||||
comment: 备注(可选)
|
||||
created_at: 创建时间
|
||||
"""
|
||||
|
||||
# 表名
|
||||
__tablename__ = "conversation_annotations"
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 字段定义
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
# 主键
|
||||
id: Mapped[str] = mapped_column(
|
||||
String(36),
|
||||
primary_key=True,
|
||||
default=lambda: str(uuid.uuid4()),
|
||||
)
|
||||
|
||||
# 会话ID
|
||||
conversation_id: Mapped[str] = mapped_column(
|
||||
String(36),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="会话ID",
|
||||
)
|
||||
|
||||
# 坐席ID
|
||||
agent_id: Mapped[str] = mapped_column(
|
||||
String(36),
|
||||
nullable=False,
|
||||
comment="坐席ID",
|
||||
)
|
||||
|
||||
# 被标注的消息ID
|
||||
message_id: Mapped[str] = mapped_column(
|
||||
String(36),
|
||||
nullable=False,
|
||||
comment="被标注的消息ID",
|
||||
)
|
||||
|
||||
# 反馈类型
|
||||
feedback: Mapped[str] = mapped_column(
|
||||
String(20),
|
||||
nullable=False,
|
||||
comment="useful=有用/useless=无用",
|
||||
)
|
||||
|
||||
# 备注
|
||||
comment: Mapped[str] = mapped_column(
|
||||
Text,
|
||||
nullable=True,
|
||||
comment="备注",
|
||||
)
|
||||
|
||||
# 创建时间
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True),
|
||||
nullable=False,
|
||||
default=datetime.now,
|
||||
comment="创建时间",
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# 索引定义
|
||||
# --------------------------------------------------------------------------
|
||||
__table_args__ = (
|
||||
Index("idx_annotation_conversation", "conversation_id"),
|
||||
Index("idx_annotation_message", "message_id"),
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""标注对象的字符串表示。"""
|
||||
return f"<ConversationAnnotation(id={self.id}, feedback={self.feedback})>"
|
||||
Reference in New Issue
Block a user