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.
Summary
Functions
Returns input field names in declared order.
Builds a signature.
Normalizes and validates input values.
Returns output field names in declared order.
Returns a signature with replaced instructions.
Validates a string-keyed output map against the declared output schema.
Types
@type t() :: %Tune.Signature{ input_schema: Zoi.schema(), inputs: [Tune.Field.t()], instructions: String.t(), output_schema: Zoi.schema(), outputs: [Tune.Field.t()] }
Functions
Returns input field names in declared order.
@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
@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.
Returns output field names in declared order.
@spec put_instructions(t(), String.t()) :: {:ok, t()} | {:error, Exception.t()}
Returns a signature with replaced instructions.
@spec validate_outputs(t(), map()) :: {:ok, map()} | {:error, [Zoi.Error.t()]}
Validates a string-keyed output map against the declared output schema.