View Source LangChain.Message (LangChain v0.1.0)
Models a complete Message
for a chat LLM.
Roles
:system
- a system message. Typically just one and it occurs first as a primer for how the LLM should behave.:user
- The user or application responses. Typically represents the "human" element of the exchange.:assistant
- Responses coming back from the LLM.:arguments
- Thearguments
can be set as a map where each key is an "argument". If set as a String, it is expected to be a JSON formatted string and will be parsed to a map. If there is an error parsing the arguments to JSON, it is considered an error.An empty map
%{}
means no arguments are passed.:function
- A message for returning the result of executing afunction_call
.
Functions
A function_call
comes from the :assistant
role. The function_name
identifies the named function to execute.
Create a message of role :function
to provide the function response.
Summary
Functions
Return if a Message is a function_call.
Build a new message and return an :ok
/:error
tuple with the result.
Build a new message and return it or raise an error if invalid.
Create a new assistant message which represents a response from the AI or LLM.
Create a new assistant message which represents a response from the AI or LLM.
Create a new function message to represent the result of an executed function.
Create a new function message to represent the result of an executed function.
Create a new function_call message to represent the request for a function to be executed.
Create a new function_call message to represent the request for a function to be executed.
Create a new system message which can prime the AI/Assistant for how to respond.
Create a new system message which can prime the AI/Assistant for how to respond.
Create a new user message which represents a human message or a message from the application.
Create a new user message which represents a human message or a message from the application.
Types
@type status() :: :complete | :cancelled | :length
Functions
Return if a Message is a function_call.
@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Build a new message and return an :ok
/:error
tuple with the result.
Build a new message and return it or raise an error if invalid.
@spec new_assistant(content :: String.t(), status()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a new assistant message which represents a response from the AI or LLM.
Create a new assistant message which represents a response from the AI or LLM.
@spec new_function(name :: String.t(), result :: any()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a new function message to represent the result of an executed function.
Create a new function message to represent the result of an executed function.
@spec new_function_call(name :: String.t(), raw_args :: String.t()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a new function_call message to represent the request for a function to be executed.
Create a new function_call message to represent the request for a function to be executed.
@spec new_system(content :: String.t()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a new system message which can prime the AI/Assistant for how to respond.
Create a new system message which can prime the AI/Assistant for how to respond.
@spec new_user(content :: String.t()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Create a new user message which represents a human message or a message from the application.
Create a new user message which represents a human message or a message from the application.