Imp.Errors (Imp v0.5.0)

Copy Markdown View Source

Reads the failure classes callers act on, through the wrappers Imp puts around an error.

An LM error reaches a caller directly ({:error, %Imp.LMError{}}), or from a client that raised ({:lm_failed, client, exception}). These functions accept either, with or without the {:error, _} around it.

Summary

Functions

Whether the provider refused the request because its input is longer than the model accepts.

Whether sending the same request again may succeed.

Functions

context_window_exceeded?(error)

@spec context_window_exceeded?(term()) :: boolean()

Whether the provider refused the request because its input is longer than the model accepts.

iex> Imp.Errors.context_window_exceeded?(%Imp.LMError{status: 400, context_window_exceeded: true})
true

iex> Imp.Errors.context_window_exceeded?({:error, %Imp.LMError{status: 500}})
false

retryable?(error)

@spec retryable?(term()) :: boolean()

Whether sending the same request again may succeed.

iex> Imp.Errors.retryable?(%Imp.LMError{status: 429, retryable: true})
true

iex> Imp.Errors.retryable?({:error, %Imp.LMError{status: 400}})
false

iex> Imp.Errors.retryable?(%Imp.AdapterParseError{kind: :malformed})
false