Merge branch 'dev' into hugo
This commit is contained in:
commit
97a5a1f106
35 files changed
+3749
-259
No files matched your search
+43
-1
@@ -276,7 +276,7 @@ class PermissionRequest(Base):
|
||||
class QuickQuestion(Base):
|
||||
"""
|
||||
常用问题表
|
||||
用途:存储用户自定义的常用问题
|
||||
用途:存储全局/用户常用问题;全局条目(user_id 为空)可配置标准答案并启用 FAQ 缓存命中。
|
||||
"""
|
||||
__tablename__ = 'quick_questions'
|
||||
|
||||
@@ -285,8 +285,50 @@ class QuickQuestion(Base):
|
||||
agent_id: Mapped[int] = mapped_column(ForeignKey('agents.id'))
|
||||
title: Mapped[str] = mapped_column(String(100))
|
||||
question: Mapped[str] = mapped_column(Text)
|
||||
answer: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
aliases: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
|
||||
cache_enabled: Mapped[bool] = mapped_column(default=False)
|
||||
is_enabled: Mapped[bool] = mapped_column(default=True)
|
||||
hit_count: Mapped[int] = mapped_column(default=0)
|
||||
retriever_resources: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
|
||||
expires_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
sort_order: Mapped[int] = mapped_column(default=0)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
|
||||
class FaqHotCandidate(Base):
|
||||
"""
|
||||
热点 FAQ 候选表
|
||||
用途:离线聚合 ChatLog 后的待审核热点问句与推荐答案(PostgreSQL 存储,不含在线命中)。
|
||||
"""
|
||||
__tablename__ = 'faq_hot_candidates'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('agent_id', 'q_norm', name='uq_faq_hot_candidates_agent_qnorm'),
|
||||
Index('ix_faq_hot_candidates_status_expires', 'status', 'expires_at'),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
agent_id: Mapped[int] = mapped_column(ForeignKey('agents.id'), index=True)
|
||||
q_norm: Mapped[str] = mapped_column(String(255))
|
||||
canonical_query: Mapped[str] = mapped_column(Text)
|
||||
answer: Mapped[str] = mapped_column(Text)
|
||||
source_chat_log_id: Mapped[Optional[int]] = mapped_column(ForeignKey('chat_logs.id'), nullable=True)
|
||||
ask_count_7d: Mapped[int] = mapped_column(default=0)
|
||||
user_count_7d: Mapped[int] = mapped_column(default=0)
|
||||
avg_tokens: Mapped[int] = mapped_column(default=0)
|
||||
avg_latency_ms: Mapped[int] = mapped_column(default=0)
|
||||
answer_dominance: Mapped[float] = mapped_column(default=0.0)
|
||||
sample_queries: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
|
||||
retriever_resources: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
|
||||
last_asked_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(20), default='candidate') # candidate | promoted | dismissed
|
||||
promoted_quick_question_id: Mapped[Optional[int]] = mapped_column(ForeignKey('quick_questions.id'), nullable=True)
|
||||
deny_until: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
expires_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
|
||||
class Announcement(Base):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user