# `AgentDb.Core.Inference`
[🔗](https://github.com/manhvu/agent_db/blob/v0.1.0/lib/agent_db/core/inference.ex#L1)

The local model capabilities the store depends on.

Split by capability rather than by "run a model", so a workflow asks for
exactly what it needs and a provider need only supply part of the surface.
Embedding and summarization are separate callbacks because they have
different failure modes: a document's embedding is what makes it findable
by meaning, while a summary is a compression of something already readable.

## Invariants an implementation must uphold

  * `embed/1` returns vectors that are comparable with each other and stable
    for identical input, so an index built from them stays meaningful.
  * A model that is still loading is reported as loading, distinctly from a
    load that failed. `{:error, :model_loading}` is safe to repeat; a failure
    is not, and must not be disguised as one.
  * Neither an unavailable model nor a failed inference terminates the
    calling process or leaves the provider permanently unusable.

# `embedding`

```elixir
@type embedding() :: binary()
```

A query or document embedding, as float32 bytes.

# `child_specs`

```elixir
@callback child_specs(keyword()) :: [
  Supervisor.child_spec() | module() | {module(), term()}
]
```

Supervised children the provider needs.

# `embed`

```elixir
@callback embed([String.t()]) :: {:ok, [embedding()]} | {:error, term()}
```

Embeds `texts`, returning one comparable vector per input.

# `model_status`

```elixir
@callback model_status() :: map()
```

Describes the state of both models, including a load in progress.

Answerable while a load is running, so a caller can tell "still coming" from
"not there".

# `summarize`

```elixir
@callback summarize(String.t(), keyword()) :: {:ok, String.t()} | {:error, term()}
```

Summarizes `prompt`. An empty answer is an error, not an empty summary.

---

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