Message

org.llm4s.llmconnect.model.Message
See theMessage companion object
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.

content is always a non-null, non-empty string for well-formed messages — use validate or the smart constructors on the Message companion to ensure this invariant. 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