feat: 完善人工关注与内容合规配置

This commit is contained in:
2026-08-24 17:49:56 +08:00
parent 6ffdd2c259
commit 910e67bd89
53 changed files with 1808 additions and 49 deletions

View File

@@ -10,6 +10,7 @@ from app.models.growth import GrowthProfileRevision, PeriodicReport, ShareDraft,
from app.models.insight import QuestionInsightCleanedQuestion
from app.models.knowledge import (
HumanAttentionHistory,
HumanAttentionJob,
HumanAttentionRecord,
Knowledge,
KnowledgeCard,
@@ -53,6 +54,7 @@ __all__ = [
"KnowledgeSyncJob",
"KnowledgeVersion",
"HumanAttentionHistory",
"HumanAttentionJob",
"HumanAttentionRecord",
"ModelConfig",
"MessageFeedback",

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
from datetime import datetime
from sqlalchemy import BigInteger, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
from sqlalchemy import BigInteger, DateTime, ForeignKey, Index, Integer, String, Text, UniqueConstraint, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base, TimestampMixin
@@ -274,3 +274,33 @@ class HumanAttentionHistory(Base):
note: Mapped[str | None] = mapped_column(Text, nullable=True)
operated_by: Mapped[int] = mapped_column(BigInteger, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
class HumanAttentionJob(Base):
__tablename__ = "sys_human_attention_job"
__table_args__ = (
UniqueConstraint("message_id", name="uq_human_attention_job_message"),
Index("ix_human_attention_job_status_next", "status", "next_run_at", "id"),
Index("ix_human_attention_job_user", "user_id"),
Index("ix_human_attention_job_session", "session_id"),
Index("ix_human_attention_job_retrieval", "retrieval_log_id"),
)
id: Mapped[int] = mapped_column(PRIMARY_KEY_TYPE, primary_key=True, autoincrement=True)
session_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
message_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
retrieval_log_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
question: Mapped[str] = mapped_column(Text, nullable=False)
answer: Mapped[str] = mapped_column(Text, nullable=False)
knowledge_missing: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
config_snapshot: Mapped[str] = mapped_column(Text, nullable=False)
status: Mapped[str] = mapped_column(String(20), default="pending", nullable=False)
attempt_count: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
max_attempts: Mapped[int] = mapped_column(Integer, default=3, nullable=False)
next_run_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
locked_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
locked_by: Mapped[str | None] = mapped_column(String(100), nullable=True)
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
finished_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)