UserMessage

class UserMessage constructor(val parts: List<ContentPart>, val name: String? = null, val assets: List<Asset> = emptyList(), val timestamp: Instant = Instant.now()) : BaseMessage, UserContent, AssetView

Message sent by the user - supports multimodal content and attached assets.

Assets attached to a message that may be checkpointed (e.g. via blackboard persistence) or persisted across sessions must be serializable. Use DurableAsset (typically by materializing into an com.embabel.chat.spi.AssetStore first), or serializable assets such as MaterializableAsset.fromBytes or MaterializableAsset.fromPath. Transient stream-based assets created via MaterializableAsset.of must be materialized before attaching to a message subject to checkpointing.

Constructors

Link copied to clipboard
constructor(content: String, name: String? = null, assets: List<Asset> = emptyList(), timestamp: Instant = Instant.now())

Convenience constructor for text-only messages with optional assets.

constructor(parts: List<ContentPart>, name: String? = null, assets: List<Asset> = emptyList(), timestamp: Instant = Instant.now())

Properties

Link copied to clipboard
open override val assets: List<Asset>

All tracked assets, in order in which they were added

Link copied to clipboard
open override val content: String

Maintains backward compatibility with HasContent interface. Returns concatenated text from all TextParts.

Link copied to clipboard

Returns all document parts in this message.

Link copied to clipboard

Returns all image parts in this message.

Link copied to clipboard

Returns true if this message contains any non-text content.

Link copied to clipboard

Returns all binary media parts in this message.

Link copied to clipboard
val name: String? = null
Link copied to clipboard
Link copied to clipboard
open override val role: Role
Link copied to clipboard
Link copied to clipboard

Returns the text content of the message by concatenating all TextParts.

Link copied to clipboard
open val timestamp: Instant

Functions

Link copied to clipboard
open fun mostRecent(n: Int): AssetView

The most recently timestamped assets

Link copied to clipboard

The most recently added assets

Link copied to clipboard

Convenience method to return references. References will be converted to matryoshka tools

Link copied to clipboard
open fun since(instant: Instant): AssetView

Assets timestamped since the given instant

Link copied to clipboard
fun Message.toSpringAiMessage(toolResponseContentAdapter: ToolResponseContentAdapter = ToolResponseContentAdapter.PASSTHROUGH): <Error class: unknown class>

Convert one of our messages to a Spring AI message with multimodal support.

Link copied to clipboard
open override fun toString(): String