Inference.Capability (inference v0.3.0)

Copy Markdown View Source

Data description of adapter/provider capabilities.

Adapters report capabilities so a registry can answer questions such as "does this provider accept a JSON Schema response format?" BEFORE dispatch. A capability is a claim about the adapter and the provider it is bound to; an adapter that cannot establish a claim reports :unknown rather than assuming support.

Summary

Functions

Fetches a named capability from a capability list.

Fetches a named capability or raises when the adapter does not report it.

Builds a capability claim.

Reports whether a named capability is affirmatively supported.

Returns the closed set of support states.

Types

support()

@type support() ::
  :supported | :unsupported | :partial | :provider_dependent | :unknown

t()

@type t() :: %Inference.Capability{metadata: map(), name: atom(), support: support()}

Functions

fetch(capabilities, name)

@spec fetch([t()], atom()) :: {:ok, t()} | :error

Fetches a named capability from a capability list.

fetch!(capabilities, name)

@spec fetch!([t()], atom()) :: t()

Fetches a named capability or raises when the adapter does not report it.

new(name, support, metadata \\ %{})

@spec new(atom(), support(), map()) :: t()

Builds a capability claim.

supported?(capabilities, name)

@spec supported?([t()], atom()) :: boolean()

Reports whether a named capability is affirmatively supported.

Unknown, partial, provider-dependent, and unreported capabilities are all false: only an affirmative :supported claim answers yes.

supports()

@spec supports() :: [support()]

Returns the closed set of support states.