feat: asked-field envelope, standalone form components, branched forms

This commit is contained in:
Jonas Miederer 2026-09-28 14:07:09 +02:00
parent 0d43b0e8fb
commit f27be044b4
26 changed files with 3651 additions and 104 deletions

View file

@ -9,6 +9,7 @@ from sqlmodel import Session, select
from app.models import ApprovalTask, FlowRun, FlowVersion
from . import input_schema as form_schema
from . import store
from .lfx_client import LfxClient, LfxRunFailed
from .store import InvalidError
@ -21,16 +22,21 @@ def build_envelope(
callback_base_url: str,
continuation_flow_id: UUID | None,
callback_token: str,
fields: list[str] | None = None,
) -> str:
return json.dumps(
{
"payload": payload,
"run_id": str(run_id),
"callback_url": callback_base_url.rstrip("/"),
"continuation_flow_id": (str(continuation_flow_id) if continuation_flow_id else None),
"callback_token": callback_token,
}
)
"""Run envelope for LFX. ``fields`` (asked form-field names, from the
version's cached input schema) lets form components emit defaults only
for asked fields; omitted (None) preserves the legacy shape."""
body: dict = {
"payload": payload,
"run_id": str(run_id),
"callback_url": callback_base_url.rstrip("/"),
"continuation_flow_id": (str(continuation_flow_id) if continuation_flow_id else None),
"callback_token": callback_token,
}
if fields is not None:
body["fields"] = list(fields)
return json.dumps(body)
def _task_exists(session: Session, run_id: UUID) -> bool:
@ -66,12 +72,14 @@ async def execute_run(
run = store.create_run(
session, version, input=payload, tenant_id=tenant_id, session_id=session_id
)
cached = version.input_schema or form_schema.extract_form_schema(version.langflow_json)
envelope = build_envelope(
payload=payload,
run_id=run.id,
callback_base_url=callback_base_url,
continuation_flow_id=continuation_flow_id,
callback_token=callback_token,
fields=form_schema.schema_field_names(cached),
)
try:
result = await lfx.run_flow(