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

An immutable typed predictor: a signature and its demonstrations.

`prepare/3` and `finish/2` are pure. `call/3` composes them with one
`ReqLLM.generate_text/3` request. There is no retry, repair, extraction call,
or format fallback; ReqLLM owns transport retries.

# `t`

```elixir
@type t() :: %Tune.Predictor{demos: [Tune.Demo.t()], signature: Tune.Signature.t()}
```

# `call`

```elixir
@spec call(t(), map(), Tune.ModelConfig.t(), non_neg_integer() | nil) ::
  {:ok, Tune.Step.t()} | {:error, Exception.t() | term()}
```

Prepares, executes one ReqLLM request, and finishes.

Input errors return before any request. A ReqLLM error is returned unchanged.
`remaining_ms` caps the request's `:total_timeout`.

# `finish`

```elixir
@spec finish(Tune.Prepared.t(), ReqLLM.Response.t()) ::
  {:ok, Tune.Step.t()} | {:error, Exception.t()}
```

Checks a response against a prepared request and returns a validated step.

The response must have no error or refusal and a completed finish reason:
`:stop`, or `:tool_calls` for structured output only. Structured output must
be strictly valid with no ReqLLM repair. Makes no model request.

# `new`

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

Builds a predictor.

Options:

  * `:signature` - a `Tune.Signature` or signature options
  * `:demos` - demonstrations validated against the signature

# `prepare`

```elixir
@spec prepare(t(), map(), Tune.ModelConfig.t()) ::
  {:ok, Tune.Prepared.t()} | {:error, Exception.t()}
```

Validates inputs and renders a request with the configured adapter.

Makes no model request and holds no credentials.

# `put_demos`

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

Returns the predictor with new validated demonstrations.

# `put_instructions`

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

Returns the predictor with new instructions.

---

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