A2UIAgent.Express (A2UIAgent v0.1.1)

Copy Markdown View Source

The Express inference format: the model writes a compact, function-call notation between <a2ui> and </a2ui> tags, which the agent compiles into A2UI messages.

<a2ui>
surface("booking")
$/form/name = ""
root = Card(form)
form = Column([TextField("Name", $/form/name, ?required), submit])
submit = Button(Text("Book"), action=Event("book", {name: $/form/name}))
</a2ui>

Components take their properties positionally in the order their catalog schema declares them (or by keyword), variables name components, $ paths bind data, ?name writes a check rule and Event(...) an action. The grammar is specification/inference_formats/express/Express.g4; A2UIAgent.Express.Compiler describes how each statement compiles.

Because arguments are positional, a catalog must be read with the key order of its document: A2UICore.Catalog.Basic, A2UIAgent.CatalogConfig.from_path/2 and A2UIAgent.CatalogProvider keep it. A catalog built from a map (a document decoded without objects: :ordered_objects) has its properties ordered by name.

{:ok, format} = A2UIAgent.Express.new(catalogs, examples: [example_turn])
{:ok, prompt} = A2UIAgent.Express.prompt(format)
parser = A2UIAgent.Express.parser(format)

Options:

  • :examples — few-shot example turns (lists of messages), rendered into the prompt as Express;
  • :allowed_messages — the message actions the prompt teaches (nil, the default, teaches all of them);
  • :surface_id — the surface of statements before any surface line (default "main");
  • :version — the protocol version to write (default: the catalogs').

See A2UIAgent.Express.Prompt for the prompt and A2UIAgent.Express.Parser for reading responses. The format also provides the pieces A2UIAgent.SkillGenerator builds skills from.

Summary

Functions

The grammar rules of the prompt; see A2UIAgent.Express.Prompt.base_rules/2.

The signatures and instructions of one catalog (by id), or of all of them; see A2UIAgent.Express.Prompt.catalog_instructions/2.

The format's active catalogs, in order.

The example turns as Express blocks. Examples are not kept per catalog, so every catalog has the same ones.

Creates the format. The catalogs must be non-empty, have distinct ids and share a protocol version; several catalogs need v1.0.

A fresh parser for the format's catalogs.

The system prompt snippet; see A2UIAgent.Express.Prompt.

Types

t()

(since 0.1.0)
@type t() :: %A2UIAgent.Express{
  allowed_messages: [String.t()] | nil,
  catalogs: A2UIAgent.Express.Catalogs.t(),
  examples: [[map()]] | nil,
  surface_id: String.t()
}

Functions

base_rules(format)

(since 0.1.0)
@spec base_rules(t()) :: String.t()

The grammar rules of the prompt; see A2UIAgent.Express.Prompt.base_rules/2.

catalog_instructions(format, catalog_id \\ nil)

(since 0.1.0)
@spec catalog_instructions(t(), String.t() | nil) :: String.t()

The signatures and instructions of one catalog (by id), or of all of them; see A2UIAgent.Express.Prompt.catalog_instructions/2.

catalogs(express)

(since 0.1.0)
@spec catalogs(t()) :: [A2UICore.Catalog.t()]

The format's active catalogs, in order.

examples(format, catalog_id \\ nil)

(since 0.1.0)
@spec examples(t(), String.t() | nil) ::
  {:ok, String.t()} | {:error, A2UICore.Error.t()}

The example turns as Express blocks. Examples are not kept per catalog, so every catalog has the same ones.

new(catalogs, options \\ [])

(since 0.1.0)
@spec new([A2UICore.Catalog.t()], keyword()) ::
  {:ok, t()} | {:error, A2UICore.Error.t()}

Creates the format. The catalogs must be non-empty, have distinct ids and share a protocol version; several catalogs need v1.0.

parser(format)

(since 0.1.0)
@spec parser(t()) :: A2UIAgent.Express.Parser.t()

A fresh parser for the format's catalogs.

prompt(format)

(since 0.1.0)
@spec prompt(t()) :: {:ok, String.t()} | {:error, A2UICore.Error.t()}

The system prompt snippet; see A2UIAgent.Express.Prompt.