LLMProxy.Providers.Result (llm_proxy v0.1.1)

Copy Markdown View Source

Provider execution result tagged by response kind.

Providers return this struct from native and compatibility calls so routing, fallback, HTTP route rendering, and token accounting can branch on an explicit :kind instead of inferring meaning from nullable fields.

Summary

Types

kind()

@type kind() :: :response | :stream | :error

t()

@type t() :: %LLMProxy.Providers.Result{
  error: String.t() | nil,
  kind: kind(),
  model: String.t() | nil,
  provider: module() | nil,
  provider_body: term() | nil,
  provider_name: String.t() | nil,
  response: map() | nil,
  retry_after_ms: non_neg_integer() | nil,
  status: pos_integer() | nil,
  stream: Enumerable.t() | nil,
  token: token()
}

token()

@type token() :: map() | nil

Functions

client_error(result)

@spec client_error(t()) :: map()

error(error, status, token, opts \\ [])

@spec error(String.t(), pos_integer(), token(), keyword()) :: t()

response(body, token)

@spec response(map(), token()) :: t()

stream(stream, token)

@spec stream(Enumerable.t(), token()) :: t()

stream_failure(provider, model, token, reason)

@spec stream_failure(module(), String.t(), token(), term()) :: t()

unavailable_tokens(reason)

@spec unavailable_tokens(term()) :: {:error, t()}

with_attempt(arg, attempt)

@spec with_attempt({:ok, t()} | {:error, t()}, LLMProxy.Providers.Attempt.t()) ::
  {:ok, t()} | {:error, t()}

with_attempt(arg, provider, model)

@spec with_attempt({:ok, t()} | {:error, t()}, module(), String.t()) ::
  {:ok, t()} | {:error, t()}