# `A2UIAgent.DirectJson.Prompt`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_agent/lib/a2ui_agent/direct_json/prompt.ex#L1)

The system prompt snippet of the direct JSON format.

The snippet has three parts, separated by blank lines:

  1. `## Workflow Description:` and `workflow_rules/0`;
  2. the schemas, between `---BEGIN A2UI JSON SCHEMA---` and
     `---END A2UI JSON SCHEMA---` lines (`schema_prompt/2`);
  3. `### Examples:` and each example turn as an `<a2ui-json>` block,
     when there are examples.

# `examples`
*since 0.1.0* 

```elixir
@spec examples([[map()]] | nil) :: String.t()
```

Each example turn as an `<a2ui-json>` block, separated by blank lines;
`""` without examples. A message given as a `Jason.OrderedObject`
keeps its key order.

# `generate`
*since 0.1.0* 

```elixir
@spec generate([A2UICore.Catalog.t()], keyword()) ::
  {:ok, String.t()} | {:error, A2UICore.Error.t()}
```

Assembles the prompt snippet. Options: `:examples` (a list of turns,
each a list of messages) and `:allowed_messages` (see
`schema_prompt/2`).

# `schema_prompt`
*since 0.1.0* 

```elixir
@spec schema_prompt([A2UICore.Catalog.t()], [String.t()] | nil) ::
  {:ok, String.t()} | {:error, A2UICore.Error.t()}
```

The schemas that describe the catalogs to the model: the
agent-to-renderer schema of the catalogs' protocol version (pruned to
`allowed_messages` unless that is `nil`), the common types those
schemas use, then one section per catalog document
(`A2UICore.Catalog.to_json/2`), each as compact JSON. The protocol
schemas keep the key order they are published in, and the catalog
documents the order of the documents they were read from.

The catalogs must be non-empty and share a protocol version.

# `workflow_rules`
*since 0.1.0* 

```elixir
@spec workflow_rules() :: String.t()
```

The workflow rules every direct JSON prompt starts with.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
