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:
- the role,
- the task,
## Workflow Description:— the rules that make output parseable,## UI Description:— application-specific design guidance,- the catalog, as a compact summary or as the raw schema block,
### Examples:— few-shot examples, when supplied,- the conversation context,
- 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§
- Prompt
Spec - 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.