A2UIAgent.DirectJson (A2UIAgent v0.1.1)

Copy Markdown View Source

The direct JSON inference format: the model writes A2UI messages as JSON between <a2ui-json> and </a2ui-json> tags, guided by the protocol and catalog JSON schemas in its prompt.

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

Options:

  • :examples — few-shot example turns (lists of messages) rendered into the prompt;
  • :allowed_messages — the message actions the prompt describes (nil, the default, describes all of them);
  • :progressive_keys — string properties the streaming parser may emit before their closing quote (progressive_keys/0 lists the usual ones).

See A2UIAgent.DirectJson.Prompt for the prompt and A2UIAgent.DirectJson.Parser for reading responses.

Summary

Functions

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

A fresh parser for the format's catalogs.

The string properties commonly healed while streaming.

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

Types

t()

(since 0.1.0)
@type t() :: %A2UIAgent.DirectJson{
  allowed_messages: [String.t()] | nil,
  catalogs: [A2UICore.Catalog.t()],
  examples: [[map()]] | nil,
  progressive_keys: [String.t()]
}

Functions

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.

parser(format)

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

A fresh parser for the format's catalogs.

progressive_keys()

(since 0.1.0)
@spec progressive_keys() :: [String.t()]

The string properties commonly healed while streaming.

iex> "text" in A2UIAgent.DirectJson.progressive_keys()
true

prompt(format)

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

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