Skip to content

API Reference parrot_formdesigner.assembler

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.assembler

View source

FormAssembler — deterministic, LLM-free form assembly.

Encapsulates format detection, convenience-shortcut expansion, extractor delegation, and whole-form / component-level assembly for structured (non-LLM) form creation. FormAssembler is a plain, synchronous class with no external side effects — it is usable independently of CreateFormTool or any LLM client.

See sdd/specs/deterministic-creationformtool.spec.md (FEAT-388, Module 1) for the full design.

Class FormAssembler

Deterministic form assembly from structured input.

Handles format detection, shortcut expansion, extractor delegation, and component-level assembly. Usable independently of CreateFormTool — no LLM client required. All methods are synchronous: assembly is pure Pydantic validation and dict manipulation.

Method FormAssembler.assemble

Assemble a complete FormSchema from a schema dict.

Detects whether the input is JSON Schema (draft-07) or FormSchema-native JSON, then delegates accordingly.

assemble(schema: dict[str, Any], *, form_id: str | None = None, title: str | None = None) -> FormSchema

Parameter Type Default Description
schema dict[str, Any] JSON Schema dict or FormSchema-native dict (with optional shortcuts).
form_id str | None None Optional override for the form ID.
title str | None None Optional override for the form title.

Returns: FormSchema — A validated FormSchema.

Raises:

  • pydantic.ValidationError — If the input does not validate as a FormSchema (native path) or contains an unknown field type.

Method FormAssembler.assemble_from_sections

Assemble a FormSchema from a list of section dicts.

assemble_from_sections(sections: list[dict[str, Any]], *, form_id: str | None = None, title: str | None = None) -> FormSchema

Parameter Type Default Description
sections list[dict[str, Any]] List of section dicts (with optional shortcuts).
form_id str | None None Optional form ID. Auto-generated from title when omitted.
title str | None None Optional form title.

Returns: FormSchema — A validated FormSchema.

Method FormAssembler.assemble_from_fields

Assemble a FormSchema from a flat list of field dicts.

Fields are wrapped in a single default section.

assemble_from_fields(fields: list[dict[str, Any]], *, form_id: str | None = None, title: str | None = None, section_title: str | None = None) -> FormSchema

Parameter Type Default Description
fields list[dict[str, Any]] Flat list of field dicts (with optional shortcuts).
form_id str | None None Optional form ID. Auto-generated from title when omitted.
title str | None None Optional form title.
section_title str | None None Optional title for the auto-created default section.

Returns: FormSchema — A validated FormSchema with a single section containing all provided fields.

Method FormAssembler.assemble_field

Create a single FormField from a dict with shortcut expansion.

assemble_field(field_dict: dict[str, Any]) -> FormField

Parameter Type Default Description
field_dict dict[str, Any] Field dict (with optional shortcuts).

Returns: FormField — A validated FormField.

Method FormAssembler.assemble_section

Create a single FormSection from a dict with shortcut expansion.

assemble_section(section_dict: dict[str, Any]) -> FormSection

Parameter Type Default Description
section_dict dict[str, Any] Section dict (with optional shortcuts).

Returns: FormSection — A validated FormSection.

Method FormAssembler.detect_format

Detect input format: 'jsonschema' or 'native'.

detect_format(schema: dict[str, Any]) -> str

Parameter Type Default Description
schema dict[str, Any] The input schema dict.

Returns: str — "jsonschema" when the dict has "type": "object" and a "properties" key; "native" otherwise (including the fallback case where neither shape is recognized — Pydantic validation is left to fail fast).

Method FormAssembler.expand_shortcuts

Expand convenience shortcuts in FormSchema-native JSON.

Handles:

  • Top-level fields (no sections) wrapped in a default section.
  • Missing section_id -> sequential "section-1", "section-2", ...
  • Missing field_id -> slugified label (snake_case), with a numeric suffix on collision.
  • Missing form_id -> slugified title.
  • String field_type values are passed through unchanged (Pydantic coerces them to FieldType).

expand_shortcuts(data: dict[str, Any]) -> dict[str, Any]

Parameter Type Default Description
data dict[str, Any] FormSchema-native dict, possibly with shortcuts.

Returns: dict[str, Any] — A new dict with all shortcuts expanded. The input is not mutated.

Alias FormField

Re-exported from parrot_formdesigner.core.schema.FormField.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias FormSection

Re-exported from parrot_formdesigner.core.schema.FormSection.

Alias JsonSchemaExtractor

Re-exported from parrot_formdesigner.extractors.JsonSchemaExtractor.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally