2.8 KiB
2.8 KiB
Authoring web forms (CustomInputForm)
Flows that should render a web form start with a CustomInputForm node
(this package — the kirche category in the Langflow palette). The API
derives a JSON Schema + uiSchema from the node's template
(app/flows/input_schema.py) and the webapp renders it with RJSF.
Adding a new form field
- Open the Langflow authoring UI (http://localhost:7860) and load the
flow from
LANGFLOW_LOAD_FLOWS_PATH(canonical files are preloaded). - Edit the
CustomInputFormnode: every entry in itsinputslist is one web-form field. Add anlfx.ioinput, e.g.
Supported input types → widgets:from lfx.io import DropdownInput DropdownInput( name="room", # JSON-Schema property key display_name="Room", # form label (title) info="Where should it take place", # help text (description) options=["Chapel", "Hall"], # dropdown choices (enum) value="Chapel", # prefill (default) required=True, # marks the field required )StrInput/MessageTextInput→ text,MultilineInput→ textarea,SecretStrInput→ password,IntInput→ integer,FloatInput→ number,BoolInput→ checkbox,DropdownInput→ select,MultiselectInput→ multi-select,SliderInput→ slider (needsrange_spec),FileInput→ text stub (real upload later). - Add the new field to
collect()so it reaches the JSON output. - Wire the envelope: keep the
ChatInput → form_valuesedge (hidden input,show=False). Submitted web-form values arrive there as{"payload": {...}}and are merged over the defaults. Never make form fields required with an incoming edge — that's the envelope's job. - Export the flow (JSON) into
backend/flows/<name>.jsonand commit. The API watcher syncs + deploys it automatically; the form schema is regenerated per version.
Conventions the pipeline relies on
required=Trueon a template field:lfx validate --level 4demands a value or an edge, so the canonical-flow generator (backend/scripts/make_flow_fixtures.py) writes a single-space sentinel value for such fields. The form parser treats whitespace-only values as "no default" — don't ship real whitespace defaults.- Field key =
name(stable); label =display_name; help =info. - Unknown future input types degrade to a plain text field in the web form (parser fallback), so adding exotic lfx inputs never breaks runs.
Regenerating the bundled fixtures
After editing the component source (form_inputs.py), refresh the
canonical + test-fixture exports:
docker compose exec api /opt/venv/bin/python scripts/make_flow_fixtures.py
docker compose exec -T api uv run pytest tests/test_lfx_validate.py