diff --git a/sdk/app/schemas.py b/sdk/app/schemas.py index 82ac768..5141ded 100644 --- a/sdk/app/schemas.py +++ b/sdk/app/schemas.py @@ -101,9 +101,110 @@ class ArtifactBlock(BaseModel): status: str = "done" # running|done|error(生成中/已就绪/失败) +# --------------------------------------------------------------------------- +# §2b 生信块(BFF 仅做持久化校验,不参与渲染——字段契约归前端 store 与 +# bioflow 服务 SSE 事件;union 判别靠 type 字面量,其余字段全默认值 + +# extra="allow" 宽松接收,生信功能只部署 rag 时零影响)。 +# --------------------------------------------------------------------------- + +class BioflowPathBlock(BaseModel): + """生信路径选择卡(FR-BIO-002/003/004):候选路径列表 + 选中项。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_path"] = "bioflow_path" + status: str = "running" + candidates: list[dict[str, Any]] = Field(default_factory=list) + selected: Any = None + autoFilled: list[str] = Field(default_factory=list) + reuseArchive: Any = None + reuseName: Any = None + fallback: Any = None + + +class BioflowProgressBlock(BaseModel): + """生信阶段进度卡(FR-BIO-013/014):逐阶段状态流转 + 日志尾。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_progress"] = "bioflow_progress" + jobId: Any = None + jobStatus: str = "created" + stages: list[dict[str, Any]] = Field(default_factory=list) + autoContinue: bool = False + + +class BioflowFormBlock(BaseModel): + """生信参数确认表单卡(FR-BIO-008/012):阶段参数可编辑表单。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_form"] = "bioflow_form" + stage: str = "" + fields: list[dict[str, Any]] = Field(default_factory=list) + autoContinue: bool = False + rerun: bool = False + submitting: bool = False + + +class BioflowFileBlock(BaseModel): + """生信数据文件引导卡(FR-BIO-005/006):缺失文件提示 + 上传进度。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_file"] = "bioflow_file" + stage: str = "" + requiredFiles: list[str] = Field(default_factory=list) + message: str = "" + files: list[dict[str, Any]] = Field(default_factory=list) + + +class BioflowArchiveBlock(BaseModel): + """生信存档提示卡(FR-BIO-020):任务完成后提示存档。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_archive"] = "bioflow_archive" + jobId: Any = None + status: str = "pending" # pending | archiving | done | dismissed | error + name: str = "" + description: str = "" + result: Any = None + error: Any = None + + +class BioflowQaBlock(BaseModel): + """生信流程知识库咨询引用块(FR-BIO-026):引用携带 cite 供跳转。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_qa"] = "bioflow_qa" + question: str = "" + citations: list[dict[str, Any]] = Field(default_factory=list) + degraded: bool = False + + +class BioflowReuseBlock(BaseModel): + """生信存档复用预填表单块(FR-BIO-023):复用存档方法发起新任务。""" + + model_config = ConfigDict(extra="allow") + + type: Literal["bioflow_reuse"] = "bioflow_reuse" + mode: str = "reuse" + stage: str = "reuse" + archiveId: Any = None + archiveName: str = "" + sessionId: str = "" + target: str = "" + fields: list[dict[str, Any]] = Field(default_factory=list) + prefill: dict[str, Any] = Field(default_factory=dict) + + Block = Union[ TextBlock, TableBlock, CodeBlock, StreamBlock, PipelineBlock, ToolBlock, SourcesBlock, GraphBlock, ArtifactBlock, + BioflowPathBlock, BioflowProgressBlock, BioflowFormBlock, BioflowFileBlock, + BioflowArchiveBlock, BioflowQaBlock, BioflowReuseBlock, ]