mirror of
https://github.com/langgenius/dify.git
synced 2026-02-01 16:41:58 +08:00
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: hj24 <mambahj24@gmail.com> Co-authored-by: CodingOnStar <hanxujiang@dify.ai> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class PreviewDetail(BaseModel):
|
|
content: str
|
|
summary: str | None = None
|
|
child_chunks: list[str] | None = None
|
|
|
|
|
|
class QAPreviewDetail(BaseModel):
|
|
question: str
|
|
answer: str
|
|
|
|
|
|
class IndexingEstimate(BaseModel):
|
|
total_segments: int
|
|
preview: list[PreviewDetail]
|
|
qa_preview: list[QAPreviewDetail] | None = None
|
|
|
|
|
|
class PipelineDataset(BaseModel):
|
|
id: str
|
|
name: str
|
|
description: str = Field(default="", description="knowledge dataset description")
|
|
chunk_structure: str
|
|
|
|
@field_validator("description", mode="before")
|
|
@classmethod
|
|
def normalize_description(cls, value: str | None) -> str:
|
|
"""Coerce None to empty string so description is always a string."""
|
|
if value is None:
|
|
return ""
|
|
return value
|
|
|
|
|
|
class PipelineDocument(BaseModel):
|
|
id: str
|
|
position: int
|
|
data_source_type: str
|
|
data_source_info: dict | None = None
|
|
name: str
|
|
indexing_status: str
|
|
error: str | None = None
|
|
enabled: bool
|
|
|
|
|
|
class PipelineGenerateResponse(BaseModel):
|
|
batch: str
|
|
dataset: PipelineDataset
|
|
documents: list[PipelineDocument]
|