LangchainPrompt.Message (LangchainPrompt v0.1.0)

Copy Markdown View Source

A single message in a conversation with an LLM.

content is either a plain string or a list of content parts for multimodal messages (text + images/files).

Plain text message

%Message{role: :user, content: "Hello"}

Multimodal message (text + image)

%Message{role: :user, content: [
  %{type: :text, content: "Describe this image"},
  %{type: :image, content: "base64...", media: :jpg}
]}

Multimodal messages are built automatically by LangchainPrompt.execute/4 when you pass attachments.

Summary

Types

content_part()

@type content_part() :: %{
  type: :text | :image | :file,
  content: String.t(),
  media: atom() | String.t() | nil
}

t()

@type t() :: %LangchainPrompt.Message{
  content: String.t() | [content_part()],
  role: :system | :user | :assistant
}