AssistantMessage

org.llm4s.llmconnect.model.AssistantMessage
See theAssistantMessage companion object
case class AssistantMessage(contentOpt: Option[String], toolCalls: Seq[ToolCall]) extends Message

A response from the LLM, optionally containing text, tool-call requests, or both.

content always returns a non-null String; it returns "" when the LLM response contains only tool calls and no accompanying text (contentOpt is None). Code that displays assistant output should check for an empty string rather than null-guarding.

A well-formed AssistantMessage must satisfy at least one of:

  • contentOpt.exists(_.trim.nonEmpty) — the LLM produced text.
  • toolCalls.nonEmpty — the LLM requested one or more tool invocations.

Value parameters

contentOpt

Text portion of the response; None when the model produced only tool calls.

toolCalls

Tool invocations requested by the model; each carries an id that must be matched by a subsequent ToolMessage.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Message
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def content: String
def hasToolCalls: Boolean
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
Message -> Any
override def validate: Result[Message]

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

Definition Classes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields