Skip to main content

Module prompt

Module prompt 

Source
Expand description

Assembling the prompt for the surface-generating model.

A2UI v0.9 is designed to be prompted rather than schema-constrained: the catalog goes into the prompt, the model writes JSON against it, and the result is validated afterwards. That makes prompt assembly load-bearing, so it lives here rather than being open-coded per agent.

A prompt is assembled in this order:

  1. the role,
  2. the task,
  3. ## Workflow Description: — the rules that make output parseable,
  4. ## UI Description: — application-specific design guidance,
  5. the catalog, as a compact summary or as the raw schema block,
  6. ### Examples: — few-shot examples, when supplied,
  7. the conversation context,
  8. the current surface, when updating one.

Section 8 is what makes intent = "update" work: without the components already on screen, the model cannot edit them, only replace them.

§Section headings are a cross-language contract

The headings and the opening line of the workflow rules are the same strings every A2UI toolkit emits. Evaluation harnesses and prompt-diffing tools key on them, so a surface generated by this crate can be compared against one generated by the TypeScript or Python toolkit. The rules under that opening line are this crate’s own, and are written to head off the failures its validator actually reports.

Structs§

PromptSpec
Everything the prompt builder needs.

Constants§

EXAMPLES_SECTION
Heading of the section carrying few-shot examples.
GENERATION_GUIDELINES
The rules that keep generated A2UI parseable and renderable.
UI_SECTION
Heading of the section carrying application design guidance.
WORKFLOW_SECTION
Heading of the section carrying the generation rules.

Functions§

augment_prompt_with_errors
Appends the errors from a failed attempt to the prompt for the next one.
build_subagent_prompt
Builds the full system prompt for the generating model.
describe_surface
A short human-readable summary of a surface, for logs and activity reports.
format_validation_errors
Formats validation errors for a retry prompt.
render_data_model
Renders a data model compactly for inclusion in a prompt.