31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""
|
||
文档向量化模型
|
||
"""
|
||
from sqlalchemy import Column, BigInteger, String, DateTime, Index, Text
|
||
from sqlalchemy.sql import func
|
||
from app.core.database import Base
|
||
|
||
|
||
class DocumentVector(Base):
|
||
"""文档向量表模型"""
|
||
|
||
__tablename__ = "document_vector"
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="向量ID")
|
||
project_id = Column(BigInteger, nullable=False, index=True, comment="项目ID")
|
||
file_path = Column(String(500), nullable=False, comment="文件相对路径")
|
||
content_hash = Column(String(64), comment="内容哈希值,用于判断文件是否变更")
|
||
zvec_id = Column(String(256), comment="ZVec返回的向量ID")
|
||
zvec_response = Column(Text, comment="ZVec完整响应JSON")
|
||
status = Column(String(32), nullable=False, default="success", comment="向量化状态:success/failed/pending")
|
||
error_message = Column(String(500), comment="错误信息")
|
||
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||
|
||
__table_args__ = (
|
||
Index("idx_project_file", "project_id", "file_path"),
|
||
)
|
||
|
||
def __repr__(self):
|
||
return f"<DocumentVector(id={self.id}, project_id={self.project_id}, file_path='{self.file_path}', status='{self.status}')>"
|