# `Tune.Signature`
[🔗](https://github.com/mikehostetler/tune/blob/v0.5.0/lib/tune/signature.ex#L1)

Ordered, typed input and output fields plus task instructions.

    {:ok, signature} =
      Tune.Signature.new(
        instructions: "Classify the support ticket.",
        inputs: [ticket: Zoi.string(description: "Customer message")],
        outputs: [label: Zoi.enum(["billing", "bug", "other"])]
      )

Field names are normalized to strings once. Field order is preserved in
every prompt format. Input and output values are string-keyed maps.
Instructions are the only tunable part of a signature.

# `t`

```elixir
@type t() :: %Tune.Signature{
  input_schema: Zoi.schema(),
  inputs: [Tune.Field.t()],
  instructions: String.t(),
  output_schema: Zoi.schema(),
  outputs: [Tune.Field.t()]
}
```

# `input_names`

```elixir
@spec input_names(t()) :: [String.t()]
```

Returns input field names in declared order.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, Exception.t()}
```

Builds a signature.

Options:

  * `:inputs` - nonempty list of field specifications
  * `:outputs` - nonempty list of field specifications
  * `:instructions` - task instructions; defaults to a sentence naming the fields

# `normalize_inputs`

```elixir
@spec normalize_inputs(t(), map()) :: {:ok, map()} | {:error, Exception.t()}
```

Normalizes and validates input values.

Top-level keys may be declared strings or the matching trusted atoms. Unknown
keys, missing keys, and atom/string duplicates are errors. No atoms are created.

# `output_names`

```elixir
@spec output_names(t()) :: [String.t()]
```

Returns output field names in declared order.

# `put_instructions`

```elixir
@spec put_instructions(t(), String.t()) :: {:ok, t()} | {:error, Exception.t()}
```

Returns a signature with replaced instructions.

# `validate_outputs`

```elixir
@spec validate_outputs(t(), map()) :: {:ok, map()} | {:error, [Zoi.Error.t()]}
```

Validates a string-keyed output map against the declared output schema.

---

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