feat: flow runtime on LFX with tests
- LfxClient (upload/run/info/delete, typed errors, serve-key auth) - Flows API: CRUD, versions, deploy, sync run, SSE stream proxy, runs - Approvals callback endpoint (flow terminal-state contract) - Runner: envelope in, status from approval side-effect (no interrupts) - Fixture generator (lfx serializers) + simple_rule/approval_handoff fixtures verified against real lfx serve - 14 tests green (real LFX subprocess + live uvicorn callback server)
This commit is contained in:
parent
e178ae406d
commit
96c0da33c7
15 changed files with 5070 additions and 5 deletions
86
backend/app/flows/schemas.py
Normal file
86
backend/app/flows/schemas.py
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
"""Pydantic contracts for the flows API."""
|
||||
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class FlowDefinitionCreate(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=200)
|
||||
description: str = Field(default="", max_length=2000)
|
||||
continuation_flow_id: UUID | None = None
|
||||
|
||||
|
||||
class FlowDefinitionRead(BaseModel):
|
||||
id: UUID
|
||||
name: str
|
||||
description: str
|
||||
status: str
|
||||
continuation_flow_id: UUID | None
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class FlowVersionCreate(BaseModel):
|
||||
langflow_json: dict
|
||||
author: str = Field(default="", max_length=200)
|
||||
|
||||
|
||||
class FlowVersionRead(BaseModel):
|
||||
id: UUID
|
||||
flow_id: UUID
|
||||
version_no: int
|
||||
langflow_json: dict
|
||||
lfx_flow_id: str | None
|
||||
deployed_at: datetime | None
|
||||
author: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class RunRequest(BaseModel):
|
||||
"""Start a flow run. `input` is the domain payload handed to the flow."""
|
||||
|
||||
input: dict = Field(default_factory=dict)
|
||||
version_no: int | None = None
|
||||
tenant_id: str = Field(default="default", max_length=200)
|
||||
session_id: str | None = None
|
||||
# Base URL the flow uses for callbacks (e.g. approval tasks).
|
||||
# Defaults to settings.callback_base_url; tests point it at a live server.
|
||||
callback_base_url: str | None = None
|
||||
continuation_flow_id: UUID | None = None
|
||||
|
||||
|
||||
class RunRead(BaseModel):
|
||||
id: UUID
|
||||
version_id: UUID
|
||||
tenant_id: str
|
||||
status: str
|
||||
input: dict | None
|
||||
output: dict | None
|
||||
session_id: str | None
|
||||
created_at: datetime
|
||||
finished_at: datetime | None
|
||||
|
||||
|
||||
class ApprovalCreate(BaseModel):
|
||||
"""Callback contract: a flow reports a terminal approval state."""
|
||||
|
||||
run_id: UUID
|
||||
title: str = Field(default="", max_length=500)
|
||||
payload: dict = Field(default_factory=dict)
|
||||
continuation_flow_id: UUID | None = None
|
||||
|
||||
|
||||
class ApprovalRead(BaseModel):
|
||||
id: UUID
|
||||
run_id: UUID
|
||||
version_id: UUID
|
||||
tenant_id: str
|
||||
title: str
|
||||
payload: dict
|
||||
continuation_flow_id: UUID | None
|
||||
approver: str | None
|
||||
status: str
|
||||
decision_note: str
|
||||
created_at: datetime
|
||||
decided_at: datetime | None
|
||||
Loading…
Add table
Add a link
Reference in a new issue