Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: migrate DocumentSegmentSummary to TypeBase (#34862)
sxxtony90d638fba31d
diff --git a/api/models/dataset.py b/api/models/dataset.pyindex 50301dd2d7d..eee5c39a0e8 100644--- a/api/models/dataset.py+++ b/api/models/dataset.py@@ -1715,7 +1715,7 @@ class SegmentAttachmentBinding(TypeBase):)-class DocumentSegmentSummary(Base):+class DocumentSegmentSummary(TypeBase):__tablename__ = "document_segment_summaries"__table_args__ = (sa.PrimaryKeyConstraint("id", name="document_segment_summaries_pkey"),@@ -1725,25 +1725,40 @@ class DocumentSegmentSummary(Base):sa.Index("document_segment_summaries_status_idx", "status"),)- id: Mapped[str] = mapped_column(StringUUID, nullable=False, default=lambda: str(uuid4()))+ id: Mapped[str] = mapped_column(+ StringUUID,+ nullable=False,+ insert_default=lambda: str(uuid4()),+ default_factory=lambda: str(uuid4()),+ init=False,+ )dataset_id: Mapped[str] = mapped_column(StringUUID, nullable=False)document_id: Mapped[str] = mapped_column(StringUUID, nullable=False)# corresponds to DocumentSegment.id or parent chunk idchunk_id: Mapped[str] = mapped_column(StringUUID, nullable=False)- summary_content: Mapped[str] = mapped_column(LongText, nullable=True)- summary_index_node_id: Mapped[str] = mapped_column(String(255), nullable=True)- summary_index_node_hash: Mapped[str] = mapped_column(String(255), nullable=True)- tokens: Mapped[int | None] = mapped_column(sa.Integer, nullable=True)- status: Mapped[str] = mapped_column(- EnumText(SummaryStatus, length=32), nullable=False, server_default=sa.text("'generating'")+ summary_content: Mapped[str | None] = mapped_column(LongText, nullable=True, default=None)+ summary_index_node_id: Mapped[str | None] = mapped_column(String(255), nullable=True, default=None)+ summary_index_node_hash: Mapped[str | None] = mapped_column(String(255), nullable=True, default=None)+ tokens: Mapped[int | None] = mapped_column(sa.Integer, nullable=True, default=None)+ status: Mapped[SummaryStatus] = mapped_column(+ EnumText(SummaryStatus, length=32),+ nullable=False,+ server_default=sa.text("'generating'"),+ default=SummaryStatus.GENERATING,+ )+ error: Mapped[str | None] = mapped_column(LongText, nullable=True, default=None)+ enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("true"), default=True)+ disabled_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, default=None)+ disabled_by: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)+ created_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), init=False)- error: Mapped[str] = mapped_column(LongText, nullable=True)- enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("true"))- disabled_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)- disabled_by = mapped_column(StringUUID, nullable=True)- created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())updated_at: Mapped[datetime] = mapped_column(- DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ DateTime,+ nullable=False,+ server_default=func.current_timestamp(),+ onupdate=func.current_timestamp(),+ init=False,)def __repr__(self):diff --git a/api/services/summary_index_service.py b/api/services/summary_index_service.pyindex a91f49e9e6e..cf39469be85 100644--- a/api/services/summary_index_service.py+++ b/api/services/summary_index_service.py@@ -349,7 +349,6 @@ class SummaryIndexService:summary_record_id,)summary_record_in_session = DocumentSegmentSummary(- id=summary_record_id, # Use the same ID if availabledataset_id=dataset.id,document_id=segment.document_id,chunk_id=segment.id,@@ -360,6 +359,9 @@ class SummaryIndexService:status=SummaryStatus.COMPLETED,enabled=True,)+ if summary_record_in_session is None:+ raise RuntimeError("summary_record_in_session should not be None at this point")+ summary_record_in_session.id = summary_record_idsession.add(summary_record_in_session)logger.info("Created new summary record (id=%s) for segment %s after vectorization",