MessageContent
@JsonDeserialize(using = MessageContentDeserializer.class) @JsonSerialize(using = MessageContentSerializer.class) public sealed interface MessageContent permits MessageContent.Text, MessageContent.Blocks
io/agentscope/core/agui/model/MessageContent.java:45–72定义消息内容契约的接口。位于 io.agentscope.core.agui.model 包。
Type-safe union representing the content field of an AG-UI message.
In the AG-UI protocol, message content can be either a plain string or an
array of structured InputContent parts. This sealed interface models
that union without resorting to Object, providing compile-time type
safety and exhaustive pattern matching.
JSON forms:
-
Text→ JSON string:"Hello" -
Blocks→ JSON array:[{"type":"text","text":"Hi"},{"type":"image",...}]
Custom Jackson serialization/deserialization handles the non-object JSON
shape (scalar vs. array) via MessageContentDeserializer and
MessageContentSerializer.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Text | 记录record | 承载文本数据的记录类型。 Plain text content, serialized as a JSON string. |
Blocks | 记录record | 承载 Blocks数据的记录类型。 Structured content blocks, serialized as a JSON array of `InputContent`. |
嵌套类详情Nested Class Detail
Text
record Text(String value) implements MessageContent承载文本数据的记录类型。位于 io.agentscope.core.agui.model 包,实现 MessageContent。核心成员包括 value。
Plain text content, serialized as a JSON string.
Blocks
record Blocks(List<InputContent> parts) implements MessageContent承载 Blocks数据的记录类型。位于 io.agentscope.core.agui.model 包,实现 MessageContent。核心成员包括 parts、Blocks。
Structured content blocks, serialized as a JSON array of InputContent.