A2UIAgent.Express.Prompt (A2UIAgent v0.1.1)

Copy Markdown View Source

The system prompt snippet of the Express format.

The snippet has three parts, separated by blank lines:

  1. ## Workflow Description: and the grammar rules (base_rules/2), with the rules for several catalogs when there are several;
  2. the positional signatures of each catalog's components and functions, and the catalog's own instructions, whose JSON examples are rewritten as Express (catalog_instructions/2);
  3. ### Examples: and each example turn as an Express block (examples/1), when there are examples.

An allowlist of message types (:allowed_messages) leaves out the rules for the statements that write other messages.

Summary

Functions

The grammar rules. With an allowlist, the rules for statements that write other messages are left out and the rest renumbered. Rule 15's root = ... example names a component of the catalogs: the first one holding a single child reference, else the first one. With several catalogs, and components or data allowed, the rules for several catalogs follow.

The signatures and instructions of one catalog (given by id), or of all of them: with several catalogs, each under a # Catalog heading.

The example turns as Express blocks, separated by blank lines. An example the catalogs cannot express is an error.

Assembles the prompt snippet for catalogs. Options: :examples (a list of turns, each a list of messages) and :allowed_messages.

The grammar rules, exactly as the reference writes them when every message type is allowed.

Functions

base_rules(catalogs, allowed_messages \\ nil)

(since 0.1.0)
@spec base_rules(A2UIAgent.Express.Catalogs.t(), [String.t()] | nil) :: String.t()

The grammar rules. With an allowlist, the rules for statements that write other messages are left out and the rest renumbered. Rule 15's root = ... example names a component of the catalogs: the first one holding a single child reference, else the first one. With several catalogs, and components or data allowed, the rules for several catalogs follow.

catalog_instructions(catalogs, catalog_id \\ nil)

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

The signatures and instructions of one catalog (given by id), or of all of them: with several catalogs, each under a # Catalog heading.

examples(catalogs, turns)

(since 0.1.0)
@spec examples(A2UIAgent.Express.Catalogs.t(), [[map()]] | nil) ::
  {:ok, String.t()} | {:error, A2UICore.Error.t()}

The example turns as Express blocks, separated by blank lines. An example the catalogs cannot express is an error.

generate(catalogs, options \\ [])

(since 0.1.0)
@spec generate(A2UIAgent.Express.Catalogs.t(), keyword()) ::
  {:ok, String.t()} | {:error, A2UICore.Error.t()}

Assembles the prompt snippet for catalogs. Options: :examples (a list of turns, each a list of messages) and :allowed_messages.

rules()

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

The grammar rules, exactly as the reference writes them when every message type is allowed.