Skip to content

API Reference parrot_formdesigner.renderers.a2ui

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

parrot_formdesigner.renderers.a2ui

View source

A2UIFormRenderer — lowers a FormSchema into an A2UI v1.0 createSurface envelope.

Spec: sdd/specs/a2ui-form-output-renderer.spec.md (FEAT-544), §3 Module 1.

ai-parrot (and therefore parrot.outputs.a2ui) is an OPTIONAL dependency of parrot-formdesigner (see pyproject.toml's ai-parrot extra) — every parrot.* symbol this module needs is imported lazily, inside :func:_a2ui_ns, so import parrot_formdesigner.renderers.a2ui never fails (or pulls ai-parrot) when the extra is not installed.

Field lowering (TASK-3072) is table-driven: :data:FIELD_LOWERING maps every FieldType to a Basic Catalog primitive (TextField/CheckBox/ ChoicePicker/Slider/DateTimeInput), to "hidden" (dataModel only, no component), or to "notice" — an honest degradation to a Text notice + a RenderWarning for the FieldTypes Basic cannot express (spec §7, hybrid decision U3). Rendering never raises for any FieldType.

Class A2UIFieldLowering

How one FieldType lowers to a Basic Catalog primitive (or degrades).

Fields:

Field Type Default Description
primitive Literal['TextField', 'CheckBox', 'ChoicePicker', 'Slider', 'DateTimeInput', 'notice', 'hidden'] The Basic Catalog component name, or "notice" for an honest degradation, or "hidden" for a dataModel-only field (no component emitted).
props dict[str, Any] Extra wire kwargs merged onto the constructed Component (e.g. {"variant": "longText"}, {"enableDate": True}).
check_functions tuple[str, ...] () Extra Basic check functions always attached to this FieldType's checks (e.g. ("email",) for EMAIL), independent of FieldConstraints.

Class A2UIFormRenderer

Lower a FormSchema into an A2UI v1.0 createSurface envelope.

The resulting surface is composed exclusively of Basic Catalog primitives (Column, Row, Card, Text, Button, plus the per-field input primitives added by TASK-3072) — no Form catalog component is ever emitted (A2UI dialect spec G6). ai-parrot semantics (form/field identity) ride exclusively in metadata.extensions.parrot_*.

Parameter Type Default Description
submit_url_template str DEFAULT_SUBMIT_URL_TEMPLATE str.format template with {tenant} and {form_uid} placeholders for the submit Button's context.submit_url.
catalog_id str | None None Override for the surface's default catalogId.

Attributes:

Attribute Type Description
RENDERER_NAME str
submit_url_template str.format template for the submit URL, filled in with tenant and form_uid per render.
catalog_id Override for the surface's default catalogId. None (default) uses DEFAULT_CATALOG_ID.

Method A2UIFormRenderer.render

Render a FormSchema into an A2UI v1.0 createSurface envelope.

render(form: FormSchema, style: StyleSchema | None = None, *, locale: str = 'en', prefilled: dict[str, Any] | None = None, errors: dict[str, str] | None = None) -> RenderedForm

Parameter Type Default Description
form FormSchema The form schema to render.
style StyleSchema | None None Optional style configuration. Defaults to StyleSchema().
locale str 'en' BCP 47 locale tag for i18n label resolution.
prefilled dict[str, Any] | None None Pre-filled field values (field_id -> value).
errors dict[str, str] | None None Validation errors to display (field_id -> message).

Returns: RenderedForm — A RenderedForm whose content is the serialized createSurface envelope (content_type == "application/a2ui+json").

Alias AbstractFormRenderer

Re-exported from parrot_formdesigner.renderers.base.AbstractFormRenderer.

Attribute DEFAULT_SUBMIT_URL_TEMPLATE

Attribute FIELD_LOWERING

Type: dict[FieldType, A2UIFieldLowering]

Alias FieldOption

Re-exported from parrot_formdesigner.core.options.FieldOption.

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

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 FormSubsection

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

Alias LocalizedString

Re-exported from parrot_formdesigner.core.types.LocalizedString.

Alias RenderWarning

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

Alias RenderedForm

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

Alias StyleSchema

Re-exported from parrot_formdesigner.core.style.StyleSchema.

Function field_id_from_pointer_token

Inverse of :func:field_pointer's escaping (RFC 6901 token unescape).

field_id_from_pointer_token(token: str) -> str

Parameter Type Default Description
token str An escaped pointer reference token (e.g. "a~1b").

Returns: str — The original, unescaped field_id (e.g. "a/b").

Function field_pointer

Build the /answers/... JSON Pointer a field's value is bound at.

Escapes RFC 6901 special characters in field_id — ~ -> ~0 first, then / -> ~1 — before appending it to the /answers/ prefix.

field_pointer(field_id: str) -> str

Parameter Type Default Description
field_id str The form field's field_id.

Returns: str — A well-formed JSON Pointer, e.g. "/answers/a~1b" for "a/b".

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