Files
2026-06-08 18:14:59 +08:00

35 lines
1.1 KiB
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.
"""
知识库标注模型(Q&A 对)
手动添加的高优先级问答对,检索时优先匹配。
"""
from sqlalchemy import Column, String, Text, Integer, Boolean, Index
from app.base_model import BaseModel
class KnowledgeAnnotation(BaseModel):
"""
知识库标注(Q&A 对)
用户手动添加的问答对,检索时优先匹配 question,返回 answer。
"""
__tablename__ = "ai_knowledge_annotation"
knowledge_base_id = Column(String(21), nullable=False, index=True, comment="所属知识库ID(逻辑外键关联ai_knowledge_base")
# Q&A 内容
question = Column(Text, nullable=False, comment="问题")
answer = Column(Text, nullable=False, comment="答案")
# 向量化状态
embedding_status = Column(String(20), default="pending", comment="向量化状态: pending/completed/failed")
# 状态
enabled = Column(Boolean, default=True, comment="是否启用")
hit_count = Column(Integer, default=0, comment="命中次数")
__table_args__ = (
Index('idx_annotation_kb_enabled', 'knowledge_base_id', 'enabled'),
)