LangChain.ChatModels.ChatModel behaviour (LangChain v0.5.1)

Copy Markdown View Source

Summary

Functions

Restore a ChatModel from a serialized config map.

Create a serializable map from a ChatModel's current configuration that can later be restored.

Types

call_response()

@type call_response() ::
  {:ok,
   LangChain.Message.t()
   | [LangChain.Message.t()]
   | [LangChain.MessageDelta.t()]}
  | {:error, LangChain.LangChainError.t()}

t()

@type t() :: Ecto.Schema.t()

tool()

@type tool() :: LangChain.Function.t()

tools()

@type tools() :: [tool()]

Callbacks

call(t, arg2, list)

@callback call(
  t(),
  String.t() | [LangChain.Message.t()],
  [LangChain.Function.t()]
) :: call_response()

restore_from_map(map)

@callback restore_from_map(%{required(String.t()) => any()}) ::
  {:ok, struct()} | {:error, String.t()}

retry_on_fallback?(t)

@callback retry_on_fallback?(LangChain.LangChainError.t()) :: boolean()

serialize_config(t)

@callback serialize_config(t()) :: %{required(String.t()) => any()}

Functions

restore_from_map(data)

@spec restore_from_map(nil | %{required(String.t()) => any()}) ::
  {:ok, struct()} | {:error, String.t()}

Restore a ChatModel from a serialized config map.

serialize_config(model)

Create a serializable map from a ChatModel's current configuration that can later be restored.