Inference.Error exception (inference v0.3.0)

Copy Markdown View Source

Stable error envelope for inference failures.

Summary

Types

category()

@type category() ::
  :invalid
  | :missing_dependency
  | :missing_credentials
  | :timeout
  | :rate_limited
  | :invalid_response
  | :unsupported_capability
  | :adapter_exception
  | :provider_error

t()

@type t() :: %Inference.Error{
  __exception__: true,
  category: category(),
  message: String.t(),
  metadata: map(),
  reason: atom()
}

Functions

adapter_exception(exception, metadata \\ [])

invalid(reason, message, metadata \\ [])

missing_credentials(provider, metadata \\ [])

missing_dependency(module, metadata \\ [])

new(category, reason, message, metadata \\ %{})

@spec new(category(), atom(), String.t(), keyword() | map()) :: t()

provider_error(reason, metadata \\ [])

response_format_unsupported(response_format, metadata \\ [])

@spec response_format_unsupported(
  term(),
  keyword()
) :: t()

Reports that an adapter cannot map a declared Inference.ResponseFormat.

Adapters return this instead of silently dropping the declared format.

unexpected_tool_call(tool_calls, metadata \\ [])

@spec unexpected_tool_call(
  list(),
  keyword()
) :: t()

Reports a provider-returned tool call on a completion-only adapter.

A returned tool call is a contract failure. Adapters never execute one.

unsupported_capability(capability, metadata \\ [])