"""用户反馈记录模型 — 采集点踩/修改/驳回等反馈信号""" import uuid from datetime import datetime from sqlalchemy import Column, String, Text, DateTime, JSON, Float, Integer, Boolean from app.core.database import Base class FeedbackRecord(Base): """用户反馈记录""" __tablename__ = "feedback_records" id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4())) user_id = Column(String(36), nullable=False, index=True) # 反馈信号 signal_type = Column(String(30), nullable=False, comment="thumbs_down/manual_edit/retry_command/reject_approval") severity = Column(Float, default=0.5, comment="严重程度(0-1)") # 关联上下文 execution_log_id = Column(String(36), nullable=True, index=True) agent_name = Column(String(200), nullable=True) task_id = Column(String(36), nullable=True) # 原始内容 original_output = Column(Text, nullable=True, comment="被否定的Agent输出") user_correction = Column(Text, nullable=True, comment="用户修正后的内容") # 反馈详情 feedback_context = Column(JSON, nullable=True, comment="反馈上下文: {user_message, reason, ...}") improvement_suggestion = Column(Text, nullable=True, comment="LLM生成的改进建议") # 学习状态 learned = Column(Boolean, default=False, comment="是否已学习") lesson_summary = Column(Text, nullable=True, comment="学习后的教训总结") created_at = Column(DateTime, default=datetime.now) def __repr__(self): return f""