1. Messages are the unit of communication in chat models.
  2. They are used to represent the input and output of a chat model, as well as any additional context or metadata that may be associated with a conversation.
  3. Each message has a role (e.g., "user", "assistant") and content (e.g., text, multimodal data) with additional metadata.

A message typically consists of the following pieces of information:

Role:

  1. Roles are used to distinguish between different types of messages in a conversation and help the chat model understand how to respond to a given sequence of messages.
Role Description
system Used to tell the chat model how to behave and provide additional context. Not supported by all chat model providers.
user Represents input from a user interacting with the model, usually in the form of text or other interactive input.
assistant Represents a response from the model, which can include text or a request to invoke tools.
tool A message used to pass the results of a tool invocation back to the model after external data or processing has been retrieved. Used with chat models that support tool calling.
function (legacy) This is a legacy role, corresponding to OpenAI's legacy function-calling API. tool role should be used instead.

Content: The content of a message text or a list of dictionaries representing multimodal data (e.g., images, audio, video).

Other message data:

Depending on the chat model provider, messages can include other data such as: