pub struct PromptSpec<'a> {
pub role: &'a str,
pub request: &'a str,
pub intent: Intent,
pub surface_id: &'a str,
pub catalog: &'a Catalog,
pub schemas: Option<&'a SchemaBundle>,
pub examples: Option<&'a str>,
pub conversation: &'a [(String, String)],
pub prior_surface: Option<&'a PriorSurface>,
pub ui_description: Option<&'a str>,
pub workflow_rules: Option<&'a str>,
pub include_response_format: bool,
}Expand description
Everything the prompt builder needs.
Fields§
§role: &'a strWhat the model is, e.g. “You generate UI surfaces for a travel agent.”
request: &'a strWhat the user asked for on this turn.
intent: IntentWhether a new surface is being built or an existing one edited.
surface_id: &'a strThe surface id the model should target.
catalog: &'a CatalogThe catalog the model must stay inside.
schemas: Option<&'a SchemaBundle>The raw schema documents.
When present the prompt carries the full JSON Schema block instead of the
compact catalog summary: exact, but far more tokens. Prune it first with
SchemaBundle::prune if the model only needs part of the catalog.
examples: Option<&'a str>Few-shot examples, already rendered by
load_examples.
conversation: &'a [(String, String)]Prior conversation turns, oldest first, as (role, text).
prior_surface: Option<&'a PriorSurface>The surface currently on screen, for Intent::Update.
ui_description: Option<&'a str>Extra design guidance from the application.
workflow_rules: Option<&'a str>Replaces GENERATION_GUIDELINES wholesale.
The default rules are tuned to what this crate’s validator rejects; an
application with its own house style can substitute its own, keeping the
The generated response MUST follow these rules: opening line so the
section stays recognizable across toolkits.
include_response_format: boolWhether to spell out the response format with the <a2ui-json> tags.
Turn this off when the model answers through a structured-output tool, where the tags would end up inside the JSON.
Implementations§
Source§impl<'a> PromptSpec<'a>
impl<'a> PromptSpec<'a>
Sourcepub fn new(role: &'a str, request: &'a str, catalog: &'a Catalog) -> Self
pub fn new(role: &'a str, request: &'a str, catalog: &'a Catalog) -> Self
A spec with sensible defaults for a create-intent turn.
Sourcepub fn updating(self, prior: &'a PriorSurface) -> Self
pub fn updating(self, prior: &'a PriorSurface) -> Self
Points the spec at an existing surface, switching to update intent.
Sourcepub fn with_conversation(self, conversation: &'a [(String, String)]) -> Self
pub fn with_conversation(self, conversation: &'a [(String, String)]) -> Self
Supplies prior conversation turns.
Sourcepub fn with_schemas(self, schemas: &'a SchemaBundle) -> Self
pub fn with_schemas(self, schemas: &'a SchemaBundle) -> Self
Carries the raw schema block instead of the compact catalog summary.
Sourcepub fn with_examples(self, examples: &'a str) -> Self
pub fn with_examples(self, examples: &'a str) -> Self
Adds few-shot examples.
Trait Implementations§
Source§impl<'a> Clone for PromptSpec<'a>
impl<'a> Clone for PromptSpec<'a>
Source§fn clone(&self) -> PromptSpec<'a>
fn clone(&self) -> PromptSpec<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more