Skip to content

API Reference parrot_formdesigner.tools.create_form

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

parrot_formdesigner.tools.create_form

View source

CreateFormTool — LLM-driven and deterministic form generation tool.

Accepts either a natural language prompt (LLM path) or fully structured input (schema, sections, fields — deterministic path via FormAssembler, zero LLM calls) and returns a validated FormSchema. Supports iterative refinement: when refine_form_uid is provided, loads the existing form (by its immutable form_uid, FEAT-389) and asks the LLM to modify it.

LLM flow (prompt-only):

  1. Build a structured system prompt with FormSchema JSON structure
  2. If refine_form_uid, load existing form from registry (by form_uid) and include in prompt
  3. Call LLM client to generate JSON
  4. Parse and validate against FormSchema (retry up to 2 times with error feedback)
  5. Validate generated form using FormValidator (circular dependency check)
  6. Optionally register in FormRegistry with persist=True
  7. Return FormSchema in ToolResult metadata (including form_uid)

FEAT-389: the LLM never generates form_uid — it is always injected by this tool. New forms get a fresh uuid.uuid4() (or a caller-supplied form_uid); refinements preserve the existing form's form_uid unchanged (only form_id/slug and content may change via a refinement prompt).

Deterministic flow (schema/sections/fields — FEAT-388):

  1. Detect which structured input was provided
  2. Delegate to FormAssembler for format detection, shortcut expansion, and assembly — no LLM call
  3. Validate generated form using FormValidator (circular dependency check)
  4. Optionally register in FormRegistry with persist=True
  5. Return FormSchema in ToolResult metadata (same shape as the LLM path)

Class CreateFormInput

Input schema for the create_form tool.

Exactly one of prompt (LLM path) or a structured input — schema, sections, fields (deterministic path, FEAT-388) — must be provided. Providing both, or neither, is a validation error raised at execution time (see CreateFormTool._execute).

Fields:

Field Type Default Description
prompt str | None None Natural language description of the form to create or modification to apply. Required only when no structured input is given.
schema dict[str, Any] | None None Complete form definition as a dict. Accepts either: (1) Standard JSON Schema (draft-07) — detected by 'type'+ 'properties' keys; (2) FormSchema-native JSON (with optional shortcuts like auto-generated IDs). No LLM call is made.
sections list[dict[str, Any]] | None None List of section dicts to assemble into a form. No LLM call is made.
fields list[dict[str, Any]] | None None Flat list of field dicts. Auto-wrapped in a single default section. No LLM call is made.
form_id str | None None Custom form ID (slug). Auto-generated if not provided.
form_uid uuid.UUID | None None Optional UUID for the form. Auto-generated if not provided (FEAT-389).
persist bool False Whether to save the form to the registry storage.
refine_form_uid uuid.UUID | None None UUID of an existing form to load and modify (FEAT-389 — renamed from refine_form_id; forms are now looked up by their immutable identity, not their slug).

Class CreateFormTool

Create a FormSchema from a natural language prompt using an LLM.

Supports:

  • New form creation from a prompt
  • Iterative refinement of an existing form
  • Pydantic validation with up to 2 retries (error feedback to LLM)
  • Circular dependency detection via FormValidator
  • Optional registry persistence
Parameter Type Default Description
client Any LLM client with a completion() or ask() method.
registry FormRegistry | None None Optional FormRegistry for refinement lookups and persistence.
model str | None None Optional model name override for form generation calls.
tenant str | None None Optional tenant slug used when looking up and registering forms. When None, :class:FormRegistry falls back to its configured default_tenant.
**kwargs Any {}

Attributes:

Attribute Type Description
name str
description str
client Any The LLM client used for form generation.

Alias EditToolkit

Re-exported from parrot_formdesigner.tools.edit_toolkit.EditToolkit.

Alias FormAssembler

Re-exported from parrot_formdesigner.assembler.FormAssembler.

Alias FormRegistry

Re-exported from parrot_formdesigner.services.registry.FormRegistry.

Alias FormSchema

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

Alias FormValidator

Re-exported from parrot_formdesigner.services.validators.FormValidator.

Alias get_form_field_schema_snippets

Re-exported from parrot_formdesigner.tools.field_helpers.get_form_field_schema_snippets.

Alias list_supported_form_field_types

Re-exported from parrot_formdesigner.tools.field_helpers.list_supported_form_field_types.

Attribute logger

Alias resolve_rule_references

Re-exported from parrot_formdesigner.core.resolution.resolve_rule_references.

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