Message

org.llm4s.llmconnect.model.Message
See theMessage companion object
@Stable
sealed trait Message

A single turn in an LLM conversation.

Conversations are sequences of Message values passed to org.llm4s.llmconnect.LLMClient. Each concrete subtype corresponds to one participant role: UserMessage, SystemMessage, AssistantMessage, ToolMessage.

A UserMessage and a ToolMessage carry ContentParts - text, images and documents; a SystemMessage and an AssistantMessage carry text. content is a message's text: for a user or tool message, its text parts joined by newlines, so "" for one that is all media. Use validate or the smart constructors on the Message companion to ensure a message has content. AssistantMessage.content returns "" rather than null when the LLM response contains only tool calls and no text.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def content: String

Concrete methods

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Validates that this message satisfies its role-specific content constraints.

Validates that this message satisfies its role-specific content constraints.

Returns Left(ValidationError) when content is blank; AssistantMessage additionally requires at least one of content or toolCalls to be present.

Attributes