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

The agent-level entry point: the catalogs an agent supports, its
few-shot examples and its inference format, from which it creates one
`A2UIAgent.RequestProcessor` per request.

    {:ok, config} = A2UIAgent.CatalogConfig.from_path("catalogs/basic.json")
    generator = A2UIAgent.Generator.new([config], examples: [turn])

    # per request, with the capabilities the renderer sent:
    {:ok, processor} = A2UIAgent.Generator.create_processor(generator, capabilities)

Catalog negotiation follows `A2UIAgent.CatalogResolver`.

# `t`
*since 0.1.0* 

```elixir
@type t() :: %A2UIAgent.Generator{
  accepts_inline_catalogs: boolean(),
  catalogs: [A2UIAgent.CatalogConfig.t()],
  examples: [[map()]] | nil,
  format: A2UIAgent.Format.spec()
}
```

# `create_processor`
*since 0.1.0* 

```elixir
@spec create_processor(t(), map() | nil, keyword()) ::
  {:ok, A2UIAgent.RequestProcessor.t()} | {:error, A2UICore.Error.t()}
```

Creates the processor for a renderer's capabilities.

A processor is negotiated for one renderer, so `nil` capabilities are a
`:catalog` error here (although `A2UIAgent.CatalogResolver.resolve/3`
accepts them). Option: `:format` overrides the generator's format for
this processor.

# `new`
*since 0.1.0* 

```elixir
@spec new([A2UIAgent.CatalogConfig.t()], keyword()) :: t()
```

Creates a generator over the registered catalogs.

Options: `:examples`; `:format` (an `t:A2UIAgent.Format.spec/0`,
`A2UIAgent.DirectJson` by default); `:accepts_inline_catalogs`
(default `false`).

---

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