fix deploy bug

This commit is contained in:
EduBrain Dev
2026-04-14 18:00:18 +08:00
parent c5f96056fa
commit 2a6e506416
2 changed files with 18 additions and 21 deletions

View File

@@ -37,20 +37,24 @@ class KnowledgePage(Base, TimestampMixin):
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
title: Mapped[str] = mapped_column(String(500), nullable=False, comment="页面标题")
content: Mapped[str] = mapped_column(Text, nullable=False, comment="页面内容")
source: Mapped[str | None] = mapped_column(String(200), nullable=True, comment="来源文件")
source_file: Mapped[str | None] = mapped_column(String(500), nullable=True, comment="来源文件路径")
page_number: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="原文件页码")
# 向量嵌入JSON 格式存储)
course_name: Mapped[str | None] = mapped_column(String(200), nullable=True, comment="课程名称")
teacher_name: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="讲师名称")
live_date: Mapped[str | None] = mapped_column(String(20), nullable=True, comment="直播日期")
metadata_json: Mapped[str | None] = mapped_column(Text, nullable=True, comment="额外元数据JSON")
embedding: Mapped[str | None] = mapped_column(Text, nullable=True, comment="向量嵌入JSON")
@property
def embedding_vector(self) -> list[float] | None:
if self.embedding is None:
return None
return json.loads(self.embedding)
@embedding_vector.setter
def embedding_vector(self, value: list[float] | None):
self.embedding = json.dumps(value) if value else None
class KnowledgeChunk(Base, TimestampMixin):
"""知识页面分块"""
__tablename__ = "knowledge_chunks"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
page_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="关联页面 ID")
chunk_index: Mapped[int] = mapped_column(Integer, nullable=False, comment="分块索引")
content: Mapped[str] = mapped_column(Text, nullable=False, comment="分块内容")
embedding: Mapped[str | None] = mapped_column(Text, nullable=True, comment="向量嵌入JSON")
class OCRImage(Base, TimestampMixin):