A2UIAgent.RequestProcessor (A2UIAgent v0.1.1)

Copy Markdown View Source

Everything an agent needs to answer one request: the negotiated catalogs, the inference format bound to them, its prompt snippet and its parsers.

A processor is normally created by A2UIAgent.Generator.create_processor/3 from the renderer's capabilities.

{:ok, processor} = A2UIAgent.RequestProcessor.new(catalogs, examples: [turn])
{:ok, prompt} = A2UIAgent.RequestProcessor.prompt(processor)
{:ok, parts} = A2UIAgent.RequestProcessor.parse_response(processor, model_output)

Summary

Functions

The active catalogs, in the renderer's order of preference.

Creates a processor over the active catalogs.

Parses and validates a complete model response with a fresh parser. Option: :wrapped (default true).

A fresh parser bound to the active catalogs.

The format's system prompt snippet.

Types

t()

(since 0.1.0)
@type t() :: %A2UIAgent.RequestProcessor{
  catalogs: [A2UICore.Catalog.t()],
  examples: [[map()]] | nil,
  format: struct()
}

Functions

active_catalogs(request_processor)

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

The active catalogs, in the renderer's order of preference.

new(catalogs, options \\ [])

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

Creates a processor over the active catalogs.

Options: :examples — few-shot example turns, each checked with A2UIAgent.PayloadValidator against the catalogs; :format — the A2UIAgent.Format.spec/0 (A2UIAgent.DirectJson by default).

parse_response(processor, content, options \\ [])

(since 0.1.0)
@spec parse_response(t(), String.t(), keyword()) ::
  {:ok, [A2UIAgent.DirectJson.Parser.part()]} | {:error, A2UICore.Error.t()}

Parses and validates a complete model response with a fresh parser. Option: :wrapped (default true).

parser(request_processor)

(since 0.1.0)
@spec parser(t()) :: struct()

A fresh parser bound to the active catalogs.

prompt(request_processor)

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

The format's system prompt snippet.