View Source LangChain.LangChainError exception (LangChain v0.3.1)

Exception used for raising LangChain specific errors.

It stores the :message. Passing an Ecto.Changeset with an error converts the error into a string message.

raise LangChainError, changeset

raise LangChainError, "Message text"

raise LangChainError, type: "overloaded", message: "Message text"

The error struct contains the following keys:

  • :type - A string code to make detecting and responding to specific errors easier. This may have values like "length" or "overloaded". The specific meaning of the type is dependent on the service or model.

  • :message - A string representation or explanation of the error.

  • :original - If a exception was caught and wrapped into a LangChainError, this may be the original message that was encountered.

Summary

Functions

Create the exception using either a message or a changeset who's errors are converted to a message.

Formats the exception as a string using a stacktrace to provide context.

Types

@type t() :: %LangChain.LangChainError{
  __exception__: true,
  message: term(),
  original: term(),
  type: term()
}

Functions

@spec exception(message :: String.t() | Ecto.Changeset.t() | keyword()) ::
  t() | no_return()

Create the exception using either a message or a changeset who's errors are converted to a message.

Link to this function

format_exception(exception, trace, format \\ :full_stacktrace)

View Source
@spec format_exception(
  exception :: struct(),
  trace :: Exception.stacktrace(),
  format :: atom()
) ::
  String.t()

Formats the exception as a string using a stacktrace to provide context.